Skip to content

[TRTLLM-14388][refactor] Remove 2 model spec dec drafting loops - #17562

Merged
mikeiovine merged 7 commits into
NVIDIA:mainfrom
mikeiovine:remove-drafting-loop
Aug 25, 2026
Merged

[TRTLLM-14388][refactor] Remove 2 model spec dec drafting loops#17562
mikeiovine merged 7 commits into
NVIDIA:mainfrom
mikeiovine:remove-drafting-loop

Conversation

@mikeiovine

@mikeiovine mikeiovine commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Description

2 model based spec dec is now disabled after #17366.

This PR removes some dead code. Drafting loops were a component used by 2 model eagle/MTP only. No usable codepath is affected by this change.

Test Coverage

Existing tests.

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-compatible or api-breaking. For api-breaking, include BREAKING in 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.

Dev Engineer Review

  • Removed disabled two-model Eagle/MTP drafting-loop and chain-drafter code.
  • Updated related APIs, callers, cache sizing, metadata handling, and configuration consistently.
  • Updated Ruff and pre-commit lists for the deleted module.
  • No unintended code or configuration changes identified.
  • CI helper jobs passed, but L0_MergeRequest_PR pipelines failed and require follow-up.

QA Engineer Review

Modified or removed test coverage:

  • Removed test_draft_token_static_tree_prepare_for_generation.
  • Removed test_draft_token_static_tree_sampling.
  • Modified test_llama_eagle3.
  • Removed test_eagle3_cdl_sampling.
  • Removed num_extra_decoding_steps coverage from tests/unittest/llmapi/test_llm_args.py.
  • Updated speculative-decoding calls in tests/unittest/_torch/modeling/test_modeling_llama.py.
  • Updated the engine fixture in tests/unittest/_torch/executor/test_pytorch_model_engine.py.

test_llama_eagle3 remains covered by tests/integration/test_lists/test-db/l0_h100.yml and l0_b200.yml. No matching test-list entries were identified for the other modified or removed unit tests.

Verdict: needs follow-up.

@mikeiovine mikeiovine added the api-compatible Accepted LLM API contract change that is backwards-compatible label Aug 12, 2026
@mikeiovine
mikeiovine marked this pull request as ready for review August 12, 2026 16:33
@mikeiovine
mikeiovine requested review from a team as code owners August 12, 2026 16:33
@mikeiovine

Copy link
Copy Markdown
Collaborator Author

/bot run

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Changes

The PR removes static drafting-loop and chain-drafter execution paths. It updates speculative-decoding APIs, adds occurrence-penalty handling, changes graph and cache sizing, centralizes request-state resets, and updates related tests and configuration.

Speculative decoding simplification

Layer / File(s) Summary
Dynamic drafting execution
tensorrt_llm/_torch/speculative/*, tensorrt_llm/_torch/pyexecutor/py_executor_creator.py, tensorrt_llm/_torch/pyexecutor/sampler/sampler.py
Draft preparation, sampling, output processing, and scheduling now use the dynamic path. Chain-drafter and drafting-loop wrapper integration were removed.
Penalty and model configuration contracts
tensorrt_llm/_torch/speculative/interface.py, tensorrt_llm/llmapi/llm_args.py
One-model speculative decoding supports occurrence penalties. MTP checkpoint state now distinguishes replacement heads and external draft models.
Engine graph and warmup sizing
tensorrt_llm/_torch/pyexecutor/model_engine.py
Model initialization, CUDA graph capture, and warmup sizing no longer use wrapped-model state or num_extra_decoding_steps.
Metadata, cache, and request-state updates
tensorrt_llm/_torch/attention_backend/*, tensorrt_llm/_torch/pyexecutor/*cache_manager.py, tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py, tensorrt_llm/_torch/pyexecutor/llm_request.py
Speculative metadata and dummy-request APIs drop removed parameters. Host-tier quota synchronization and fallback handling are centralized. Recompute resets now reinitialize request execution state.
Validation and generated configuration
.pre-commit-config.yaml, legacy-files.txt, pyproject.toml, ruff-legacy.toml, tests/unittest/...
References to removed speculative-decoding files and obsolete options were removed from configuration and tests.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: 🟠 High · up to 8b312

The current head removes obsolete drafting-loop code, but adjacent speculative-decoding and replay changes still have unresolved correctness issues: requested penalties can be skipped, and prefill replay can duplicate returned context logits; required configuration metadata is also incomplete. These can change generated results or returned outputs, so the PR is not merge-ready until the correctness and metadata issues are addressed or explicitly accepted.

Sequence Diagram(s)

sequenceDiagram
  participant PyExecutor
  participant PyTorchModelEngine
  participant ModelDrafter
  participant DraftModel
  participant SpecMetadata
  participant Sampler
  PyExecutor->>PyTorchModelEngine: initialize target and draft engines
  PyExecutor->>ModelDrafter: prepare dynamic draft requests
  ModelDrafter->>DraftModel: run dynamic draft passes
  DraftModel->>ModelDrafter: return draft outputs and d2t
  ModelDrafter->>Sampler: generate draft probabilities
  SpecMetadata->>Sampler: apply occurrence penalties
  PyTorchModelEngine->>PyExecutor: capture graphs and allocate warmup requests
Loading

Possibly related PRs

Suggested reviewers: tburt-nv

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the ticket, refactor type, and removal of two-model speculative-decoding drafting loops.
Description check ✅ Passed The description explains the reason and scope of the cleanup, identifies existing test coverage, and includes the required checklist.
Docstring Coverage ✅ Passed Docstring coverage is 84.21% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
tensorrt_llm/_torch/pyexecutor/py_executor_creator.py (1)

626-631: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the now-unreachable overlap-scheduler warning.

Lines 626-631 set llm_args.disable_overlap_scheduler = True for every value of has_draft_model_engine that is true. The later block at lines 650-653 requires has_draft_model_engine and not llm_args.disable_overlap_scheduler, so it can never run. Delete it to avoid a misleading log path.

♻️ Proposed removal of the dead warning block
-    if has_draft_model_engine and not llm_args.disable_overlap_scheduler:
-        logger.warning(
-            "Overlap scheduler is enabled for two-model speculative decoding. Rejection sampling will fallback to greedy sampling."
-        )
-
     max_seq_len = model_engine_max_seq_len

Also applies to: 650-653

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/_torch/pyexecutor/py_executor_creator.py` around lines 626 -
631, Remove the has_draft_model_engine block that logs the overlap-scheduler
warning and sets llm_args.disable_overlap_scheduler in the surrounding
executor-creation flow. Also remove the now-unreachable later branch guarded by
has_draft_model_engine and not llm_args.disable_overlap_scheduler, while
preserving all other scheduler logic.
tests/unittest/_torch/speculative/test_eagle3.py (2)

477-496: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prune the parameterization rows that always skip.

Line 504 skips unconditionally when use_one_model is False. Most rows in this list set the fifth value to False, so those runs only ever report SKIPPED. That hides the real covered matrix and costs collection time on every CI run. Since this pull request removes the two-model path, drop the use_one_model column and keep only the one-model rows.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/speculative/test_eagle3.py` around lines 477 - 496,
Update the parameterization list for the speculative model test by removing the
obsolete use_one_model column and deleting rows that represent the removed
two-model path. Retain only one-model cases, adjust each remaining row to the
new parameter shape, and preserve the mocked HuggingFace auto-download case.

504-505: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer a module-level or collection-time skip over a body skip.

The body skip runs after fixtures and after torch.cuda access in later lines is set up. If the two-model path stays deprecated, express the restriction in the parameterization instead, so the skipped cases never reach the test body.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/speculative/test_eagle3.py` around lines 504 - 505,
Move the deprecation skip for the two-model Eagle3 cases out of the test body
and into the test parameterization or collection-time configuration. Update the
parameterization associated with use_one_model so deprecated two-model cases are
marked skipped before fixtures and torch.cuda setup run, then remove the
body-level pytest.skip.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tensorrt_llm/_torch/attention_backend/trtllm.py`:
- Around line 1194-1210: Update the static-tree branch in update_spec_dec_param
to handle spec_metadata.is_draft_model before the target-only assertion. Add the
explicit draft-model metadata path required for draft forwards, then retain the
existing target-model spec_tree_manager updates and assertion for non-draft
metadata.

In `@tensorrt_llm/_torch/pyexecutor/model_engine.py`:
- Around line 1971-1973: Update the is_draft_model branch to derive draft_len
from the runtime draft width used by ModelDrafter, rather than
self.max_total_draft_tokens. Preserve the existing cuda_graph_batch_sizes
mapping while ensuring draft requests without py_draft_tokens produce the
zero-width graph key required for replay.

---

Nitpick comments:
In `@tensorrt_llm/_torch/pyexecutor/py_executor_creator.py`:
- Around line 626-631: Remove the has_draft_model_engine block that logs the
overlap-scheduler warning and sets llm_args.disable_overlap_scheduler in the
surrounding executor-creation flow. Also remove the now-unreachable later branch
guarded by has_draft_model_engine and not llm_args.disable_overlap_scheduler,
while preserving all other scheduler logic.

In `@tests/unittest/_torch/speculative/test_eagle3.py`:
- Around line 477-496: Update the parameterization list for the speculative
model test by removing the obsolete use_one_model column and deleting rows that
represent the removed two-model path. Retain only one-model cases, adjust each
remaining row to the new parameter shape, and preserve the mocked HuggingFace
auto-download case.
- Around line 504-505: Move the deprecation skip for the two-model Eagle3 cases
out of the test body and into the test parameterization or collection-time
configuration. Update the parameterization associated with use_one_model so
deprecated two-model cases are marked skipped before fixtures and torch.cuda
setup run, then remove the body-level pytest.skip.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ca308652-32bc-4416-bde4-e11211178b17

📥 Commits

Reviewing files that changed from the base of the PR and between 3a3cbe7 and 1f48f24.

📒 Files selected for processing (25)
  • .pre-commit-config.yaml
  • legacy-files.txt
  • pyproject.toml
  • ruff-legacy.toml
  • tensorrt_llm/_torch/attention_backend/interface.py
  • tensorrt_llm/_torch/attention_backend/sparse/dsa/metadata.py
  • tensorrt_llm/_torch/attention_backend/sparse/rocket/cache_manager.py
  • tensorrt_llm/_torch/attention_backend/trtllm.py
  • tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
  • tensorrt_llm/_torch/pyexecutor/llm_request.py
  • tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py
  • tensorrt_llm/_torch/pyexecutor/model_engine.py
  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
  • tensorrt_llm/_torch/pyexecutor/resource_manager.py
  • tensorrt_llm/_torch/pyexecutor/sampler/sampler.py
  • tensorrt_llm/_torch/speculative/drafting_loops.py
  • tensorrt_llm/_torch/speculative/interface.py
  • tensorrt_llm/_torch/speculative/model_drafter.py
  • tensorrt_llm/llmapi/llm_args.py
  • tests/unittest/_torch/executor/test_pytorch_model_engine.py
  • tests/unittest/_torch/modeling/test_modeling_llama.py
  • tests/unittest/_torch/speculative/hw_agnostic/test_draft_token_prepare_for_generation.py
  • tests/unittest/_torch/speculative/hw_agnostic/test_draft_token_tree_sampling.py
  • tests/unittest/_torch/speculative/test_eagle3.py
  • tests/unittest/llmapi/test_llm_args.py
💤 Files with no reviewable changes (16)
  • ruff-legacy.toml
  • tensorrt_llm/llmapi/llm_args.py
  • tests/unittest/_torch/speculative/hw_agnostic/test_draft_token_prepare_for_generation.py
  • legacy-files.txt
  • tensorrt_llm/_torch/attention_backend/sparse/rocket/cache_manager.py
  • tensorrt_llm/_torch/speculative/drafting_loops.py
  • tests/unittest/_torch/executor/test_pytorch_model_engine.py
  • .pre-commit-config.yaml
  • tensorrt_llm/_torch/pyexecutor/resource_manager.py
  • tests/unittest/_torch/speculative/hw_agnostic/test_draft_token_tree_sampling.py
  • tests/unittest/_torch/modeling/test_modeling_llama.py
  • tensorrt_llm/_torch/attention_backend/sparse/dsa/metadata.py
  • tensorrt_llm/_torch/pyexecutor/llm_request.py
  • tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py
  • pyproject.toml
  • tensorrt_llm/_torch/attention_backend/interface.py

Comment thread tensorrt_llm/_torch/attention_backend/trtllm.py
Comment thread tensorrt_llm/_torch/pyexecutor/model_engine.py
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #65609 [ run ] triggered by Bot. Commit: 1f48f24 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67966 [ run ] triggered by Bot. Commit: 8b31202 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67966 [ run ] completed with state SUCCESS. Commit: 8b31202
/LLM/main/L0_MergeRequest_PR pipeline #55421 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68012 [ run ] triggered by Bot. Commit: 8b31202 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68012 [ run ] completed with state SUCCESS. Commit: 8b31202
/LLM/main/L0_MergeRequest_PR pipeline #55465 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68074 [ run ] triggered by Bot. Commit: 8b31202 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68074 [ run ] completed with state SUCCESS. Commit: 8b31202
/LLM/main/L0_MergeRequest_PR pipeline #55525 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68372 [ run ] triggered by Bot. Commit: 8b31202 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68372 [ run ] completed with state SUCCESS. Commit: 8b31202
/LLM/main/L0_MergeRequest_PR pipeline #55797 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68414 [ run ] triggered by Bot. Commit: 13e5408 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68414 [ run ] completed with state SUCCESS. Commit: 13e5408
/LLM/main/L0_MergeRequest_PR pipeline #55838 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68428 [ run ] triggered by Bot. Commit: 13e5408 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68428 [ run ] completed with state FAILURE. Commit: 13e5408
/LLM/main/L0_MergeRequest_PR pipeline #55851 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

Signed-off-by: allisonlim-nv <allim@nvidia.com>
Signed-off-by: Allison Lim <allim@nvidia.com>
@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68852 [ run ] triggered by Bot. Commit: 2fd438d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68852 [ run ] completed with state FAILURE. Commit: 2fd438d
/LLM/main/L0_MergeRequest_PR pipeline #56249 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@mikeiovine

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68923 [ run ] triggered by Bot. Commit: 2fd438d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68923 [ run ] completed with state SUCCESS. Commit: 2fd438d
/LLM/main/L0_MergeRequest_PR pipeline #56307 completed with status: 'SUCCESS'

CI Report

Link to invocation

@mikeiovine
mikeiovine merged commit 491f11a into NVIDIA:main Aug 25, 2026
7 checks passed
@mikeiovine
mikeiovine deleted the remove-drafting-loop branch August 25, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-compatible Accepted LLM API contract change that is backwards-compatible ci: full pre-merge approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants