flashinfer.fused_moe.prims_ts_fp8_per_tensor_scale_moe¶
- flashinfer.fused_moe.prims_ts_fp8_per_tensor_scale_moe(routing_logits: Tensor, routing_bias: Tensor | None, hidden_states: Tensor, gemm1_weights: Tensor, output1_scales_scalar: Tensor, output1_scales_gate_scalar: Tensor, gemm2_weights: Tensor, output2_scales_scalar: 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, use_routing_scales_on_input: bool, routing_method_type: int = 0, do_finalize: bool = True, enable_pdl: bool | None = None, tune_max_num_tokens: int = 8192, activation_type: int = 3, norm_topk_prob: bool = True, routing_replay_out: Tensor | None = None, output: Tensor | None = None, *, weight_layout: int = 0, fc1_per_channel_weight_scale: Tensor | None = None, fc2_per_channel_weight_scale: Tensor | None = None) List[Tensor] | Tensor¶
FP8 per-tensor-scaled MoE using the Prims-TS backend on SM100.
Same arguments and return value as
trtllm_fp8_per_tensor_scale_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) –
float8_e4m3fnactivations.gemm1_weights (torch.Tensor) –
float8_e4m3fnFC1 weights.output1_scales_scalar (torch.Tensor) – Per-expert FC1 output scales.
output1_scales_gate_scalar (torch.Tensor) – Per-expert FC1 gate scales.
gemm2_weights (torch.Tensor) –
float8_e4m3fnFC2 weights.output2_scales_scalar (torch.Tensor) – Per-expert FC2 output scales.
num_experts (int) – Total number of experts.
top_k (int) – Experts selected per token.
n_group (Optional[int]) – Number of expert groups.
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.
use_routing_scales_on_input (bool) – Apply routing scales on the input path when
True.routing_method_type (int) – Routing method selector (default
0).do_finalize (bool) – If
True, return the finalized MoE output.enable_pdl (Optional[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.
output (Optional[torch.Tensor]) – Optional in-place output tensor.
weight_layout (int) – Prims-TS weight layout enum value (default
MajorK). Keyword-only.fc1_per_channel_weight_scale (Optional[torch.Tensor]) – Optional per-channel FC1 weight scales. Keyword-only.
fc2_per_channel_weight_scale (Optional[torch.Tensor]) – Optional per-channel FC2 weight scales. Keyword-only.
- Returns:
Same return contract as
trtllm_fp8_per_tensor_scale_moe().- Return type:
torch.Tensor or List[torch.Tensor]