Skip to content

[deepep_v2] support GLM-5.3-Flash (Glm5NextForConditionalGeneration) - #40466

Merged
kpham-sgl merged 4 commits into
sgl-project:mainfrom
whn09:feat/deepep-v2-glm5-next
Sep 23, 2026
Merged

kpham-sgl merged 4 commits into
sgl-project:mainfrom
whn09:feat/deepep-v2-glm5-next

Conversation

@whn09

@whn09 whn09 commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

--moe-a2a-backend deepep_v2 cannot 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_MODELS does not list it, so
validate_deepep_v2_model_architecture() rejects the server args before the
engine starts.

2. glm5_next.py gates the a2a path on a v1-only predicate.
MoeA2ABackend.is_deepep() is true only for deepep, not for deepep_v2, so
even past the first gate the model silently runs the non-a2a path:

Glm5NextModel.__init__ computes
enable_a2a_moe = is_deepep() or is_mooncake(), which stays False under v2,
so the MoE layers never route through the dispatcher.

deepseek_v2.py — an already-validated v2 model — includes is_deepep_v2() in
that predicate. This change mirrors it.

Edit after review: the first version of this PR also touched the
gemm_output_zero_allocator sizing predicate and the
shared-experts-fusion rejection reason. @mmangkad correctly pointed out that
neither does anything here, and both are reverted as of 442125e — see the
Modifications section below.

Modifications

Two lines, both load-bearing:

  • configs/moe_model_registry.py: add Glm5NextForConditionalGeneration to
    _DEEPEP_V2_MODELS (silu_mul_keep_fp32=False, same as the other entries).
  • models/glm5_next.py: include is_deepep_v2() in enable_a2a_moe.

Reverted after review (442125e), both no-ops:

  • the is_a2a_moe sizing 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_size 4096, so the block is
    unreachable for this architecture on any device.
  • the is_deepep_class_backend() switch in
    shared_experts_fusion_disable_reason, plus its import. The
    get_parallel().moe_ep_size > 1 check immediately above already returns for
    every 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 produce
correct 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):

$ curl .../v1/chat/completions -d '{... "用中文写三句话介绍长江..." , "temperature":0}'
长江是中国第一长河,全长约6300公里,也是亚洲第一、世界第三长河。它发源于青藏高原的唐古拉山脉,
自西向东流经11个省级行政区,最终在上海注入东海。长江流域物产丰富、经济发达,孕育了灿烂的中华文明,
被誉为中华民族的母亲河。
  • 8 concurrent arithmetic prompts (N * 13 for N in 3,5,7,9,11,13,17,19):
    8/8 exact.
  • 4424-token prompt (3 chunks at
    SGLANG_DEEPEP_V2_NUM_MAX_DISPATCH_TOKENS_PER_RANK=2048): correct summary.
  • zero errors/asserts in either node's log.

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 ElasticBuffer asserts on a non-NONE NCCL GIN
(csrc/kernels/backend/nccl.cu) even when EP fits inside a single NVLink
domain. 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 over
aws-ofi-nccl via NCCL_NET_PLUGIN) is the only working setting. Separately,
deep_ep/__init__.py:check_nccl_so() matches the bare substring libnccl
against /proc/self/maps, so pointing NCCL_NET_PLUGIN at
libnccl-net-ofi.so trips its "Duplicate NCCL runtime" assert; a copy under a
name not containing libnccl avoids it.

Checklist

  • Format your code according to the Code Formatting with Pre-Commit.
  • Add or update tests, or state why they are unnecessary: covered by the existing test_deepep_v2_* unit tests; this change only adds an architecture to the eligibility registry and aligns one predicate with deepseek_v2.py.
  • Update documentation as needed, or state why it is unnecessary.
  • Provide accuracy results (above).
  • For CI changes: n/a.

🤖 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

`--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.
@b8zhong b8zhong added the run-ci CI: run the baseline test suite on this PR label Sep 20, 2026
Comment thread python/sglang/srt/models/glm5_next.py Outdated
Comment on lines +1322 to +1325
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."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we revert this and the new import

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread python/sglang/srt/models/glm5_next.py Outdated
a2a_backend.is_deepep()
or a2a_backend.is_mori()
or a2a_backend.is_mooncake()
or a2a_backend.is_deepep_v2()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems dead line (this is AMD path)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

whn09 and others added 2 commits September 21, 2026 23:33
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants