Skip to content

[Fix][BCG][Spec] Restore EAGLE prefill plumbing dropped by #23906 - #28870

Merged
ch-wan merged 2 commits into
sgl-project:mainfrom
Oasis-Git:eagle-prefill-skip-rationale
Jun 22, 2026
Merged

ch-wan merged 2 commits into
sgl-project:mainfrom
Oasis-Git:eagle-prefill-skip-rationale

Conversation

@Oasis-Git

@Oasis-Git Oasis-Git commented Jun 22, 2026 •

Copy link
Copy Markdown
Collaborator

The cuda graph runner refactor (#23906) consolidated BCG and PCG into PrefillCudaGraphRunner but dropped four #25795 hooks needed for BCG+EAGLE end to end:

  • init: capture_hidden_mode for BCG+EAGLE — draft worker LAST, target worker FULL.
  • init: allocate static_draft_hidden_states buffer for BCG+draft+EAGLE (captured segments hold its address).
  • capture_prepare: pass spec_info=EagleDraftInput(hidden_states=...) aliasing the static buffer instead of spec_info=None.
  • load_batch: copy live forward_batch.spec_info.hidden_states into the static buffer before replay.

Also narrow the existing model_runner.py skip block to non-BCG so the restored target-FULL capture isn't short-circuited to eager_runner. tc_piecewise stays on the skip — it has no pre-#23906 logic to restore here, and its dead-graph capture corrupts FP4 / TRTLLM-MoE decode replay (see #28386).

Alternative to PR #28809, which only attempted the target-worker capture_hidden_mode flip, botched the tc_piecewise branch (codex P1), and dropped the skip block — reproducing the #28386 corruption end to end (gsm8k=0.0 on test_deepseek_v3_fp4_mtp_small in PR Test (Base)).

Motivation

Modifications

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #27932537034
Latest PR Test (Extra): ❌ Run #27932536842

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@Oasis-Git

Copy link
Copy Markdown
Collaborator Author

/tag-run-ci-label

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Jun 22, 2026
@Oasis-Git Oasis-Git added bypass-fastfail run-ci-extra CI: also run the extra suite (requires run-ci) labels Jun 22, 2026
@Oasis-Git
Oasis-Git force-pushed the eagle-prefill-skip-rationale branch 2 times, most recently from 82f50e8 to de3ebbf Compare June 22, 2026 05:12
… from sgl-project#25795

The cuda graph runner refactor (sgl-project#23906) consolidated BCG and PCG into
PrefillCudaGraphRunner but dropped four sgl-project#25795 hooks needed for
BCG+EAGLE end to end:

  * __init__: capture_hidden_mode for BCG+EAGLE — draft worker LAST,
    target worker FULL.
  * __init__: allocate static_draft_hidden_states buffer for
    BCG+draft+EAGLE (captured segments hold its address).
  * capture_prepare: pass spec_info=EagleDraftInput(hidden_states=...)
    aliasing the static buffer instead of spec_info=None.
  * load_batch: copy live forward_batch.spec_info.hidden_states into
    the static buffer before replay.

Also narrow the existing model_runner.py skip block to non-BCG so the
restored target-FULL capture isn't short-circuited to eager_runner.
tc_piecewise stays on the skip — it has no pre-sgl-project#23906 logic to restore
here, and its dead-graph capture corrupts FP4 / TRTLLM-MoE decode
replay (see sgl-project#28386).

Alternative to PR sgl-project#28809, which only attempted the target-worker
capture_hidden_mode flip, botched the tc_piecewise branch (codex P1),
and dropped the skip block — reproducing the sgl-project#28386 corruption end to
end (gsm8k=0.0 on test_deepseek_v3_fp4_mtp_small in PR Test (Base)).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@Oasis-Git
Oasis-Git force-pushed the eagle-prefill-skip-rationale branch from de3ebbf to 1068d5e Compare June 22, 2026 05:37
@ch-wan
ch-wan merged commit 2ce3236 into sgl-project:main Jun 22, 2026
274 of 291 checks passed
]
timeout_mult = 3
server_env = {"SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN": "1"}
accuracy_threshold = 0.75

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

how do you assert the cuda graph is turned on for both the draft model and target model?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I made a local assert to verify whether:

prefill_cg_target == "PrefillCudaGraphRunner(BreakableCudaGraphBackend)"  ✓ 
prefill_cg_draft  == "PrefillCudaGraphRunner(BreakableCudaGraphBackend)"  ✓

Let me check if an assert can be added in test file directly.

Oasis-Git added a commit to Oasis-Git/sglang that referenced this pull request Jun 29, 2026
…hidden width

sgl-project#28870 restored the BCG EAGLE draft-prefill plumbing but sized
static_draft_hidden_states from fc.in_features. That is correct only for EAGLE3,
whose fc consumes the aux-stacked target hidden directly. EAGLE-v1's fc instead
consumes cat([embed(H), target_hidden(H)]), so fc.in_features overcounts the
target-hidden slice by H: spec_info.hidden_states becomes 2H wide and the draft
prefill capture crashes at llama_eagle.py fc with
"mat1 and mat2 shapes cannot be multiplied (Nx3H and 2HxH)".

Gate the fc.in_features shortcut to EAGLE3; route EAGLE-v1 (and any arch without
an fc) to get_draft_hidden_dim(), which already returns the correct width for
both algorithms. EAGLE3 behavior is unchanged.

Verified on B200 with Llama-2-7b-chat-hf + sglang-EAGLE-llama2-chat-7B:
TestEagleLlama2Chunked4 -> 4 passed; TestEagleLlama2Suite -> 14 passed + 2 subtests.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) speculative-decoding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants