IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python function

mega_ffn_combine_send

mega_ffn_combine_send()​

max.nn.ep.mega_ffn_combine_send(config, buffers, grouped, route, *, n_local_experts, max_recv_tokens, gate_up_weight, gate_up_b_scales, down_weight, down_b_scales, gate_up_expert_scales, down_expert_scales, c_input_scales, estimated_total_m, activation=None)

source

Runs the routed experts’ FFN and sends its rows back, one launch each.

Each device runs one kernel, which replaces both grouped matmuls and combine_start(). The down projection writes each finished row to its source device’s receive buffer, so the FFN’s output is never stored on its own device. combine_finish() then waits for the rows.

Parameters:

  • config (EPConfig) – The expert-parallel configuration. It must not set use_allreduce or fused_shared_expert.
  • buffers (EPBuffers) – The exchange’s buffers.
  • grouped (Grouped) – The NVFP4 tokens that dispatch_finish() grouped.
  • route (Route) – The route that dispatch_finish() returned.
  • n_local_experts (int) – The number of experts on each device, which is the first dimension of the weights.
  • max_recv_tokens (int) – The most rows that a device can receive.
  • gate_up_weight (Tensor) – The local experts’ gate/up weights, in the sigma-permuted layout.
  • gate_up_b_scales (Tensor) – The gate/up weight scales.
  • down_weight (Tensor) – The local experts’ down weights.
  • down_b_scales (Tensor) – The down weight scales.
  • gate_up_expert_scales (Tensor) – Each local expert’s gate/up output scale.
  • down_expert_scales (Tensor) – Each local expert’s down output scale.
  • c_input_scales (Tensor) – Each local expert’s inverted scale for the requantization between the two matmuls.
  • estimated_total_m (Tensor) – The uint32 host scalar estimate of the routed rows per device, which selects the kernel’s tiles.
  • activation (GatedActivation | None) – The gated activation that the kernel fuses. Defaults to SiLU.

Raises:

ValueError – If check_supported() rejects config, if config sets use_allreduce or fused_shared_expert, or if config dispatches in another format than NVFP4 with one global scale. Legacy accepts per-token NVFP4 global scales here, but the kernel cannot read them, so this refusal is deliberately stricter than legacy.

Return type:

None