Skip to content

[DFLASH] Support GLM-5.3-Flash hidden-state capture - #36708

Merged
hnyls2002 merged 1 commit into
sgl-project:xinyuan/glm-5.3-flash-supportfrom
jianc99:feature/glm5-next-dflash-capture
Aug 27, 2026
Merged

hnyls2002 merged 1 commit into
sgl-project:xinyuan/glm-5.3-flash-supportfrom
jianc99:feature/glm5-next-dflash-capture

Conversation

@jianc99

@jianc99 jianc99 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Enable DFLASH speculative decoding for Glm5NextForConditionalGeneration.

GLM-5.3-Flash keeps its inter-layer mHC state at hc_mult * hidden_size, while a DFLASH draft consumes one hidden_size stream per selected target layer. The existing generic aux-hidden path therefore needs an mHC contraction when it is configured by DFLASH.

This PR is stacked on #36507 and only contains the DFLASH adapter change.

Changes

  • implement the standard set_dflash_layers_to_capture model hook
  • contract completed mHC states from hc_mult * hidden_size to hidden_size
  • keep the existing EAGLE3 capture behavior unchanged
  • keep DFLASH per-layer capture on the eager layer loop when TBO is enabled
  • add unit coverage for mHC contraction, EAGLE3 isolation, and target-layer mapping

Tests

Run in the GLM-5.3-Flash SGLang serving image based on the #36507 head:

  • python3 -m pytest -q test_glm5_next_dflash_capture.py — 3 passed
  • python3 -m pytest -q test_glm5_next_config.py test_glm5_next_pp_metadata.py test_glm5_next_dcp.py — 8 passed

Static checks:

  • ruff check passed
  • git diff --check passed

CI States

Latest PR Test (Base): ❌ Run #33085155037
Latest PR Test (Extra): ❌ Run #33085154794
Latest PR Test (AMD ROCm 7.2): ❌ Run #33085154963

@hnyls2002
hnyls2002 merged commit c4d5d45 into sgl-project:xinyuan/glm-5.3-flash-support Aug 27, 2026
79 of 89 checks passed
zijiexia added a commit that referenced this pull request Aug 27, 2026
DFLASH on this model needs the hidden-state capture from #36708, which is
merged into #36507's xinyuan/glm-5.3-flash-support branch rather than into
main -- so the image the Install accordion pins does not carry it, and the
chip as shipped composes a command that cannot start. Say so where the
reader picks it.

The speculative card had nowhere to put that: renderChip only surfaces a
tooltip while a chip is DISABLED, and DFlash2 is selectable. Give a
speculative option an optional `note`, rendered under the chip row while
that option is the one in effect, in the same amber treatment as the
under-command callouts. No config in the tree carries the field today, so
no other page changes.

The Playground bullet in section 2 gets the same prerequisite so the prose
and the card cannot drift apart.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
sfxnz pushed a commit to sfxnz/GLM-5.3-Flash-NVFP4-vLLM-2x-DGX-Spark that referenced this pull request Aug 28, 2026
… stack

v10: Glm5Next lacked the EAGLE3 interface DFlash taps target hidden states
through; capture the completed layer output with the SGLang-verified mHC
hc_post + stream-average contraction (sgl-project/sglang#36708).

v11: the bespoke GLM-5-Next KV grouping rejected the draft's sliding-window
specs, falling back to a generic path that cannot unify the indexer page.
Give the draft a dedicated KV group at a quarter of the attention block size.

run.sh grows an EXTRA_ARGS passthrough (e.g. --load-format dummy for fast
boot iteration).

Co-authored-by: Cursor <cursoragent@cursor.com>
ormandj pushed a commit to ormandj/sglang that referenced this pull request Aug 29, 2026
Leslie360 added a commit to Leslie360/sglang that referenced this pull request Sep 21, 2026
Qwen4-Exp (Qwen3.8-Flash-Next) could not emit DFlash aux hidden
states, so DFlash/DSpark drafters failed to serve it (sgl-project#38589).
Follow the GLM-5.3-Flash precedent (sgl-project#36708) and fix the three
breakages diagnosed in the issue, all inside qwen4_exp.py:

1. Capture mechanism (issue point 1): the Qwen4-Exp decoder layers
   deliberately drop the parent's layer_communicator, so the
   captured_last_layer_outputs kwarg they received was silently
   swallowed in **kwargs and never appended. Restore capture at the
   model level instead: Qwen4ExpModel.forward now appends
   _prepare_aux_hidden_state() before running any layer whose index
   is in layers_to_capture, the same point the parent's
   prepare_attn_and_capture_last_layer_outputs hook observes.

2. Decoder layers (issue point 2): with capture moved to the model
   loop, the dead captured_last_layer_outputs plumbing is removed
   from the layer call; the layers' rewritten forwards no longer
   need to consume it.

3. Return protocol (issue point 3): the second return slot is no
   longer unconditionally occupied by the hyper-connection stream.
   When aux hidden states were captured they now own the second
   slot (standard (hidden_states, aux_hidden_states) contract), so
   Qwen3VLForConditionalGeneration.forward unpacks them and the
   logits processor packs them into LogitsProcessorOutput.hidden_states
   for DFlashWorkerV2. The HC stream is still returned for the MTP
   drafter whenever aux capture is off, and
   Qwen4ExpForConditionalGeneration.forward no longer clobbers the
   packed aux states with the HC stream when capture is active.

Because qwen4-exp keeps the residual stream in the hyper-connection
layout (hc_count * hidden_size) between layers, the captured tensor
is contracted back to hidden_size via hc_contract, mirroring
glm5_next's mhc handling from sgl-project#36708; plain hidden_size inputs (the
first capture edge) pass through untouched.

Adds test/registered/unit/models/test_qwen4_exp_dflash_capture.py
with CPU-level contract tests, mirroring the glm5_next tests from
sgl-project#36708. Hardware verification is still pending.
JustinTong0323 added a commit that referenced this pull request Sep 21, 2026
…uto, pin latest

Same treatment as the GLM-5.3 page: one parsers overlayDims entry (default
on) replaces the 20 per-cell parser-flag pairs, and both flags use auto.
The page pinned the 2026-09-03 glm-5.3-flash dev image on every lane,
which predates the GLM-5.3 template detection (#38297), so auto would
misdetect; v0.5.20 (= latest) carries both GLM-5.3-Flash support (#36507)
and #38297, so dockerImages move to lmsysorg/sglang:latest. The DFlash2
note now says the pinned release image does not carry PR #36708 (merged
only into the support branch, not main).
JustinTong0323 added a commit that referenced this pull request Sep 21, 2026
…for DFlash2

Both prerequisites are in the v0.5.20 release the pages now pin: the DFlash2
drafter (#35371, merged into main 2026-08-19) and the GLM-5.3-Flash
hidden-state capture (#36708, which reached main via the #36507 squash
merge). Removes the nightly-image requirement on the GLM-5.3 page and the
support-branch checkout instructions (xinyuan/glm-5.3-flash-support) on
the Flash page; keeps the still-valid notes (CUDA/NPU-only, no
DP-Attention, draft checkpoint gating/license).
tanjiangshan added a commit to tanjiangshan/vllm-ascend that referenced this pull request Sep 27, 2026
…ner V2

The incoai/GLM-5.3-Flash-DFlash2 drafter is a standard DFlash2DraftModel, so the Ascend DFlash2 speculator path already covers the draft side. The missing piece was target-side aux hidden-state capture:

- Glm5NextModel now inherits EagleModelMixin and captures per-layer aux hidden states for DFlash drafters: the completed mHC output of layer k is materialized (deferred hc_post) and contracted to a single stream, matching the SGLang reference semantics (sgl-project/sglang#36708)
- Add SupportsEagle3 to Glm5NextForCausalLM / Glm5NextForConditionalGeneration and get_language_model() on the multimodal wrapper so load_dflash_model can share the target's embed_tokens/lm_head with the drafter
- Add UT tests/ut/models/test_glm5next_dflash_capture.py and a docs section

Note: num_speculative_tokens must be 7 (drafter block_size 8; AscendC KDA limit) and the draft requires enforce_eager on MRV2.

Signed-off-by: tanjiangshan <tanjiangshan@foxmail.com>
tanjiangshan added a commit to tanjiangshan/vllm-ascend that referenced this pull request Sep 27, 2026
…ner V2

The incoai/GLM-5.3-Flash-DFlash2 drafter is a standard DFlash2DraftModel, so the Ascend DFlash2 speculator path already covers the draft side. The missing piece was target-side aux hidden-state capture:

- Glm5NextModel now inherits EagleModelMixin and captures per-layer aux hidden states for DFlash drafters: the completed mHC output of layer k is materialized (deferred hc_post) and contracted to a single stream, matching the SGLang reference semantics (sgl-project/sglang#36708)
- Add SupportsEagle3 to Glm5NextForCausalLM / Glm5NextForConditionalGeneration and get_language_model() on the multimodal wrapper so load_dflash_model can share the target's embed_tokens/lm_head with the drafter
- Add UT tests/ut/models/test_glm5next_dflash_capture.py and a docs section

Note: num_speculative_tokens must be 7 (drafter block_size 8; AscendC KDA limit) and the draft requires enforce_eager on MRV2.

Signed-off-by: tanjiangshan <tanjiangshan@foxmail.com>
tanjiangshan added a commit to tanjiangshan/vllm-ascend that referenced this pull request Sep 27, 2026
…ner V2

The incoai/GLM-5.3-Flash-DFlash2 drafter is a standard DFlash2DraftModel, so the Ascend DFlash2 speculator path already covers the draft side. The missing piece was target-side aux hidden-state capture:

- Glm5NextModel now inherits EagleModelMixin and captures per-layer aux hidden states for DFlash drafters: the completed mHC output of layer k is materialized (deferred hc_post) and contracted to a single stream, matching the SGLang reference semantics (sgl-project/sglang#36708)
- Add SupportsEagle3 to Glm5NextForCausalLM / Glm5NextForConditionalGeneration and get_language_model() on the multimodal wrapper so load_dflash_model can share the target's embed_tokens/lm_head with the drafter
- Add UT tests/ut/models/test_glm5next_dflash_capture.py and a docs section

Note: num_speculative_tokens must be 7 (drafter block_size 8; AscendC KDA limit) and the draft requires enforce_eager on MRV2.

Signed-off-by: tanjiangshan <tanjiangshan@foxmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants