Skip to content

refactor(runner): rename runner replay/load/can_run for the shared surface - #28384

Merged
ch-wan merged 1 commit into
mainfrom
cheng/refactor/runner-lifecycle-rename
Jun 19, 2026
Merged

ch-wan merged 1 commit into
mainfrom
cheng/refactor/runner-lifecycle-rename

Conversation

@ch-wan

@ch-wan ch-wan commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Three runner methods are dispatched polymorphically across the cuda-graph runners (and a forthcoming eager runner). Give them a shared, intent-revealing surface; leave the cuda-graph-only methods named as they are.

Modifications

  • Rename, across Base/Decode/Prefill CudaGraphRunner and the speculative / NPU / CPU graph runners:
    • replay()execute() (per-iter run)
    • replay_prepare()load_batch() (per-iter fill + metadata)
    • can_run()can_run_graph() (dispatch gate)
  • Kept at their names (cuda-graph-only): runner capture() / capture_prepare() / capture_one_shape(); ExecutionBackend capture_session() / capture_one() / can_run() / replay_session() / replay().
  • Preserved (not part of this surface): torch.cuda.CUDAGraph.replay(), the deepep / tbo / ViT runner hierarchies, and the can_run_cuda_graph result field.

Pure mechanical rename, behavior-identical.

Mechanical Move

Transform script: https://gist.github.com/ch-wan/c3e9f3be03f0c5451920973963a64f9e

The script renames only the three polymorphic runner-lifecycle methods (replayexecute, replay_prepareload_batch, can_runcan_run_graph) and their call sites, leaving every must-preserve token intact (self.backend.replay/.replay_session/.can_run, tbo_plugin.replay_prepare, deepep_adapter.replay, the _replay_graph helpers, prose uses of "replay", and the two docstring can_run mentions the PR kept). Line reflows from the longer identifiers are produced by pre-commit (black), which the verification scaffold runs. Verified to reproduce a40924b byte-for-byte.

One-click verification

python3 <(curl -sL https://gist.githubusercontent.com/ch-wan/c3e9f3be03f0c5451920973963a64f9e/raw/transform_runner_lifecycle_rename.py)

Accuracy Tests

N/A — behavior-preserving refactor (no change to model outputs).

Speed Tests and Profiling

N/A — no inference-speed impact.

Checklist

  • Format your code with pre-commit.
  • Behavior-preserving; covered by the existing runner-mode attention unit tests (test/registered/attention/unittests/dense).
  • Follow the SGLang code style guidance.

Builds on #28383.

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ❌ Run #27815358410
Latest PR Test (Extra): ❌ Run #27815358225

@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!

@ch-wan
ch-wan force-pushed the cheng/refactor/forward-unify-dp branch from 75a5354 to c30b541 Compare June 16, 2026 07:03
@ch-wan
ch-wan force-pushed the cheng/refactor/runner-lifecycle-rename branch from 596eea1 to ef97913 Compare June 16, 2026 07:03
@ch-wan
ch-wan force-pushed the cheng/refactor/forward-unify-dp branch from c30b541 to 8e80bfe Compare June 16, 2026 20:47
@ch-wan
ch-wan force-pushed the cheng/refactor/runner-lifecycle-rename branch from ef97913 to b2ef358 Compare June 16, 2026 20:47
@ch-wan
ch-wan force-pushed the cheng/refactor/forward-unify-dp branch from 8e80bfe to 553893b Compare June 16, 2026 20:49
@ch-wan
ch-wan force-pushed the cheng/refactor/runner-lifecycle-rename branch from b2ef358 to 17f9845 Compare June 16, 2026 20:49
@ch-wan
ch-wan force-pushed the cheng/refactor/forward-unify-dp branch from 553893b to b104183 Compare June 16, 2026 20:59
@ch-wan
ch-wan force-pushed the cheng/refactor/runner-lifecycle-rename branch from 17f9845 to 1b867c6 Compare June 16, 2026 20:59
@ch-wan
ch-wan force-pushed the cheng/refactor/forward-unify-dp branch from b104183 to d59fbb6 Compare June 16, 2026 21:24
@ch-wan
ch-wan force-pushed the cheng/refactor/runner-lifecycle-rename branch from 1b867c6 to a40924b Compare June 16, 2026 21:24
@ch-wan ch-wan added the ready-to-merge The PR is ready to merge after the CI is green. label Jun 17, 2026
@ch-wan

ch-wan commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_deepseek_v3_fp4_mtp_small.py

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Results for /rerun-test test_deepseek_v3_fp4_mtp_small.py:

🚀 4-gpu-b200 (1 test): ✅ View workflow run

cd test/ && python3 registered/spec/eagle/test_deepseek_v3_fp4_mtp_small.py

@ch-wan
ch-wan force-pushed the cheng/refactor/forward-unify-dp branch from d59fbb6 to db9191d Compare June 18, 2026 10:23
@ch-wan
ch-wan force-pushed the cheng/refactor/runner-lifecycle-rename branch from a40924b to 517404e Compare June 18, 2026 10:23
Base automatically changed from cheng/refactor/forward-unify-dp to main June 18, 2026 20:41
…rface

Pure mechanical rename (behavior-identical). Only the three runner methods
that become the shared BaseRunner abstract surface — dispatched
polymorphically across the cuda-graph runners and the upcoming EagerRunner —
are renamed; everything else keeps its main name:

  Runner (Base/Decode/Prefill CudaGraphRunner / spec / NPU / CPUGraphRunner):
    replay()          -> execute()        (per-iter run; shared)
    replay_prepare()  -> load_batch()     (per-iter fill + metadata; shared)
    can_run()         -> can_run_graph()  (dispatch gate; shared)

Kept at their main names (cuda-graph-only — the graph runner and the
ExecutionBackend are purely cuda-graph, so a generic rename would be
gratuitous):

  Runner:           capture(), capture_prepare(), capture_one_shape()
  ExecutionBackend: capture_session(), capture_one(), can_run(),
                    replay_session(), replay()

Preserved (not our ABC): torch.cuda.CUDAGraph.replay(),
deepep_adapter.replay()/.capture(), tbo_plugin.replay_prepare(),
backend.replay_with_input_update (NPU), the separate ViT graph-runner
hierarchy, and the GenerationBatchResult.can_run_cuda_graph field.
CPUGraphRunner/NPUGraphRunner renamed in lockstep because
ModelRunner.{decode,prefill}_cuda_graph_runner is polymorphic over them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ch-wan
ch-wan force-pushed the cheng/refactor/runner-lifecycle-rename branch from 517404e to 64fcd74 Compare June 19, 2026 08:43
@ch-wan
ch-wan merged commit 1c6331c into main Jun 19, 2026
108 of 125 checks passed
@ch-wan
ch-wan deleted the cheng/refactor/runner-lifecycle-rename branch June 19, 2026 08:45
kpham-sgl added a commit that referenced this pull request Jun 22, 2026
Resolve conflicts from spec v2 refactor:
- frozen_kv_mtp_worker.py: removed (replaced by frozen_kv_mtp_worker_v2.py
  in #27607); ported trtllm_mha draft-attn-backend branch into the v2 worker.
- frozen_kv_mtp_cuda_graph_runner.py: adopt shared DecodeCudaGraphRunner
  surface (_replay_graph + _make_graph_key) from #28081 / #28384.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
jakki-amd pushed a commit to jakki-amd/sglang that referenced this pull request Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

npu ready-to-merge The PR is ready to merge after the CI is green. speculative-decoding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant