Skip to content

[Spec] Allow speculative workers to stage prefill shared reads - #38554

Merged
Qiaolin-Yu merged 2 commits into
sgl-project:mainfrom
paulzhang-tm:codex/spec-prefill-shared-read-stager
Sep 14, 2026
Merged

Qiaolin-Yu merged 2 commits into
sgl-project:mainfrom
paulzhang-tm:codex/spec-prefill-shared-read-stager

Conversation

@paulzhang-tm

@paulzhang-tm paulzhang-tm commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Speculative workers with later draft-prefill readers cannot publish the early prefill read-done event, even when those reads can be staged before target replay. Add an optional callback so workers can opt in after staging their shared reads.

Modifications

  • Add ModelRunner.prefill_shared_read_stager: Optional[Callable[[ForwardBatch], bool]], defaulting to None. The speculative worker installs the callback for its forward call and returns True only after staging its shared reads before event recording.
  • Invoke the callback after the prefill flag, mode, and backend checks. An absent or unsuccessful callback retains the existing fallback; non-speculative and DFLASH/DSPARK behavior is preserved.

Accuracy Tests

python -m pytest -q test/registered/unit/model_executor/runner/test_prefill_shared_read_done.py — 12 passed. Covers staging before event creation, unsuccessful/missing staging, existing prefill gates, and DFLASH/DSPARK compatibility.

Upstream pre-commit hooks passed for all three changed files.

Speed Tests and Profiling

No benchmark: this PR adds the hook without enabling it in an upstream worker. Model-specific staging and performance validation remain with the worker implementation.

-Robot


CI States

Latest PR Test (Base): ✅ Run #34534808195
Latest PR Test (Extra): ❌ Run #34534808017
Latest PR Test (AMD ROCm 10): ❌ Run #34534808235

@Qiaolin-Yu Qiaolin-Yu self-assigned this Sep 10, 2026
@Qiaolin-Yu Qiaolin-Yu added run-ci CI: run the baseline test suite on this PR bypass-fastfail labels Sep 10, 2026
@Qiaolin-Yu
Qiaolin-Yu merged commit 9128d57 into sgl-project:main Sep 14, 2026
295 of 322 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants