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
DistributedEPDispatchBlockScaledNV
struct DistributedEPDispatchBlockScaledNV
Registers the mo.distributed.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, //, target: StringSlice[ImmStaticOrigin], _trace_name: StringSlice[ImmStaticOrigin]](output_tokens: VariadicTensors[IOSpec[_, _].Output, static_specs=output_tokens.static_specs], output_scales: VariadicTensors[IOSpec[_, _].Output, static_specs=output_scales.static_specs], row_offsets: VariadicTensors[IOSpec[_, _].Output, static_specs=row_offsets.static_specs], scales_offsets: VariadicTensors[IOSpec[_, _].Output, static_specs=scales_offsets.static_specs], expert_ids: VariadicTensors[IOSpec[_, _].Output, static_specs=expert_ids.static_specs], src_info: VariadicTensors[IOSpec[_, _].Output, static_specs=src_info.static_specs], input_tokens: VariadicTensors[IOSpec[_, _].Input, static_specs=input_tokens.static_specs], topk_ids: VariadicTensors[IOSpec[_, _].Input, static_specs=topk_ids.static_specs], send_ptrs: VariadicTensors[IOSpec[_, _].Input, static_specs=send_ptrs.static_specs], recv_ptrs: VariadicTensors[IOSpec[_, _].Input, static_specs=recv_ptrs.static_specs], recv_count_ptrs: VariadicTensors[IOSpec[_, _].Input, static_specs=recv_count_ptrs.static_specs], input_scales: VariadicTensors[IOSpec[_, _].Input, static_specs=input_scales.static_specs], atomic_counters: VariadicTensors[IOSpec[_, _].MutableInput, static_specs=atomic_counters.static_specs], dev_ctxs: DeviceContextArray)
Multi-device fused Expert Parallelism NVFP4 dispatch.
Launches the EP dispatch kernel on all devices simultaneously via _ep_launch_device_collective. Each device routes its tokens to experts based on top-k IDs, quantizes them to NVFP4 format, and sends them to the appropriate peer devices.
Parameters:
- βinput_dtype (
DType):DTypeof the input tokens before quantization (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). - βtarget (
StringSlice[ImmStaticOrigin]): Compile-time device target. - β_trace_name (
StringSlice[ImmStaticOrigin]): Trace label for this op.
Args:
- βoutput_tokens (
VariadicTensors[IOSpec[_, _].Output, static_specs=output_tokens.static_specs]): Output variadic tensors storing the dispatched NVFP4-quantized tokens, one per device. - βoutput_scales (
VariadicTensors[IOSpec[_, _].Output, static_specs=output_scales.static_specs]): Output variadic tensors storing the NVFP4 block scales, one per device. - βrow_offsets (
VariadicTensors[IOSpec[_, _].Output, static_specs=row_offsets.static_specs]): Output variadic tensors storing the row offsets for the received tokens, one per device. - βscales_offsets (
VariadicTensors[IOSpec[_, _].Output, static_specs=scales_offsets.static_specs]): Output variadic tensors storing the offsets into the scales buffer, one per device. - βexpert_ids (
VariadicTensors[IOSpec[_, _].Output, static_specs=expert_ids.static_specs]): Output variadic tensors storing the expert ID for each received token, one per device. - βsrc_info (
VariadicTensors[IOSpec[_, _].Output, static_specs=src_info.static_specs]): Output variadic tensors recording the originating rank and token index for each received token, one per device. - βinput_tokens (
VariadicTensors[IOSpec[_, _].Input, static_specs=input_tokens.static_specs]): Input variadic tensors of tokens to dispatch, one per device. - βtopk_ids (
VariadicTensors[IOSpec[_, _].Input, static_specs=topk_ids.static_specs]): Input variadic tensors of top-k expert IDs per token, one per device. - βsend_ptrs (
VariadicTensors[IOSpec[_, _].Input, static_specs=send_ptrs.static_specs]): Send buffer pointers for the dispatch phase, one per device. - βrecv_ptrs (
VariadicTensors[IOSpec[_, _].Input, static_specs=recv_ptrs.static_specs]): Receive buffer pointers for the dispatch phase, one per device. - βrecv_count_ptrs (
VariadicTensors[IOSpec[_, _].Input, static_specs=recv_count_ptrs.static_specs]): Receive count buffer pointers tracking tokens received per expert, one per device. - βinput_scales (
VariadicTensors[IOSpec[_, _].Input, static_specs=input_scales.static_specs]): Input variadic tensors of global input scales for NVFP4 quantization, one per device. - βatomic_counters (
VariadicTensors[IOSpec[_, _].MutableInput, static_specs=atomic_counters.static_specs]): Atomic counters coordinating work across thread blocks, one per device. - βdev_ctxs (
DeviceContextArray): List of GPU device contexts, one per device.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!