Skip to content

vllm.model_executor.layers.fused_moe.prepare_finalize.deepep_v2

Classes:

DeepEPV2PrepareAndFinalize

Bases: FusedMoEPrepareAndFinalizeModular

Prepare/Finalize using DeepEP v2 ElasticBuffer (unified API).

Uses non-expanded dispatch without CPU synchronization in every forward. The receive capacity is bounded by the DP-wide padded token count. Expert kernels consume routing IDs and GPU-side receive counts.

Dispatch always uses async_with_compute_stream=False. finalize_async issues the combine with async_with_compute_stream=True (except under DBO) so the modular kernel can overlap the shared-expert FFN with the combine a2a; the returned receiver joins via a device-side event wait.

_pack_mxfp8_scale(scale)

Pack row-major [M, K/32] UE8M0 scales into [M, K/128] int32.

DeepEP moves scale factors as opaque 4-byte packs (sf_pack_t is a float/UE8M0x4 union), so 1-byte UE8M0 scales must be packed 4-per-int32.

_quantize_before_dispatch(quant_config, defer_input_quant)

Do quantized dispatch for blockfp8 and mxfp8, unless the subsequent moe kernel requires bf16 inputs.

_unpack_mxfp8_scale(scale, hidden_size, is_scale_swizzled)

Inverse of _pack_mxfp8_scale, restoring the expert kernel's layout.

TRTLLM consumes the row-major [M, K/32] scales as-is; CUTLASS wants them swizzled into F8_128x4, which can only happen here because the swizzle interleaves scales across a 128-row tile (i.e. across tokens).