Repository navigation
[Feat] spec: Let out-of-tree platforms provide their own speculative worker - #45144
Merged
Merged
Conversation
AgainstEntropy
requested review from
JustinTong0323,
Qiaolin-Yu,
Ying1123,
alexnails,
alphabetc1,
hnyls2002,
merrymercy,
sogalin,
whybeyoung,
wisclmy0611 and
zijiexia
as code owners
October 19, 2026 09:24
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
AgainstEntropy
force-pushed
the
yihao/oot-spec-worker
branch
from
October 22, 2026 21:08
a96a579 to
558c779
Compare
AgainstEntropy
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
celve and
yuan-luo
as code owners
October 22, 2026 21:08
4 of 5 tasks
…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
force-pushed
the
yihao/oot-spec-worker
branch
from
October 24, 2026 03:59
558c779 to
78cbea0
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Out-of-tree (OOT) platforms cannot run EAGLE-family speculative decoding today, including NEXTN/MTP drafts:
EAGLEWorkerV2keeps 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 monkeypatchSpeculativeAlgorithm.create_workerto install it.verify_tree_greedy_func(kernels/ops/speculative/spec_tree.py) has no branch for it and returns its inputs unfilled, andbuild_tree_kernel_efficient_funccalls 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
BaseFusedOpwith native fallbacks).Modifications
SRTPlatform.get_speculative_worker_cls(algorithm)(defaultNone). On an OOT platformcreate_workerreturns this class for any algorithm;Nonekeeps 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.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-adaptivefalls back to static parameters with the existing warning instead of being silently ignored (AdaptiveControllerlives only inEAGLEWorkerV2).build_tree_kernel_efficient_funcandverify_tree_greedy_funcinkernels/ops/speculative/spec_tree.pyraiseNotImplementedErrorviareject_out_of_tree_pathon an OOT device that has no tree kernel. In-tree devices and OOT platforms on a CUDA/HIP/MUSA torch build are unchanged.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):Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #40060523962
Latest PR Test (Extra): ❌ Run #40060523897
Latest PR Test (AMD ROCm 10): ❌ Run #40060523931