Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request simplifies and improves CUDA graph handling for EAGLE-family target workers. Instead of disabling the prefill CUDA graph entirely for the EAGLE target worker when return hidden states is disabled, the code now ensures that the prefill CUDA graph runner captures the FULL hidden states up front when running as an EAGLE target worker. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/tag-and-rerun-ci |
PrefillCudaGraphRunner captures with CaptureHiddenMode.NULL by default and only flips to FULL for enable_return_hidden_states or DFLASH. EAGLE target prefill, however, must produce FULL hidden states to feed the draft model -- so can_run_graph (which rejects on hidden-mode mismatch) rejected every EAGLE-target prefill batch and the captured graph was allocated but never replayed (~0.7-0.8 GB of dead memory). This was a regression from #23906 (Cuda Graph Runner/Backend Refactor), which consolidated BreakableCudaGraphRunner into PiecewiseCudaGraphRunner but dropped BCG's EAGLE-aware FULL-capture logic. Restore it so the captured graph is actually usable, then drop the now-redundant skip that #28386 added as a workaround in init_prefill_cuda_graph. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
024f1fd to
cff9e11
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 894df71efc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| else: | ||
| if ( | ||
| model_runner.server_args.enable_return_hidden_states | ||
| or model_runner.spec_algorithm.is_dflash() | ||
| ): | ||
| self.capture_hidden_mode = CaptureHiddenMode.FULL |
There was a problem hiding this comment.
Capture FULL hidden states for EAGLE tc_piecewise
When the prefill backend remains tc_piecewise (the default), this branch leaves capture_hidden_mode as NULL for EAGLE target workers. However EagleWorker.forward_batch_generation sets target prefill batches to CaptureHiddenMode.FULL so the draft can consume the hidden states, and can_run_graph rejects any mismatch; as a result every EAGLE target prefill still falls back to eager while ModelRunner no longer skips the capture, reintroducing the dead graph allocation/startup cost for the default backend. Include the EAGLE target condition in the tc_piecewise path too, not only BREAKABLE.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a32cf0eefc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… 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]>
…c_piecewise PrefillCudaGraphRunner gated the EAGLE capture-hidden-mode override on the prefill backend being BREAKABLE, so an EAGLE target on tc_piecewise fell through to the server hidden-state ceiling (NULL by default). Because EAGLE target prefill asks for FULL, can_replay_locally rejected that graph on every replay -- it was captured but never usable. capture_prefill_graph compensated by routing the EAGLE target to the EagerRunner outright, citing sgl-project#28386. That skip's stated premise is "a NULL or LAST graph is dead", which is a consequence of the gate above rather than an independent constraint: the same backend and the same kernels do capture and replay a prefill graph today whenever the server ceiling is already FULL (--return-hidden-states), and BCG is exempt precisely because it captures FULL. Pin the EAGLE target to FULL on every backend, which is what sgl-project#28809 set out to do before it flipped only the BCG branch and left tc_piecewise dead, and drop the now-unreachable skip. Speculative decoding (EAGLE/EAGLE3/NEXTN) keeps its prefill CUDA graph instead of silently running eager. capture_hidden_mode is read only by LogitsProcessor, which sits outside the compiled region (tc_piecewise compiles the inner model), so this adds no dynamo guard and no graph break. The EAGLE target's spec_info is None at prefill on both capture and replay, so the two stay consistent. The existing e2e coverage (test_pcg_with_speculative_decoding{,_extra}.py) asserts only gsm8k score and accept length, so it passed with the graph degraded to eager. Add unit coverage for the capture-mode matrix and for capture_prefill_graph keeping the runner, and rewrite the case that pinned the old skip. Not addressed here: under DP attention the schedule-time vote in dp_attn.py still recognises only BREAKABLE, so tc_piecewise prefill graphs do not replay there regardless of capture mode.
Problem
`PrefillCudaGraphRunner` captures with `CaptureHiddenMode.NULL` by default and only flips to `FULL` when `enable_return_hidden_states` or DFLASH spec is set. EAGLE target prefill, however, must produce `FULL` hidden states to feed the draft — so `can_run_graph` (which rejects on hidden-mode mismatch) rejected every EAGLE-target prefill batch and the captured graph was allocated but never replayed (~0.7–0.8 GB of dead memory).
Root cause (a regression from #23906)
Before #23906 `BreakableCudaGraphRunner` had the right logic — it flipped `capture_hidden_mode` to `FULL` whenever `spec_algorithm.is_eagle() and not is_draft_worker`. #23906 consolidated BCG and PCG into `PiecewiseCudaGraphRunner` and dropped that branch, so EAGLE-target PCG has been dead since then.
#28386 added a workaround skip (`self.prefill_cuda_graph_runner = self.eager_runner` for EAGLE target) to stop the dead capture from wasting memory. That treats the symptom; this PR fixes the root cause.
Fix
Net effect: EAGLE-target prefill now actually replays the captured graph instead of falling back to eager, and the model_runner-side skip is gone.
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ❌ Run #27896849378
Latest PR Test (Extra): ✅ Run #27896849299