Skip to content

Conversation

@yuxianq
Copy link
Collaborator

@yuxianq yuxianq commented Jan 9, 2026

Summary by CodeRabbit

  • Refactor
    • Reorganized speculative decoding component initialization across model architectures
    • Improved batch processing and inference path handling for speculative decoding
    • Consolidated speculative inference component integration
    • Enhanced model layer iteration patterns

✏️ Tip: You can customize this high-level summary in your review settings.

Description

Test Coverage

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)

  • 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

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

@yuxianq yuxianq requested review from syuoni and ziyixiong-nv January 9, 2026 10:20
@yuxianq yuxianq requested review from a team as code owners January 9, 2026 10:20
@yuxianq
Copy link
Collaborator Author

yuxianq commented Jan 9, 2026

/bot run --disable-fail-fast

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Reorganizes epilogue handling in speculative decoding models by relocating the skip_forward method from MTPWorker to SpecWorkerBase, removing epilogue extensions from DeepseekV3 and GLM models, adding them to SpecDecOneEngine, and refactoring weight removal logic in utilities.

Changes

Cohort / File(s) Summary
Model epilogue composition
tensorrt_llm/_torch/models/modeling_deepseekv3.py, tensorrt_llm/_torch/models/modeling_glm.py, tensorrt_llm/_torch/models/modeling_speculative.py
Removed epilogue extensions of draft_model.mtp_layers and spec_worker from DeepseekV3 and GLM initializers; added the same extensions to SpecDecOneEngine initializer, centralizing epilogue population logic.
Speculative worker interface
tensorrt_llm/_torch/speculative/interface.py, tensorrt_llm/_torch/speculative/mtp.py
Promoted skip_forward method from MTPWorker to SpecWorkerBase base class; method builds per-batch token tensors and returns updated logits dictionary. Also updated set_guided_decoder to return True.
Utility refactoring
tensorrt_llm/_torch/models/modeling_utils.py
Added explicit weight removal for DecoderModelForCausalLM in skip_forward function; refactored layer iteration in DecoderModel.__pp_init__ from index-based to direct enumeration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is essentially empty—only the template is present with no actual explanation of the issue, solution, test coverage, or meaningful checklist items. Provide a detailed description explaining the issue being fixed, the solution implemented, relevant test coverage, and ensure PR checklist items are properly completed.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly relates to the main change: implementing skip forward functionality for speculative workers across different model implementations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @tensorrt_llm/_torch/models/modeling_speculative.py:
- Around line 921-922: The code calls self.epilogue.extend(self.draft_model) but
draft_model is an nn.Module, not iterable, causing a TypeError; change this to
self.epilogue.append(self.draft_model) to add the whole draft model as a single
module, or if the intent was to add specific sublayers (as earlier code did with
draft_model.mtp_layers), replace extend argument with the iterable attribute
(e.g., draft_model.mtp_layers) instead.
🧹 Nitpick comments (1)
tensorrt_llm/_torch/models/modeling_utils.py (1)

306-306: Good refactor: enumerate is cleaner than range indexing.

Switching from range(num_hidden_layers) with manual indexing (self.layers[layer_idx]) to enumerate(self.layers) is more Pythonic and avoids redundant lookups. The layer variable is correctly used in the subsequent skip_forward call.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4632a86 and 0f07acf.

📒 Files selected for processing (6)
  • tensorrt_llm/_torch/models/modeling_deepseekv3.py
  • tensorrt_llm/_torch/models/modeling_glm.py
  • tensorrt_llm/_torch/models/modeling_speculative.py
  • tensorrt_llm/_torch/models/modeling_utils.py
  • tensorrt_llm/_torch/speculative/interface.py
  • tensorrt_llm/_torch/speculative/mtp.py
💤 Files with no reviewable changes (3)
  • tensorrt_llm/_torch/models/modeling_glm.py
  • tensorrt_llm/_torch/models/modeling_deepseekv3.py
  • tensorrt_llm/_torch/speculative/mtp.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: The code developed for TensorRT-LLM should conform to Python 3.8+
Indent Python code with 4 spaces. Do not use tabs
Always maintain the namespace when importing Python modules, even if only one class or function from a module is used
Python filenames should use snake_case (e.g., some_file.py)
Python classes should use PascalCase (e.g., class SomeClass)
Python functions and methods should use snake_case (e.g., def my_awesome_function():)
Python local variables should use snake_case, with prefix k for variable names that start with a number (e.g., k_99th_percentile)
Python global variables should use upper snake_case with prefix G (e.g., G_MY_GLOBAL)
Python constants should use upper snake_case (e.g., MY_CONSTANT)
Avoid shadowing variables declared in an outer scope in Python
Initialize all externally visible members of a Python class in the constructor
For Python interfaces that may be used outside a file, prefer docstrings over comments
Use comments in Python for code within a function, or interfaces that are local to a file
Use Google-style docstrings for Python classes and functions, which can be parsed by Sphinx
Python attributes and variables can be documented inline with the format """<type>: Description"""
Avoid using reflection in Python when functionality can be easily achieved without reflection
When using try-except blocks in Python, limit the except clause to the smallest set of errors possible
When using try-except blocks in Python to handle multiple possible variable types (duck-typing), keep the body of the try as small as possible and use the else block for the main logic

Files:

  • tensorrt_llm/_torch/models/modeling_speculative.py
  • tensorrt_llm/_torch/models/modeling_utils.py
  • tensorrt_llm/_torch/speculative/interface.py
**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification

Files:

  • tensorrt_llm/_torch/models/modeling_speculative.py
  • tensorrt_llm/_torch/models/modeling_utils.py
  • tensorrt_llm/_torch/speculative/interface.py
🧠 Learnings (2)
📚 Learning: 2025-08-19T12:45:11.997Z
Learnt from: amitz-nv
Repo: NVIDIA/TensorRT-LLM PR: 7033
File: tensorrt_llm/_torch/pyexecutor/model_engine.py:0-0
Timestamp: 2025-08-19T12:45:11.997Z
Learning: In tensorrt_llm/_torch/pyexecutor/model_engine.py, DoRA (Delta Orthogonal Rank Adaptation) functionality was removed from the PyTorch flow to eliminate issues with inverted DoRA detection logic. The original is_dora condition was checking if scaling_vec_pointer == 0, which was potentially incorrect.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_utils.py
📚 Learning: 2025-08-18T08:42:02.640Z
Learnt from: samuellees
Repo: NVIDIA/TensorRT-LLM PR: 6974
File: tensorrt_llm/serve/scripts/benchmark_dataset.py:558-566
Timestamp: 2025-08-18T08:42:02.640Z
Learning: In TensorRT-LLM's RandomDataset (tensorrt_llm/serve/scripts/benchmark_dataset.py), when using --random-token-ids option, sequence length accuracy is prioritized over semantic correctness for benchmarking purposes. The encode/decode operations should use skip_special_tokens=True and add_special_tokens=False to ensure exact target token lengths.

Applied to files:

  • tensorrt_llm/_torch/speculative/interface.py
🧬 Code graph analysis (2)
tensorrt_llm/_torch/models/modeling_speculative.py (1)
tensorrt_llm/_torch/models/modeling_mistral.py (1)
  • draft_model (635-636)
tensorrt_llm/_torch/speculative/interface.py (6)
tensorrt_llm/_torch/models/modeling_utils.py (1)
  • skip_forward (152-165)
tensorrt_llm/_torch/models/modeling_mistral.py (1)
  • draft_model (635-636)
tensorrt_llm/_torch/attention_backend/interface.py (1)
  • num_seqs (254-258)
tensorrt_llm/_torch/speculative/mtp.py (1)
  • max_draft_len (359-360)
tensorrt_llm/_torch/speculative/eagle3.py (1)
  • max_draft_len (367-368)
tensorrt_llm/_torch/models/modeling_llama.py (1)
  • dtype (1109-1110)
🪛 Ruff (0.14.10)
tensorrt_llm/_torch/speculative/interface.py

385-385: Unused method argument: input_ids

(ARG002)


386-386: Unused method argument: position_ids

(ARG002)


387-387: Unused method argument: hidden_states

(ARG002)


390-390: Unused method argument: spec_metadata

(ARG002)


391-391: Unused method argument: draft_model

(ARG002)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
🔇 Additional comments (3)
tensorrt_llm/_torch/models/modeling_utils.py (1)

160-161: LGTM! Explicit weight removal for DecoderModelForCausalLM.

The new branch explicitly handles DecoderModelForCausalLM instances by removing weights even when the skip_forward attribute is absent. This ensures consistent weight cleanup during pipeline parallelism setup.

tensorrt_llm/_torch/speculative/interface.py (2)

383-412: Stub implementation with unused parameters is intentional.

The new skip_forward method in SpecWorkerBase provides a default implementation that creates empty tensors without using most input parameters. This appears intentional as a fallback for subclasses that don't need full skip_forward logic during pipeline parallelism.

Static analysis correctly identifies unused parameters (input_ids, position_ids, hidden_states, spec_metadata, draft_model), but these are required for interface consistency with subclass implementations that will override this method.

Note: The empty tensors returned here serve as placeholders. Ensure that calling code can handle these placeholder tensors correctly or that subclasses override this method when actual functionality is needed.


417-417: LGTM! Explicit return value improves clarity.

Changing set_guided_decoder to explicitly return True (rather than implicitly returning None) improves code clarity and aligns with the return type expectation documented in the calling code (e.g., Line 1015 in modeling_speculative.py checks the boolean return value).

Comment on lines 921 to 922
self.epilogue.extend(self.draft_model)
self.epilogue.append(self.spec_worker)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Potential runtime error: extending epilogue with non-iterable draft_model.

Line 921 calls self.epilogue.extend(self.draft_model), but draft_model (returned by get_draft_model()) is an nn.Module instance (e.g., Eagle3ForCausalLM, MTPForCausalLM), not a list or iterable. The extend() method expects an iterable and will raise a TypeError at runtime.

Based on the AI summary, other models previously used epilogue.extend(draft_model.mtp_layers) but removed it. This suggests the intent might be to append the entire draft model as a single module.

🔧 Proposed fix

Replace extend with append to add the draft model as a single module:

-            self.epilogue.extend(self.draft_model)
+            self.epilogue.append(self.draft_model)
             self.epilogue.append(self.spec_worker)

Alternatively, if you need to extend with specific layers from certain draft models:

-            self.epilogue.extend(self.draft_model)
+            if isinstance(self.draft_model, MTPForCausalLM):
+                self.epilogue.extend(self.draft_model.mtp_layers)
+            else:
+                self.epilogue.append(self.draft_model)
             self.epilogue.append(self.spec_worker)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
self.epilogue.extend(self.draft_model)
self.epilogue.append(self.spec_worker)
self.epilogue.append(self.draft_model)
self.epilogue.append(self.spec_worker)
🤖 Prompt for AI Agents
In @tensorrt_llm/_torch/models/modeling_speculative.py around lines 921 - 922,
The code calls self.epilogue.extend(self.draft_model) but draft_model is an
nn.Module, not iterable, causing a TypeError; change this to
self.epilogue.append(self.draft_model) to add the whole draft model as a single
module, or if the intent was to add specific sublayers (as earlier code did with
draft_model.mtp_layers), replace extend argument with the iterable attribute
(e.g., draft_model.mtp_layers) instead.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31250 [ run ] triggered by Bot. Commit: 0f07acf

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31250 [ run ] completed with state SUCCESS. Commit: 0f07acf
/LLM/main/L0_MergeRequest_PR pipeline #24150 completed with status: 'FAILURE'

⚠️ 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

Signed-off-by: Yuxian Qiu <[email protected]>
@yuxianq
Copy link
Collaborator Author

yuxianq commented Jan 10, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31305 [ run ] triggered by Bot. Commit: b268f84

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31305 [ run ] completed with state SUCCESS. Commit: b268f84
/LLM/main/L0_MergeRequest_PR pipeline #24199 completed with status: 'FAILURE'

⚠️ 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

@yuxianq
Copy link
Collaborator Author

yuxianq commented Jan 11, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31400 [ run ] triggered by Bot. Commit: b268f84

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31400 [ run ] completed with state DISABLED
CI server is currently disabled for scheduled maintenance. Estimated completion time: 8 AM PST on 1/11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants