Skip to content

[Feat] spec: Let out-of-tree platforms provide their own speculative worker - #45144

Merged
alexnails merged 1 commit into
mainfrom
yihao/oot-spec-worker
Oct 24, 2026
Merged

alexnails merged 1 commit into
mainfrom
yihao/oot-spec-worker

Conversation

@AgainstEntropy

@AgainstEntropy AgainstEntropy commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Out-of-tree (OOT) platforms cannot run EAGLE-family speculative decoding today, including NEXTN/MTP drafts:

  • The built-in EAGLEWorkerV2 keeps its bookkeeping in device tensors with data-dependent shapes. Platforms that compile a graph per shape cannot run it efficiently, so they ship their own speculative worker (for example one that keeps the bookkeeping on the host) and today have to monkeypatch SpeculativeAlgorithm.create_worker to install it.
  • On an OOT device the built-in path is broken without saying so: verify_tree_greedy_func (kernels/ops/speculative/spec_tree.py) has no branch for it and returns its inputs unfilled, and build_tree_kernel_efficient_func calls a kernel that is only imported on CUDA/HIP/MUSA builds.

This PR is the first step of generic OOT speculative-decoding support. It adds the platform worker factory and makes the unsupported built-in path fail loudly. Follow-ups will add the seams the built-in worker needs on an OOT device (draft attention backend registry, draft graph runners, spec kernels on BaseFusedOp with native fallbacks).

Modifications

  • SRTPlatform.get_speculative_worker_cls(algorithm) (default None). On an OOT platform create_worker returns this class for any algorithm; None keeps the built-in worker. The class is constructed with the built-in worker's keyword arguments and must reject flags it cannot serve. SpeculativeAlgorithm.get_platform_worker_cls() is the single lookup.
  • EAGLE / EAGLE3 / NEXTN / STANDALONE on an OOT platform now require supports_speculative_algorithm(algorithm) (NEXTN is asked as "EAGLE"), mirroring the existing DFLASH gate, with an actionable error.
  • adaptive_unsupported_reason() reports a platform worker, so --speculative-adaptive falls back to static parameters with the existing warning instead of being silently ignored (AdaptiveController lives only in EAGLEWorkerV2).
  • build_tree_kernel_efficient_func and verify_tree_greedy_func in kernels/ops/speculative/spec_tree.py raise NotImplementedError via reject_out_of_tree_path on an OOT device that has no tree kernel. In-tree devices and OOT platforms on a CUDA/HIP/MUSA torch build are unchanged.
  • Docs: the hook is added to the plugin guide.

Behavior change for OOT platforms: EAGLE-family algorithms now need supports_speculative_algorithm(...) to return True (default False, same as DFLASH). Built-in platforms are unaffected.

Accuracy Tests

No change on built-in platforms: every new branch is guarded by is_out_of_tree() or sits on a path that previously raised or computed nothing.

Tests

test/registered/unit/spec/test_oot_eagle_hooks.py (CPU, base-a-test-cpu):

  • worker selection: the platform class wins on OOT, the built-in worker when the platform declines, in-tree platforms never consult the hook;
  • algorithm gate: an unsupported OOT platform is rejected, built-in platforms are not gated;
  • adaptive falls back with a platform worker and stays available with the built-in one;
  • tree construction and greedy verification raise on an OOT device without a tree kernel (both fail on the pre-fix code), and the in-tree fall-through is unchanged.
pytest test/registered/unit/spec/ test/registered/unit/platforms/ \
       test/registered/unit/test_split_attention_backend_decisions.py
# 395 passed, 2 skipped

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 #40060523962
Latest PR Test (Extra): ❌ Run #40060523897
Latest PR Test (AMD ROCm 10): ❌ Run #40060523931

@mintlify

mintlify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
sglang-doc 🟢 Ready View Preview Oct 24, 2026, 4:03 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@github-actions github-actions Bot added documentation Improvements or additions to documentation speculative-decoding labels Oct 19, 2026
@alexnails alexnails added run-ci CI: run the baseline test suite on this PR bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) labels Oct 23, 2026
@AgainstEntropy AgainstEntropy removed the run-ci CI: run the baseline test suite on this PR label Oct 24, 2026
…worker

Out-of-tree platforms cannot run EAGLE-family speculative decoding
(including NEXTN/MTP) today. The built-in EAGLEWorkerV2 keeps its
bookkeeping in device tensors with data-dependent shapes and dispatches
tree kernels by torch build, so platforms that compile per shape ship
their own worker and have to monkeypatch create_worker to install it; and
on an OOT device the built-in path silently skips greedy tree
verification.

- SRTPlatform.get_speculative_worker_cls(algorithm): consulted by
  create_worker for every algorithm on an OOT platform; None keeps the
  built-in worker.
- EAGLE/EAGLE3/NEXTN/STANDALONE on an OOT platform require
  supports_speculative_algorithm(algorithm), mirroring the DFLASH gate.
- --speculative-adaptive falls back to static parameters when a platform
  worker replaces the built-in one, since only EAGLEWorkerV2 implements it.
- EAGLE tree construction and greedy verification raise on an OOT device
  with no tree kernel instead of failing with NameError or computing
  nothing.
- Document the hook in the plugin guide.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexnails
alexnails force-pushed the yihao/oot-spec-worker branch from 558c779 to 78cbea0 Compare October 24, 2026 03:59
@alexnails
alexnails merged commit af3f9e4 into main Oct 24, 2026
111 of 127 checks passed
@alexnails
alexnails deleted the yihao/oot-spec-worker branch October 24, 2026 04:25

This branch was successfully deployed

1 active deployment
staging - docs — 78cbea03 Deployed Oct 24, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) documentation Improvements or additions to documentation jit-kernel speculative-decoding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants