[TPU] Add kernel test for moe_pallas (#17496)

Signed-off-by: Michael Goin <mgoin64@gmail.com>
This commit is contained in:
Michael Goin
2025-05-06 17:59:57 -07:00
committed by GitHub
parent a17cef70ea
commit e50a1f1a9c
4 changed files with 96 additions and 3 deletions
@@ -11,7 +11,9 @@ def fused_moe(
w2: torch.Tensor,
gating_output: torch.Tensor,
topk: int,
renormalize: bool,
global_num_experts: int,
expert_map: torch.Tensor = None,
renormalize: bool = False,
) -> torch.Tensor:
"""
Args:
@@ -20,6 +22,7 @@ def fused_moe(
w2: [num_experts, hidden_size, intermediate_size]
gating_output: [*, num_experts]
"""
assert expert_map is None, "expert_map is not supported for pallas MoE."
orig_shape = hidden_states.shape
hidden_size = hidden_states.shape[-1]
num_tokens = hidden_states.shape[:-1].numel()