flashinfer.fused_moe.prims_ts_bf16_moe¶
- flashinfer.fused_moe.prims_ts_bf16_moe(routing_logits: Tensor, routing_bias: Tensor | None, hidden_states: Tensor, gemm1_weights: Tensor, gemm2_weights: Tensor, num_experts: int, top_k: int, n_group: int | None, topk_group: int | None, intermediate_size: int, local_expert_offset: int, local_num_experts: int, routed_scaling_factor: float | None = None, routing_method_type: int = 0, use_shuffled_weight: bool = True, weight_layout: int = WeightLayout.MajorK, do_finalize: bool = True, enable_pdl: bool = True, tune_max_num_tokens: int = 8192, activation_type: int = 3, norm_topk_prob: bool = True, routing_replay_out: Tensor | None = None, gemm1_alpha: Tensor | None = None, gemm1_beta: Tensor | None = None, gemm1_clamp_limit: Tensor | None = None, output: Tensor | None = None) List[Tensor] | Tensor¶
BF16 MoE using the Prims-TS batched GEMM backend on SM100.
Same arguments and return value as
trtllm_bf16_moe().- Parameters:
routing_logits (torch.Tensor) –
[seq_len, num_experts]routing logits.routing_bias (Optional[torch.Tensor]) – Optional
[num_experts]routing bias.hidden_states (torch.Tensor) –
[seq_len, hidden_size]BF16 activations.gemm1_weights (torch.Tensor) – First-layer expert weights.
gemm2_weights (torch.Tensor) – Second-layer expert weights.
num_experts (int) – Total number of experts.
top_k (int) – Experts selected per token.
n_group (Optional[int]) – Number of expert groups (DeepSeek-style routing).
topk_group (Optional[int]) – Groups considered for top-k routing.
intermediate_size (int) – Intermediate (FFN) width.
local_expert_offset (int) – Global offset of the first local expert.
local_num_experts (int) – Number of experts resident on this device.
routed_scaling_factor (Optional[float]) – Optional routing scale.
routing_method_type (int) – Routing method selector (default
0).use_shuffled_weight (bool) – Whether weights use the shuffled MajorK layout (default
True).weight_layout (int) – Weight layout enum value (default
MajorK).do_finalize (bool) – If
True, return the finalized MoE output.enable_pdl (bool) – Enable Programmatic Dependent Launch when supported.
tune_max_num_tokens (int) – Autotune token-bucket upper bound (default
8192).activation_type (int) – Activation enum value (default Swiglu).
norm_topk_prob (bool) – Normalize top-k routing probabilities.
routing_replay_out (Optional[torch.Tensor]) – Optional buffer that captures selected expert IDs.
gemm1_alpha (Optional[torch.Tensor]) – Optional per-expert SwiGLU alpha.
gemm1_beta (Optional[torch.Tensor]) – Optional per-expert SwiGLU beta.
gemm1_clamp_limit (Optional[torch.Tensor]) – Optional per-expert clamp limit.
output (Optional[torch.Tensor]) – Optional in-place
[seq_len, hidden_size]output.
- Returns:
Same return contract as
trtllm_bf16_moe().- Return type:
torch.Tensor or List[torch.Tensor]