For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo struct
Struct_ep_dispatch_block_scaled_nv
struct Struct_ep_dispatch_block_scaled_nv
Registers the ep.dispatch.block.scaled.nv graph op with the graph compiler.
Implemented traitsβ
Methodsβ
executeβ
static def execute[input_dtype: DType, dispatch_dtype: DType, dispatch_scale_dtype: DType, hidden_size: Int, top_k: Int, n_experts: Int, max_token_per_rank: Int, n_gpus_per_node: Int, n_nodes: Int, fused_shared_expert: Bool, skip_a2a: Bool, allreduce_world_size: Int, //, target: StringSlice[ImmStaticOrigin]](output_tokens: ManagedTensorSlice[IOSpec[_, _].Output, static_spec=output_tokens.static_spec], output_scales: ManagedTensorSlice[IOSpec[_, _].Output, static_spec=output_scales.static_spec], row_offsets: ManagedTensorSlice[IOSpec[_, _].Output, static_spec=row_offsets.static_spec], scales_offsets: ManagedTensorSlice[IOSpec[_, _].Output, static_spec=scales_offsets.static_spec], expert_ids: ManagedTensorSlice[IOSpec[_, _].Output, static_spec=expert_ids.static_spec], src_info: ManagedTensorSlice[IOSpec[_, _].Output, static_spec=src_info.static_spec], atomic_counters: ManagedTensorSlice[IOSpec[_, _].MutableInput, static_spec=atomic_counters.static_spec], input_tokens: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=input_tokens.static_spec], topk_ids: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=topk_ids.static_spec], send_ptrs: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=send_ptrs.static_spec], recv_ptrs: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=recv_ptrs.static_spec], recv_count_ptrs: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=recv_count_ptrs.static_spec], input_scales: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=input_scales.static_spec], context: DeviceContext)
Execute the fused Expert Parallelism NVFP4 dispatch kernel. Tokens are dispatched in NVFP4 format.
Parameters:
- βinput_dtype (
DType):DTypeof the input tokens before dispatch (inferred). - βdispatch_dtype (
DType):DTypeused for the quantized token payload during dispatch (inferred). - βdispatch_scale_dtype (
DType):DTypeof the block scales accompanying the dispatched tokens (inferred). - βhidden_size (
Int): Size of the model's hidden dimension (inferred). - βtop_k (
Int): Number of experts each token is routed to (inferred). - βn_experts (
Int): Total number of experts across all GPUs (inferred). - βmax_token_per_rank (
Int): Maximum number of tokens per GPU (inferred). - βn_gpus_per_node (
Int): Number of GPUs per node (inferred). - βn_nodes (
Int): Number of physical nodes (inferred). - βfused_shared_expert (
Bool): Whether a shared expert is fused into the dispatch kernel (inferred). - βskip_a2a (
Bool): Whether to skip the all-to-all communication and send tokens only within the current device (inferred). - βallreduce_world_size (
Int): Number of ranks participating in the allreduce following dispatch (inferred). - βtarget (
StringSlice[ImmStaticOrigin]): Compile-time device target.
Args:
- βoutput_tokens (
ManagedTensorSlice[IOSpec[_, _].Output, static_spec=output_tokens.static_spec]): Output tensor storing the received tokens in NVFP4 format. - βoutput_scales (
ManagedTensorSlice[IOSpec[_, _].Output, static_spec=output_scales.static_spec]): Output tensor storing the NVFP4 block scales for the received tokens. - βrow_offsets (
ManagedTensorSlice[IOSpec[_, _].Output, static_spec=row_offsets.static_spec]): Output tensor storing the row offsets for the received tokens. - βscales_offsets (
ManagedTensorSlice[IOSpec[_, _].Output, static_spec=scales_offsets.static_spec]): Output tensor storing the offsets into the scales buffer for the received tokens. - βexpert_ids (
ManagedTensorSlice[IOSpec[_, _].Output, static_spec=expert_ids.static_spec]): Output tensor storing the expert ID for each received token. - βsrc_info (
ManagedTensorSlice[IOSpec[_, _].Output, static_spec=src_info.static_spec]): Output tensor recording the originating rank and token index for each received token. Shape[num_tokens, 2]. - βatomic_counters (
ManagedTensorSlice[IOSpec[_, _].MutableInput, static_spec=atomic_counters.static_spec]): Atomic counters coordinating work across thread blocks during the dispatch phase. - βinput_tokens (
ManagedTensorSlice[IOSpec[_, _].Input, static_spec=input_tokens.static_spec]): Input tokens to dispatch to experts. Shape[num_tokens, hidden_size]. - βtopk_ids (
ManagedTensorSlice[IOSpec[_, _].Input, static_spec=topk_ids.static_spec]): Input tensor of top-k expert IDs per token. Shape[num_tokens, top_k]. - βsend_ptrs (
ManagedTensorSlice[IOSpec[_, _].Input, static_spec=send_ptrs.static_spec]): Send buffer pointers for the dispatch phase. - βrecv_ptrs (
ManagedTensorSlice[IOSpec[_, _].Input, static_spec=recv_ptrs.static_spec]): Receive buffer pointers for the dispatch phase. - βrecv_count_ptrs (
ManagedTensorSlice[IOSpec[_, _].Input, static_spec=recv_count_ptrs.static_spec]): Receive count buffer pointers tracking tokens received per expert. - βinput_scales (
ManagedTensorSlice[IOSpec[_, _].Input, static_spec=input_scales.static_spec]): Global input scales for NVFP4 quantization. - βcontext (
DeviceContext): GPU device context for the current device.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!