Repository navigation
[None][refactor] BREAKING: Remove the two-model speculative decoding path and dead C++ spec-dec code - #18721
Conversation
|
/bot run --disable-fail-fast |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThis change removes two-model speculative decoding paths and obsolete public interfaces. It simplifies runtime configuration, one-model executor routing, KV-cache allocation, draft-token extraction, suffix-automaton types, examples, documentation, and validation coverage. ChangesSpeculative decoding cleanup
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant LlmArgs
participant SpeculativeDecodingMode
participant PyExecutorCreator
participant ModelEngine
LlmArgs->>SpeculativeDecodingMode: Select supported one-model mode
SpeculativeDecodingMode->>PyExecutorCreator: Provide speculative configuration
PyExecutorCreator->>ModelEngine: Use standard execution path
PyExecutorCreator->>ModelEngine: Keep draft_model_engine=None
Suggested reviewers: Merge Risk: 🔵 Low · up to This change removes two-model speculative decoding and related APIs while retaining one-model operation. The remaining dead incremental-update code, missing rejection-path coverage, and stale two-model QA invocation create bounded cleanup and validation risk before release. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 20.59% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 68 functions across 26 files. (5 skipped: 5 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
PR_Github #71511 [ run ] triggered by Bot. Commit: |
eagle3_one_model=False forces disable_overlap_scheduler=True regardless of overlap_scheduler, so overlap_scheduler=True/False produced identical server configs under two-model eagle3. Collapse the parametrization to the 3 distinct combos and drop the duplicate test list entries. Two-model eagle3 (eagle3_one_model=False) is being removed repo-wide (NVIDIA#18721), so go further and drop the eagle3_one_model axis entirely from this test, keeping only the one-model overlap_scheduler=True/False cases and updating the test list selectors to match. Signed-off-by: Xin He (SW-GPU) <[email protected]>
eagle3_one_model=False forces disable_overlap_scheduler=True regardless of overlap_scheduler, so overlap_scheduler=True/False produced identical server configs under two-model eagle3. Collapse the parametrization to the 3 distinct combos and drop the duplicate test list entries. Two-model eagle3 (eagle3_one_model=False) is being removed repo-wide (NVIDIA#18721), so go further and drop the eagle3_one_model axis entirely from this test, keeping only the one-model overlap_scheduler=True/False cases and updating the test list selectors to match. Signed-off-by: Xin He (SW-GPU) <[email protected]>
|
PR_Github #72866 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #73025 [ run ] triggered by Bot. Commit: |
|
PR_Github #73025 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #73059 [ run ] triggered by Bot. Commit: |
|
PR_Github #73059 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #73072 [ run ] triggered by Bot. Commit: |
|
PR_Github #73072 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #73115 [ run ] triggered by Bot. Commit: |
|
PR_Github #73115 [ run ] completed with state |
…ssion Two conflicts, plus one semantic follow-up: * tensorrt_llm/_torch/speculative/utils.py -- main (NVIDIA#18721) dropped the two-model speculative-decoding path: the Eagle3ResourceManager branch in get_spec_resource_manager and the whole ModelDrafter/draft_slots/ SeqSlotManager block in get_spec_drafter. Took main's side; this branch's seat_pool_or_none helper and the num_seq_slots forwarding it feeds survive unchanged. * tests/integration/test_lists/test-db/l0_a10.yml -- both sides appended an entry to the same list. Kept both. * tests/unittest/_torch/speculative/test_spec_slot_pool_sizing.py -- the "drafter's own slot pool" section tested the two-model drafter's SeqSlotManager, which no longer exists. Removed those three tests rather than have them assert against a deleted code path; the remaining coverage (including the AST guard over every get_spec_resource_manager branch) is unaffected. Co-Authored-By: Claude <[email protected]> Signed-off-by: chenfeiz0326 <[email protected]>
…usalLM main removed the two-model speculative decoding path (NVIDIA#18721), taking MTPDraftModelForCausalLM with it -- the class, its registration and its _resolve_class rewrite. Three places here cited that rewrite as the upstream precedent for a synthetic architecture name, which is now a claim about code that no longer exists. The Eagle3 rewrite is the surviving instance of the same pattern and builds EAGLE3<Arch> the same way, so it takes over as the example. The precedence note in _resolve_class drops to one rewrite for the same reason, along with the clause about MTPDecodingConfig's validator, which was explaining why a branch that is now gone was unreachable. Nothing in the targets changes: they were always on the one-model MTP path, which is what survived. Signed-off-by: Fred Wei <[email protected]>
…usalLM main removed the two-model speculative decoding path (NVIDIA#18721), taking MTPDraftModelForCausalLM with it -- the class, its registration and its _resolve_class rewrite. Three places here cited that rewrite as the upstream precedent for a synthetic architecture name, which is now a claim about code that no longer exists. The Eagle3 rewrite is the surviving instance of the same pattern and builds EAGLE3<Arch> the same way, so it takes over as the example. The precedence note in _resolve_class drops to one rewrite for the same reason, along with the clause about MTPDecodingConfig's validator, which was explaining why a branch that is now gone was unreachable. Nothing in the targets changes: they were always on the one-model MTP path, which is what survived. Signed-off-by: Fred Wei <[email protected]>
…usalLM main removed the two-model speculative decoding path (NVIDIA#18721), taking MTPDraftModelForCausalLM with it -- the class, its registration and its _resolve_class rewrite. Three places here cited that rewrite as the upstream precedent for a synthetic architecture name, which is now a claim about code that no longer exists. The Eagle3 rewrite is the surviving instance of the same pattern and builds EAGLE3<Arch> the same way, so it takes over as the example. The precedence note in _resolve_class drops to one rewrite for the same reason, along with the clause about MTPDecodingConfig's validator, which was explaining why a branch that is now gone was unreachable. Nothing in the targets changes: they were always on the one-model MTP path, which is what survived. Signed-off-by: Fred Wei <[email protected]>
Dev Engineer Review
eagle3_one_model=Falseandmtp_eagle_one_model=Falsenow raiseValueError.SpeculativeDecodingFastLogitsInfo::toTensor()and speculative-decoding accessors and bindings.AllocateKvCacheand its Python binding to removeModelConfig.Verdict: sufficient, subject to successful CI validation and downstream API updates.
QA Engineer Review
Modified or removed tests include:
TestDeepSeekV3Lite::test_bfloat16_2_model_mtp.EAGLE3_ONE_MODEL.eagle3_one_model=Falsesettings from configuration and speculative-decoding tests.Modified test-list and test metadata files include:
tests/integration/test_lists/test-db/l0_b200.yml: removed the obsolete two-model MTP test.tests/integration/test_lists/test-db/l0_h100.yml: consolidated batch-slot-limit test entries.tests/integration/test_lists/qa/llm_function_core.txt: removed obsolete two-model cases and narrowed supported configurations.tests/integration/defs/.test_durations: removed obsolete duration data and consolidated batch-slot-limit entries.The modified test identifiers remain consistent with the test definitions. The test-list changes preserve formatting and contain no duplicate or invalid entries. The changes cover the removal of two-model speculative decoding and retain one-model coverage.
Verdict: sufficient.
Description
This PR does two related things: it removes the two-model speculative decoding path, which had already been made unreachable and was marked for removal, and it clears out the dead code left on the C++ speculative-decoding side. Both are speculative-decoding cleanup, which is why they travel together.
Part 1 — Removing the two-model path (the breaking part)
Three separate one-model forcings had already made every two-model mode unreachable:
EagleDecodingConfigeagle3_one_modelback toTrue, warning that 2-model "will be removed in a future release"MTPDecodingConfigmtp_eagle_one_modelDraftTargetDecodingConfig_draft_target_one_model: bool = PrivateAttr(True), never assigned anywhereBecause all three modes were unreachable,
SpeculativeDecodingMode.has_draft_model()was a constantFalse— and that predicate is the guard on the entire separate-draft-engine build. So the whole two-model machinery behind it was dead.Removed: the
EAGLE3/MTP_EAGLE/DRAFT_TARGETenum members and their predicates (has_draft_model(),needs_kv_cache_recompute(), the threeis_*());model_drafter.pyin full (905 lines —ModelDrafter,get_draft_model_prompt); the two-model branches inspeculative/utils.py; the draft-engine construction block and forced overlap-scheduler disable inpy_executor_creator.py;_two_model_spec_dec_decoding_type()inllm_utils.pyand both KV-cache-V2 guards it fed; theneeds_kv_cache_recomputebranch incuda_graph_runner.py(whose enclosing helper became a pure passthrough and is inlined); theeagle3_two_modeltelemetry flag; and theMTP_EAGLEregister_draft_modelentry plus its_arch_indexrow.Also removed as plain dead code:
EagleDecodingConfig.greedy_samplingand.posterior_threshold(no reader anywhere — the one--eagle_posterior_thresholdgrep hit is a CLI-flow test arg for the removed TRT build path, not this pydantic field), andMTPEagleWorker.is_thop, which was written but never read (everyis_thopreader is onMTPWorker, a different class).Compatibility
eagle3_one_modelandmtp_eagle_one_modelare kept as fields, so existing configs that passTrue— including the examples and docs in this repo — keep working unchanged. PassingFalsenow raises an explicitValueErrorinstead of being silently ignored, which is the actual behavior change users will see.quickstart_advanced.pyloses its--use_one_modelflag accordingly.Part 2 — Dead C++ speculative-decoding code
The root here is the TRT-engine config parsing in
gptJsonConfig, which is unreachable end to end: the engine builder is gone from the repo (tensorrt_llm/builder.pyandcommands/build.pyno longer exist, notrtllm-buildentry point),trtllm-benchrejects--backend tensorrtat parse time becauseALL_SUPPORTED_BACKENDS = ["pytorch", "_autodeploy"]is passed toclick.Choice, andSpeculativeDecodingMode.from_arguments()has no callers.GptJsonConfigitself is kept — it still parses name/version/precision/parallelism andloraManagerTest.cppuses it; only the speculative-decoding branches are dropped.Removing those branches leaves
gptJsonConfigas the sole writer ofModelConfig::mSpeculativeDecodingModeandmSpeculativeDecodingModule, pinning the mode toNone()— the only constructor hardcodes it, the setters have no remaining callers, and nanobind exposes the field read-only (def_prop_ro). That made the dependent branches dead too.gptJsonConfig.cppnumLayersadjustment,speculative_decoding_modeparse + setter, the spec-module construction blockexplicitDraftTokensModule.hSpeculativeDecodingModule; its siblingMedusaModule/EagleModule/LookaheadModulewere already removed for the same reason and this one was missedspeculativeDecodingMode.hallBitSethelper, and the whole nanobind binding classspeculativeDecodingModule.hgetNumPackedMasks,getMaxNumPaths, 3 setters,computeNumPackedMasks, 2 members; the constructor dropsmaxNumPathsmodelConfig.hgetMaxDecodingDraftTokens/getMaxDecodingTokens, the last consumers ofisNone()allocateKvCache.cppisEagle()branches that dereference a module theTLLM_CHECKproves is null — reaching them would abort. The now-unusedmodelConfigparameter is dropped from the header, the definition and the nanobind argspeculativeDecodingConfig.cppSpeculativeDecodingFastLogitsInfo::toTensor+ the file it emptieddraftTokenTreeKernels.{h,cu}extract_real_draft_tokens_op, whose only user was a smoke test asserting the op existssuffixAutomaton/struct SABuffer(nothing declares one; the automaton usesSADynamicBuffer) and theBatchIndex/RequestID/NumTokenstypedefsPublic API / ABI removal — migration boundary
Everything else in this PR is internal, but five public headers under
cpp/include/lose symbols. The in-repo dependency-closure build cannot validate consumers outside this repository, so those removals are stated explicitly here rather than resting on the reachability argument.Removed exported symbols
executor/executor.hSpeculativeDecodingFastLogitsInfo::toTensor() construntime/speculativeDecodingMode.hupdatesPositionIds,requiresAttentionMask,predictsDraftTokens,needsKVCacheRewind,variableDraftLength,hasDraftLogits,needsDecoderPrologueconstexprinline predicatesruntime/speculativeDecodingModule.hgetNumPackedMasks,getMaxNumPaths,setMaxDraftTokens,setMaxDraftPathLen,setMaxNumPathsruntime/modelConfig.hModelConfig::getMaxDecodingDraftTokens,ModelConfig::getMaxDecodingTokensbatch_manager/allocateKvCache.hAllocateKvCache::operator()loses itsmodelConfigparameterThe only one that is an out-of-line definition — i.e. an actual entry in the shared library's dynamic symbol table — is:
An old binary that calls it against a new
libtensorrt_llmfails at link/load time withundefined symbol. That is a loud failure, not a silent one. The rest areinline/constexprand are emitted into each consumer's own object files, so they break at compile time (no member named ...), not at load time.Layout changes (the part that can fail silently)
sizeofbefore → afterSpeculativeDecodingFastLogitsInfodraftRequestId0→0,draftParticipantId8→8 — unchangedSpeculativeDecodingModulemMaxNumPathsandmMaxNumPackedMasksare removed; surviving members keep their offsets (8, 12)So for
SpeculativeDecodingFastLogitsInfo— the type reachable fromexecutor.h, the public executor entry point — the data layout is byte-for-byte identical and only a function symbol disappears.SpeculativeDecodingModuledoes shrink, but it lives inruntime/and is not reachable fromexecutor.h(which does not includemodelConfig.h); it was only ever constructed by the TRT-engine parsing path this PR removes, so no object of the old size can be produced by the new library.Migration
There is no replacement for any of these.
toTensor()served the fast-logits path of the TRT-engine flow, which no longer exists; the predicates and accessors described state that is now permanently unset. Callers should delete the call sites. If an external consumer turns out to depend ontoTensor(), please say so on this PR — it is the one symbol here worth reconsidering.Exported-symbol diff (run at this head)
libtensorrt_llm.sowas built twice with identical CMake flags — once from the merge-basee8654268e9and once from this branch — and their dynamic symbol tables compared withnm -D --defined-only. Result: 35 symbols removed, 2 added, out of ~150,500. Every one is attributable to this PR:SpeculativeDecodingFastLogitsInfo::toTensor()AllocateKvCache::operator()modelConfigparameter was droppedruntime::SpeculativeDecodingModuleshared_ptrcontrol-block instantiationsruntime::ExplicitDraftTokensModulenlohmann::json::at<char const(&)[17]>/[25]gptJsonConfigfield lookupsLogger::log<char[308]>→<char[265]>This corrected one claim made earlier in this PR. I had described
SpeculativeDecodingModuleas merely shrinking from 24 to 16 bytes. In the built library it does not shrink — it disappears from the dynamic symbol table entirely, vtable and RTTI included. The class is still declared in the header, but after this PR removes thegptJsonConfigparsing path nothing constructs it, so the compiler emits no vtable/typeinfo for it and the linker drops it. Practically this makes the layout question moot: the new library cannot produce an object of either size. But it is a larger ABI delta than "one member function", and downstream code that constructs aSpeculativeDecodingModuledirectly would fail to link.No unexpected symbols were removed — nothing outside the speculative-decoding surface changed, which is the property the closure build could not establish on its own.
Notes for reviewers
speculativeDecodingModule.hno longer needscudaUtils.h. Dropping that heavy header exposed two pre-existing include-what-you-use gaps that had been relying on it transitively, both fixed here:modelConfig.husesTLLM_CHECK_WITH_INFO/TLLM_LOG_DEBUGwithout includingassert.horlogger.h, andruntimeUtils.cppusesTLLM_CUDA_CHECK/std::ifstreamwithout includingcudaUtils.hor<fstream>.kernels/CMakeLists.txtusesfile(GLOB_RECURSE ... *.cu), so deleting the kernel file pair needs no CMake change.executor::DecodingMode::isMedusa/isEagle/isExplicitDraftTokens(a different class fromruntime::SpeculativeDecodingMode) and the pure-PythonSpeculativeDecodingModeinmodels/modeling_utils.py.kernels/speculativeDecoding/(dynamicTree,kvCacheUpdate,mtp) were scanned and are clean — nothing removed from them. Two things there look dead but are not:updateLinearKVCacheDraftTokenLocationis never reached from production code (kv_cache_manager_v2.pyhardcodesuse_paged_kv_cache=True) buttest_linear_kvcache_updatepassesFalseand checks it against a ground-truth reimplementation; and the three parameters the 2D variant always receives asnullptrare shared with the 1D variant, which passes real pointers.suffixAutomaton/, only whole-entity dead code was removed. The individually-unused members ofSADynamicBuffer/SAOptional/SAFlatHashMap/NamedTypeare left alone — those files are adapted from Baseten'ssa_specand the members mirror the upstreamstd::optional/ STL contract.ModelConfig's speculative-decoding members and their accessors are now written by nobody and are dead, but are left in place to keep this PR's blast radius bounded; they are a natural follow-up.Test Coverage
test_bfloat16_2_model_mtpspecifically covered the removed two-model path and is deleted, along with itsl0_b200.ymland.test_durationsentries. Every other test only needed the two-model flag dropped or the mode swapped for its one-model equivalent — their subjects (KV cache reuse, tree verification, long prompts, cold-page compression) are unaffected.test_custom_ops.pydrops thetrtllm::extract_real_draft_tokens_opentry from the op-existence list.Build verification (devel container, CUDA 13.2): the 110 translation units in the dependency closure of the edited C++ headers all compile, along with the nanobind and executor targets. The closure was computed with the preprocessor (
-M -MG) rather than by grep, which is what caught the two include-what-you-use gaps above. For the suffix-automaton headers, which are included by relative path, correctness was confirmed by injecting a deliberate syntax error and observing the dependent TUs fail. The Python side ispy_compile-clean andruff-clean for undefined names; the devel image lackstransformers, so the unit tests above have not been run locally and CI is their first execution.PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.