Skip to content

vllm.model_executor.layers.fused_moe.deep_gemm_utils

Taken from https://github.com/ModelTC/LightLLM/blob/8ed97c74c18f11505b048b1ba00ba5c0cef8bff6/lightllm/common/fused_moe/deepep_scatter_gather.py and updated to fit vllm needs and terminology.

Functions:

compute_aligned_M_and_alignment(M, num_topk, local_num_experts, alignment, expert_tokens_meta)

Return (M_sum, alignment_used).

alignment_used may be smaller than the caller-supplied alignment on SM100/SM120 when DeepGEMM can JIT a smaller BLOCK_M for the per-call expected_m. Callers that index by block size (e.g. M_sum // block_m) or assert workspace alignment must use the returned alignment_used, not their original alignment argument.