Repository navigation
[deepep_v2] support GLM-5.3-Flash (Glm5NextForConditionalGeneration) - #40466
Conversation
`--moe-a2a-backend deepep_v2` could not be used with GLM-5.3-Flash for two
independent reasons.
1. `moe_model_registry._DEEPEP_V2_MODELS` did not list the architecture, so
`validate_deepep_v2_model_architecture()` rejected the server args outright.
2. Even past that gate the model silently took the non-a2a path, because
`glm5_next.py` gates on `MoeA2ABackend.is_deepep()`, which is v1-only:
* `Glm5NextModel.__init__` sets `enable_a2a_moe = is_deepep() or
is_mooncake()`, so under v2 it stayed `False` and the MoE layers never
used the dispatcher.
* the `gemm_output_zero_allocator` sizing computed
`tp_size = get_parallel().tp_size` instead of 1, so the shared-expert
output buffer was sized for the tensor-parallel layout while DeepEP
hands back per-rank tokens.
`deepseek_v2.py` already includes `is_deepep_v2()` in both of those
predicates; this mirrors it.
Also switches the shared-experts-fusion rejection reason to
`is_deepep_class_backend()`, matching deepseek_v2.py. Not load-bearing today
(`_handle_a2a_moe` already forces `disable_shared_experts_fusion` under v2),
included so the two models agree.
Tested on 2x p5.48xlarge (H100 80GB x8, EFAv2), GLM-5.3-Flash:
* TP=8 EP=8 1P1D PD-disaggregated, `--moe-a2a-backend deepep_v2`,
`deepep_v2_mode=direct`: server reaches "fired up", PD warmup completes and
generations are correct.
* TP=16 EP=16 across both nodes (cross-node all-to-all).
Note for other EFA users: DeepEP v2's `ElasticBuffer` requires a non-NONE
NCCL GIN even when EP fits inside one NVLink domain. On H100 + EFAv2 there is
no GDAKI, so `NCCL_GIN_TYPE=2` (PROXY, over aws-ofi-nccl as
`NCCL_NET_PLUGIN`) is the only working setting. That is deployment config,
not part of this change.
| if is_deepep_class_backend(): | ||
| return ( | ||
| "Shared experts fusion is not supported when Deepep MoE backend " | ||
| "is enabled." | ||
| "Shared experts fusion is not supported when a DeepEP-family MoE " | ||
| "backend is enabled." |
There was a problem hiding this comment.
Can we revert this and the new import
There was a problem hiding this comment.
Done — reverted in 442125e, along with the import. You're right that it changed nothing: the get_parallel().moe_ep_size > 1 check immediately above already returns for every DeepEP-family configuration, so widening this branch was cosmetic. Keeping the diff to the two functional lines.
| a2a_backend.is_deepep() | ||
| or a2a_backend.is_mori() | ||
| or a2a_backend.is_mooncake() | ||
| or a2a_backend.is_deepep_v2() |
There was a problem hiding this comment.
Seems dead line (this is AMD path)
There was a problem hiding this comment.
Good catch — removed in 442125e.
I'd missed that the enclosing block is gated on _use_aiter_gfx95 and config.n_routed_experts == 256 and self.embed_tokens.embedding_dim == 7168. Besides being AMD-only, GLM-5.3-Flash is 288 routed experts with hidden_size 4096, so this block is unreachable for this architecture on any device. My PR description listed it as a second functional blocker, which was wrong — I've corrected that too.
The only load-bearing change left in this file is enable_a2a_moe.
Both of @mmangkad's comments are correct, and both are pure removals. 1. The `is_a2a_moe` hunk was a dead line. Its enclosing block is gated on `_use_aiter_gfx95 and config.n_routed_experts == 256 and self.embed_tokens.embedding_dim == 7168` — AMD gfx95 only, and GLM-5.3-Flash is 288 routed experts with hidden_size 4096, so the block is unreachable for this architecture on any device. My original commit message listed it as a second functional blocker; that was wrong. 2. The `is_deepep_class_backend()` switch in `shared_experts_fusion_disable_reason` changed no behaviour: the `get_parallel().moe_ep_size > 1` check immediately above it already returns for every DeepEP-family configuration. Reverted along with the import. What remains is the actual enablement, and nothing else: * `moe_model_registry.py`: register `Glm5NextForConditionalGeneration` so `validate_deepep_v2_model_architecture()` stops rejecting the server args. * `glm5_next.py`: include `is_deepep_v2()` in `enable_a2a_moe`, since `MoeA2ABackend.is_deepep()` is an exact-equality check on `DEEPEP` and under v2 the MoE layers otherwise never route through the dispatcher. Co-Authored-By: Claude Opus 5 <[email protected]>
Motivation
--moe-a2a-backend deepep_v2cannot be used with GLM-5.3-Flash(
Glm5NextForConditionalGeneration). There are two independent blockers.1. The architecture is not registered as v2-eligible.
moe_model_registry._DEEPEP_V2_MODELSdoes not list it, sovalidate_deepep_v2_model_architecture()rejects the server args before theengine starts.
2.
glm5_next.pygates the a2a path on a v1-only predicate.MoeA2ABackend.is_deepep()is true only fordeepep, not fordeepep_v2, soeven past the first gate the model silently runs the non-a2a path:
Glm5NextModel.__init__computesenable_a2a_moe = is_deepep() or is_mooncake(), which staysFalseunder v2,so the MoE layers never route through the dispatcher.
deepseek_v2.py— an already-validated v2 model — includesis_deepep_v2()inthat predicate. This change mirrors it.
Modifications
Two lines, both load-bearing:
configs/moe_model_registry.py: addGlm5NextForConditionalGenerationto_DEEPEP_V2_MODELS(silu_mul_keep_fp32=False, same as the other entries).models/glm5_next.py: includeis_deepep_v2()inenable_a2a_moe.Reverted after review (442125e), both no-ops:
is_a2a_moesizing predicate. Its enclosing block is gated on_use_aiter_gfx95 and config.n_routed_experts == 256 and self.embed_tokens.embedding_dim == 7168. Beyond being AMD gfx95 only,GLM-5.3-Flash is 288 routed experts with
hidden_size4096, so the block isunreachable for this architecture on any device.
is_deepep_class_backend()switch inshared_experts_fusion_disable_reason, plus its import. Theget_parallel().moe_ep_size > 1check immediately above already returns forevery DeepEP-family configuration.
Accuracy Test
Hardware: 2x
p5.48xlarge(8x H100 80GB, EFAv2), model GLM-5.3-Flash,--moe-runner-backend deep_gemm,deepep_v2_mode=direct.Both arms reach
The server is fired up and ready to roll!and producecorrect output; before this change the server either fails server-arg
validation or runs without the dispatcher.
TP=8 / EP=8, 1P1D PD-disaggregated (Mooncake over EFA): PD warmup
completes; 7/7 requests correct, zero KV-transfer errors on either side.
TP=16 / EP=16 across both nodes (so dispatch/combine genuinely crosses the
network, not just NVLink):
N * 13for N in 3,5,7,9,11,13,17,19):8/8 exact.
SGLANG_DEEPEP_V2_NUM_MAX_DISPATCH_TOKENS_PER_RANK=2048): correct summary.Benchmark & Profiling
Not included — this change is about functional enablement, and the runs above
were correctness-focused. Happy to add throughput numbers if useful.
Notes for other EFA users (deployment, not part of this change)
DeepEP v2's
ElasticBufferasserts on a non-NONE NCCL GIN(
csrc/kernels/backend/nccl.cu) even when EP fits inside a single NVLinkdomain. On H100 + EFAv2 there is no GDAKI, so the aws-ofi-nccl GIN plugin
(self-reported type 5) is unusable and
NCCL_GIN_TYPE=2(PROXY, layered overaws-ofi-nccl via
NCCL_NET_PLUGIN) is the only working setting. Separately,deep_ep/__init__.py:check_nccl_so()matches the bare substringlibncclagainst
/proc/self/maps, so pointingNCCL_NET_PLUGINatlibnccl-net-ofi.sotrips its "Duplicate NCCL runtime" assert; a copy under aname not containing
libncclavoids it.Checklist
test_deepep_v2_*unit tests; this change only adds an architecture to the eligibility registry and aligns one predicate withdeepseek_v2.py.🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ❌ Run #35668543040
Latest PR Test (Extra): ❌ Run #35668542885
Latest PR Test (AMD ROCm 10): ❌ Run #35668543038