Add MoE output contract for MoE tail fusion (#51407)

Signed-off-by: Jee Jee Li <jeejeelee@inferact.ai>
This commit is contained in:
Jee Jee Li
2026-08-11 22:23:59 +08:00
committed by GitHub
parent 12bea3eedc
commit dd7cc85f17
4 changed files with 127 additions and 13 deletions
@@ -1311,6 +1311,13 @@ class FusedMoEConfig:
# Only honored on the non-reduced (late-AR) TP path. Default False.
skip_final_all_reduce: bool = False
# When True, experts that can stop after GEMM2 are allowed to hand back an
# UnfinalizedMoEOutput instead of finalized states, leaving the top-k
# reduction to fuse into the consumer. Set by layers that have such a
# consumer; read through `use_deferred_moe_finalize`, which applies the
# guards. Kernels without the capability ignore it. Default False.
defer_moe_finalize: bool = False
# SwiGLU clamp limit. When set, backends that do not implement the clamp
# are filtered out by `FusedMoEExperts.is_supported_config` so the oracle
# cannot silently select one and drop the clamp.
@@ -1428,6 +1435,18 @@ class FusedMoEConfig:
def use_ep(self):
return self.moe_parallel_config.use_ep
@property
def use_deferred_moe_finalize(self) -> bool:
"""Whether experts may return an unfinalized output on this deployment.
Evaluated on read rather than in ``__post_init__`` because
``defer_moe_finalize`` is set after construction, like
``skip_final_all_reduce``.
"""
# Without TP there is no all-reduce for the top-k reduction to fuse
# into, so the deferred form buys nothing.
return self.defer_moe_finalize and self.tp_size > 1
@property
def use_deepep_ht_kernels(self):
return self.moe_parallel_config.use_deepep_ht_kernels