Repository navigation
refactor(runner): add EagerRunner, own the eager path, polymorphic dispatch - #28386
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 429950e36d
ℹ️ 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".
429950e to
59c22c4
Compare
e0db52c to
ba709b2
Compare
57ce299 to
b42ee47
Compare
ba709b2 to
8ba9b60
Compare
b42ee47 to
00c3a3c
Compare
8ba9b60 to
9724829
Compare
00c3a3c to
440c11b
Compare
9724829 to
20d1a12
Compare
440c11b to
94f722d
Compare
20d1a12 to
7bf5308
Compare
6dd9993 to
c62f618
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c62f618024
ℹ️ 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".
c62f618 to
efc7966
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efc7966ef0
ℹ️ 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".
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]>
… 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]>
…gl-project#30889) sgl-project#30889 auto-upgrades the prefill CUDA-graph backend BREAKABLE -> TC_PIECEWISE for multimodal-piecewise-allowlisted models (e.g. Kimi K2.5/K2.6). For a speculative config on an FP4 / TRTLLM-MoE target (nvidia/Kimi-K2.6-NVFP4 DFlash, B200) this silently forced tc_piecewise, whose captured prefill graph corrupts the target FP4/MoE decode-graph replay that spec verify runs on (sgl-project#28386) -> CUDA illegal memory access during generation (nightly test_kimi_k26_nvfp4_dflash.py, regressed 07-13). Verified on 8xB200 that NO captured prefill graph (tc_piecewise OR breakable) avoids the corruption -- it is a general captured-prefill-vs-FP4/MoE issue, so spec targets must run eager prefill. Exclude speculative configs from the silent upgrade (speculative_algorithm is None), so they keep their default prefill backend (BREAKABLE -> auto-disabled for MLA -> eager, the pre-sgl-project#30889 behavior). Explicitly pinned spec + tc_piecewise configs (the dense DFlash+PCG test) lock the backend and short-circuit before this, unaffected. Co-Authored-By: Claude Opus 4.8 <[email protected]>
A tc_piecewise/breakable prefill capture session perturbs persistent state that a decode/verify graph captured afterwards bakes a dependence on; on trtllm_mla spec-decode targets the verify graph is born corrupted and hits an async illegal memory access at replay (sgl-project#28386; Kimi-K2.6-NVFP4 DFlash nightly red since sgl-project#30889). Verified on 8xB200 with the exact nightly config: order swap alone fixes the crash with tc_piecewise prefill graphs still capturing and replaying (two independent GSM8K passes), while every alternative explanation was falsified by single-variable A/B (MoE runner swap, torch.compile-free BCG, torch graph-pool isolation both channels, PDL off, autotune off, flashinfer nightly, private workspaces, fp8-vs-bf16 KV, custom allreduce off). Eager verify on the same config is immune and replay-prep inputs are provably clean at fault time, isolating the corruption to capture-environment ordering. Co-Authored-By: Claude Fable 5 <[email protected]>
…efill fallback When prefill CUDA graphs (tc_piecewise or breakable) are captured before the decode/verify graphs, the last prefill capture leaves the backend's forward_prefill_metadata with fallback_to_flashinfer_impl=True (the piecewise capture forces the flashinfer fallback; init_forward_metadata sets it on the instance). The decode runner's TARGET_VERIFY capture then enters forward_extend, whose first check consults that stale flag and silently records the flashinfer-wrapper attention into the captured graph. Replay-prep feeds the graph trtllm-gen-style metadata, so the replayed verify graph is born corrupted and hits an asynchronous illegal memory access on the first generation batch (sgl-project#28386, and the Kimi-K2.6 DFlash nightly IMA after sgl-project#30889). init_forward_metadata already clears the stale metadata for verify / draft-extend on the eager path (which is why eager verify was immune); the CUDA-graph metadata path never got the same clear. Fix both sides: - init_forward_metadata_out_graph(in_capture=True): clear forward_prefill_metadata before building decode/verify capture metadata, mirroring the eager path. - forward_extend: never take the prefill fallback short-circuit for target-verify / draft-extend modes, matching the mode guards used by the metadata paths. No capture-order change.
…spatch (sgl-project#28386) Co-authored-by: Claude Opus 4.8 (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.
Motivation
The eager forward path lived inline in
ModelRunner. Extract it into a dedicated runner so the cuda-graph runners stay purely cuda-graph, and back it with one fixed-size static input buffer (allocated once at init) instead of grow-on-demand registries.Modifications
runner/eager_runner.py::EagerRunner(BaseRunner):__init__allocates one static input buffer viabuild_eager_registry, sized once at(max_running_requests, prefill token ceiling)— no grow/realloc. The decode slot set is a superset of eager prefill's needs, so a single registry serves both decode and prefill (a decode batch is the[:num_tokens]prefix).load_batchcopies the live batch into that buffer, sliced to the batch.executeinits attention metadata and runsmodel.forwardlive, mode-dispatched (decode / extend / idle).can_run_graph()returnsFalse(the dispatch gate).cuda_graph_buffer_registry.py::build_eager_registry— the decode slot set sized at the prefill ceiling,share_pool=Trueso same-name / same-size slots coalesce through the process-wide input pool (the eager buffer is allocated before the cuda-graph runners, so it is canonical and they coalesce onto it).ModelRunnerbuildseager_runnerunconditionally — it serves both the cuda-graph-disabled case and the fallback when a cuda-graph runner can't run a batch (dispatch viaisinstance(..., EagerRunner));forward_decode/forward_extend/forward_idle/_eager_fb_vieware removed and routed through it._forward_rawapplies the DP/MLP-sync + attn-tp padding (_prepare_eager_forward_batch) once, before the split-prefill / prefill-cuda-graph / eager paths — only the decode cuda-graph path pre-pads its own static buffers and returns earlier. The cuda-graph runners gain no eager flag or backend.Accuracy Tests
N/A — behavior-preserving refactor (no change to model outputs).
Speed Tests and Profiling
N/A — no inference-speed impact.
Checklist
test/registered/attention/unittests/dense).🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ❌ Run #27816609952
Latest PR Test (Extra): ❌ Run #27816609827