Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/transformers/integrations/hub_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ def use_kernel_forward_from_hub(layer_name: str):
)
},
},
"ScatterMoEGatedMLP": {
"cuda": {
Mode.TRAINING: LayerRepository(
repo_id="kernels-community/scattermoe", layer_name="ScatterMoEGatedMLP"
),
Mode.INFERENCE: LayerRepository(
repo_id="kernels-community/scattermoe", layer_name="ScatterMoEGatedMLP"
),
},
},
"FastGELU": {
"cuda": {
Mode.INFERENCE | Mode.TORCH_COMPILE: LayerRepository(
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/granitemoe/modeling_granitemoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def forward(self, hidden_states):
return index_sorted_experts, batch_index, batch_gates, expert_size, logits


@use_kernel_forward_from_hub("ScatterMoEGatedMLP")
class GraniteMoeMoE(nn.Module):
"""
A Sparsely gated mixture of experts layer with 1-layer Feed-Forward networks as experts.
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/granitemoe/modular_granitemoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from ...activations import ACT2FN
from ...cache_utils import Cache, DynamicCache
from ...integrations import use_kernel_forward_from_hub
from ...masking_utils import create_causal_mask
from ...modeling_outputs import MoeCausalLMOutputWithPast, MoeModelOutputWithPast
from ...modeling_utils import PreTrainedModel
Expand Down Expand Up @@ -49,6 +50,7 @@ class GraniteMoeTopKGating(JetMoeTopKGating):
pass


@use_kernel_forward_from_hub("ScatterMoEGatedMLP")
class GraniteMoeMoE(nn.Module):
"""
A Sparsely gated mixture of experts layer with 1-layer Feed-Forward networks as experts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@ def forward(self, hidden_states):
return index_sorted_experts, batch_index, batch_gates, expert_size, logits


@use_kernel_forward_from_hub("ScatterMoEGatedMLP")
class GraniteMoeHybridMoE(nn.Module):
"""
A Sparsely gated mixture of experts layer with 1-layer Feed-Forward networks as experts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def forward(self, hidden_states):
return index_sorted_experts, batch_index, batch_gates, expert_size, logits


@use_kernel_forward_from_hub("ScatterMoEGatedMLP")
class GraniteMoeSharedMoE(nn.Module):
"""
A Sparsely gated mixture of experts layer with 1-layer Feed-Forward networks as experts.
Expand Down