Skip to content

Conversation

@yizhang-nv
Copy link
Member

@yizhang-nv yizhang-nv commented Jan 14, 2026

@coderabbitai summary

Description

Currently I've found that host_kv_cache_block_offsets is never used in attention op. So I remove it and let kv cache manager to manage the buffer. This would allow us to do some buffer reuse optimization for kv cache manager and let the layout/data in that buffer can be defined by kv cache manager. After the changes, the runtime only needs to get the device version of kv_cache_block_offsets.

For torch flow, I remove the argument. For TRT flow, I just remove the enqueue's host_kv_cache_block_offsets, not the plugin's interface so that we don't have to change the model definition code.

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.

@yizhang-nv yizhang-nv requested review from a team as code owners January 14, 2026 02:44
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

📝 Walkthrough

Walkthrough

This PR removes the host_kv_cache_block_offsets parameter from attention operation signatures across C++ plugins, bindings, and Python wrappers. A new copy_batch_block_offsets method is added to KVCacheManager to centralize KV cache block offset batching rather than passing through individual function parameters.

Changes

Cohort / File(s) Summary
C++ Attention Operation Core
cpp/tensorrt_llm/common/attentionOp.h, cpp/tensorrt_llm/thop/attentionOp.h, cpp/tensorrt_llm/thop/attentionOp.cpp
Removed host_kv_cache_block_offsets parameter from attention() function signatures and eliminated host_block_offsets field from EnqueueContextParams struct. KV cache enablement now relies solely on kv_cache_block_offsets presence.
Plugin Implementation
cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h, cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.cpp
Removed host_block_offsets handling from enqueueSome path and updated input parameter documentation (renumbered 8.2 as 8.1, removed 8.1 entry).
Python/C++ Bindings
cpp/tensorrt_llm/pybind/thop/bindings.cpp, cpp/tensorrt_llm/nanobind/thop/bindings.cpp
Removed host_kv_cache_block_offsets argument from attention function binding signatures, reducing exposed optional parameters.
Rope and MLA Operations
cpp/tensorrt_llm/thop/dsv3RopeOp.cpp, cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
Removed host_kv_cache_block_offsets parameter from MLARopeGeneration, loadPagedKVCacheForMLA, and MLARopeAppendPagedKVAssignQ functions. Updated Torch bindings accordingly.
Python Attention Backend
tensorrt_llm/_torch/attention_backend/trtllm.py, tensorrt_llm/_torch/attention_backend/sparse/dsa.py
Removed host_kv_cache_block_offsets field from TrtllmAttentionWrapper and updated plan() signature. Removed argument passthrough in MLA methods. Now uses kv_cache_manager.copy_batch_block_offsets() for offset management.
Custom Ops
tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py
Removed host_kv_cache_block_offsets parameter from mla_rope_generation fake op signature.
Resource Manager
tensorrt_llm/_torch/pyexecutor/resource_manager.py
Added new host_kv_cache_block_offsets tensor attribute (pinned CPU memory) and copy_batch_block_offsets() method to KVCacheManager for centralized batch offset management across context and generation portions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title '[None][fix] Remove unused params in attn' clearly indicates a fix that removes unused parameters in attention code, directly matching the changeset.
Description check ✅ Passed PR description includes clear explanation of changes and rationale: removes unused host_kv_cache_block_offsets parameter from attention ops and delegates buffer management to KV cache manager.

✏️ 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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tensorrt_llm/_torch/pyexecutor/resource_manager.py (1)

411-422: Initialization order bug: self.num_pools and self.max_blocks_per_seq used before assignment.

The tensor creation at lines 411-418 uses self.num_pools and self.max_blocks_per_seq, but these attributes are not defined until lines 421-422. This will cause an AttributeError at runtime.

🐛 Proposed fix: move tensor creation after attribute initialization
         if kv_cache_block_scale_pool_pointers.numel() > 0:
             self.kv_cache_pool_pointers = torch.stack([
                 self.kv_cache_pool_pointers, kv_cache_block_scale_pool_pointers
             ],
                                                       dim=-1)
-        self.host_kv_cache_block_offsets = torch.empty(self.num_pools,
-                                                       max_batch_size *
-                                                       max_beam_width,
-                                                       2,
-                                                       self.max_blocks_per_seq,
-                                                       dtype=torch.int32,
-                                                       pin_memory=True,
-                                                       device='cpu')

         self.kv_cache_pool_mapping = self.impl.get_layer_to_pool_mapping()
         self.num_pools = self.impl.num_pools
         self.max_blocks_per_seq = self.impl.max_blocks_per_seq
         self.enable_block_reuse = kv_cache_config.enable_block_reuse
+        self.host_kv_cache_block_offsets = torch.empty(self.num_pools,
+                                                       max_batch_size *
+                                                       max_beam_width,
+                                                       2,
+                                                       self.max_blocks_per_seq,
+                                                       dtype=torch.int32,
+                                                       pin_memory=True,
+                                                       device='cpu')
cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h (1)

1-2: Update copyright year to reflect the latest modification.

The copyright year should be updated to 2026 to reflect this modification.

As per coding guidelines: All TensorRT-LLM source files should contain an NVIDIA copyright header with the year of latest meaningful modification.

📅 Proposed fix
 /*
- * SPDX-FileCopyrightText: Copyright (c) 1993-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright (c) 1993-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
  * SPDX-License-Identifier: Apache-2.0
📜 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 795e690 and 2fcc3e6.

📒 Files selected for processing (13)
  • cpp/tensorrt_llm/common/attentionOp.h
  • cpp/tensorrt_llm/nanobind/thop/bindings.cpp
  • cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.cpp
  • cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h
  • cpp/tensorrt_llm/pybind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/thop/attentionOp.h
  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
  • tensorrt_llm/_torch/attention_backend/sparse/dsa.py
  • tensorrt_llm/_torch/attention_backend/trtllm.py
  • tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py
  • tensorrt_llm/_torch/pyexecutor/resource_manager.py
💤 Files with no reviewable changes (4)
  • tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py
  • tensorrt_llm/_torch/attention_backend/sparse/dsa.py
  • cpp/tensorrt_llm/common/attentionOp.h
  • cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.cpp
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh}: Closing braces of namespaces should have a comment saying the namespace it closes (e.g., } // namespace foo)
Prefer const or constexpr variables over #defines whenever possible
A variable that is not modified after its initialization should be declared as const
For naming of constants in C++, use uppercase snakecase with prefix 'k' (e.g., kDIGIT_NUM)
Except for 0, nullptr, true, and false, all other literals should only be used for variable initialization and not in comparisons or expressions
Use Allman indentation style for brace notation in C++ code
Put the semicolon for an empty for or while loop in a new line
The statement forming the body of a switch, while, do..while, or for statement must be a compound statement (use brace-delimited statements)
If and else statements should always be followed by brace-delimited statements, even if empty or a single statement
C++ filenames should use camelCase with first letter lowercase (e.g., thisIsAFilename.cpp)
All types (including class names) in C++ should use PascalCase with uppercase first letter (e.g., FooBarClass)
Local variables, methods, and namespaces in C++ should use camelCase with first letter lowercase (e.g., localFooBar)
Non-magic-number global variables that are non-static and not defined in anonymous namespace should use camelCase prefixed with 'g' (e.g., gDontUseGlobalFoos)
Non-magic-number global variables that are static or defined in an anonymous namespace should use camelCase prefixed with 's' (e.g., sMutableStaticGlobal)
Locally visible static variables should use camelCase with 's' as the first letter (e.g., static std::once_flag sFlag;)
Public, private, and protected class member variables should use camelCase prefixed with 'm' (e.g., mNbFooValues)
Do not use Hungarian notation in C++ except for 'apps hungarian' (e.g., 'nb' to indicate count: mNbLayers)
If a constructor parameter name conflicts with a public me...

Files:

  • cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h
  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
  • cpp/tensorrt_llm/pybind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/nanobind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/attentionOp.h
**/*.{h,hpp,hxx}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{h,hpp,hxx}: Follow Doxygen rules for documenting new C++ class interfaces and function prototypes. Use //! for C++-style single-line comments and //!< for class members
Use a preprocessor guard in C++ header files with the format TRTLLM_<FILENAME>_H, where the filename is in uppercase with no underscores, no prefix underscores, and no trailing underscores

Files:

  • cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h
  • cpp/tensorrt_llm/thop/attentionOp.h
**/*.{h,hpp,hxx,cpp,cc,cxx,cu,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All C++ class templates, function templates, class template member functions, and class template static members must be instantiated at least once

Files:

  • cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h
  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
  • cpp/tensorrt_llm/pybind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/nanobind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/attentionOp.h
**/*.{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:

  • cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h
  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
  • cpp/tensorrt_llm/pybind/thop/bindings.cpp
  • tensorrt_llm/_torch/pyexecutor/resource_manager.py
  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
  • tensorrt_llm/_torch/attention_backend/trtllm.py
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/nanobind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/attentionOp.h
**/*.{cpp,cc,cxx,cu}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{cpp,cc,cxx,cu}: Use smart pointers for allocating objects on the heap in C++
Prefer unique_ptr for single resource ownership and shared_ptr for shared resource ownership in C++. Use weak_ptr only in exceptional cases
In C++ function calls where parameters are not obvious, use inline C comments to document the parameter (e.g., doSomeOperation(/* checkForErrors = */ false);)
Use the least forceful cast necessary in C++, or no cast if possible
Casting a pointer to void* in C++ should be implicit (except if removing const)
Casting in C++ should not remove any const or volatile qualification from the type of a pointer or reference
Do not use C-style casts (other than void casts) and functional notation casts (other than explicit constructor calls) in C++
Casting from void* to T* in C++ should be done with static_cast, not reinterpret_cast
Use reinterpret_cast in C++ as a last resort, where const_cast and static_cast won't work
Avoid dynamic_cast in C++
Do not use assignment operator in C++ subexpressions (e.g., x = y = z or if (x = y))
When practical, a C++ switch statement controlled by an enum should have a case for each enum value and not have a default clause
C++ switch statements should be well structured as structured multi-way branches, not as 'glorified gotos'
In C++ switch statements, prohibit fall-through except from one case label to another. Each case clause must be terminated with a break or throw
Do not end a C++ case clause with return; use break or throw instead
If a C++ switch clause is a compound statement, put the break inside the braces
Do not use C library functions in C++ whenever possible. Use C++ alternatives like brace initialization or std::fill_n() instead of memset()

Files:

  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
  • cpp/tensorrt_llm/pybind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/nanobind/thop/bindings.cpp
**/*.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/pyexecutor/resource_manager.py
  • tensorrt_llm/_torch/attention_backend/trtllm.py
🧠 Learnings (16)
📓 Common learnings
Learnt from: thorjohnsen
Repo: NVIDIA/TensorRT-LLM PR: 6910
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:0-0
Timestamp: 2025-08-14T21:04:50.248Z
Learning: In KV cache onboarding logic during prefill in cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, when calculating which blocks fall within the attention window, use getTokensPerBlock() to advance token indices rather than block->getUniqueTokens().size(), because the calculation needs to consider the post-prefill state where blocks will be filled to capacity, not their current token count.
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 6768
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:2010-2045
Timestamp: 2025-08-21T09:41:49.347Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, updateSequenceCacheBlockOffsets is specifically for updating bookkeeping when blocks are added during the context phase, not for refreshing offsets after detach operations. During detach operations, GenerationRequest::removeFrontBlock handles the necessary cache block bookkeeping internally.
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 6768
File: cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h:0-0
Timestamp: 2025-08-20T06:48:45.368Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, updateSequenceCacheBlockOffsets is only called when adding a sequence, not during detach operations. During detach, the cache block bookkeeping is handled by GenerationRequest::removeFrontBlock.
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 6767
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:0-0
Timestamp: 2025-08-15T06:46:54.897Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp addToken function, newly allocated blocks are unshared by design. The beam search path in addToken (when sequence.getNumTokens() > windowSize) is currently broken/non-functional with SWA, so the block allocation doesn't follow a shared-then-unshared pattern.
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 6768
File: cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h:0-0
Timestamp: 2025-08-20T06:48:45.368Z
Learning: There is a planned refactoring to move cache block bookkeeping utilities from BlockManager/WindowBlockManager into the GenerationRequest class itself to improve code organization and make responsibilities clearer.
📚 Learning: 2025-08-14T21:04:50.248Z
Learnt from: thorjohnsen
Repo: NVIDIA/TensorRT-LLM PR: 6910
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:0-0
Timestamp: 2025-08-14T21:04:50.248Z
Learning: In KV cache onboarding logic during prefill in cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, when calculating which blocks fall within the attention window, use getTokensPerBlock() to advance token indices rather than block->getUniqueTokens().size(), because the calculation needs to consider the post-prefill state where blocks will be filled to capacity, not their current token count.

Applied to files:

  • cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h
  • cpp/tensorrt_llm/pybind/thop/bindings.cpp
  • tensorrt_llm/_torch/pyexecutor/resource_manager.py
  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
  • tensorrt_llm/_torch/attention_backend/trtllm.py
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/nanobind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/attentionOp.h
📚 Learning: 2025-08-08T04:10:19.038Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6728
File: cpp/tensorrt_llm/plugins/mixtureOfExperts/mixtureOfExpertsPlugin.cpp:966-966
Timestamp: 2025-08-08T04:10:19.038Z
Learning: TensorRT plugins currently don't support padding functionality, and TensorRT is not getting new features (in maintenance mode). This means that duplicating parameters like mExpertHiddenSize in function calls, even with TODO comments, can be acceptable as pragmatic solutions within these constraints.

Applied to files:

  • cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h
📚 Learning: 2025-12-19T06:31:54.973Z
Learnt from: nvyocox
Repo: NVIDIA/TensorRT-LLM PR: 10117
File: tensorrt_llm/_torch/auto_deploy/transform/library/fuse_rope_attention.py:336-339
Timestamp: 2025-12-19T06:31:54.973Z
Learning: In tensorrt_llm/_torch/auto_deploy/transform/library/fuse_rope_attention.py, the cast to torch.float16 for qkv_node before creating the AttentionPlugin is intentional and required because DriveOS LLM expects float16 dtype specifically. This should not be changed to preserve original dtype or made configurable for bfloat16 models in the DriveOS LLM ONNX export path.

Applied to files:

  • cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h
📚 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:

  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
  • tensorrt_llm/_torch/attention_backend/trtllm.py
📚 Learning: 2025-08-21T09:41:49.347Z
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 6768
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:2010-2045
Timestamp: 2025-08-21T09:41:49.347Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, updateSequenceCacheBlockOffsets is specifically for updating bookkeeping when blocks are added during the context phase, not for refreshing offsets after detach operations. During detach operations, GenerationRequest::removeFrontBlock handles the necessary cache block bookkeeping internally.

Applied to files:

  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
  • cpp/tensorrt_llm/pybind/thop/bindings.cpp
  • tensorrt_llm/_torch/pyexecutor/resource_manager.py
  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
  • tensorrt_llm/_torch/attention_backend/trtllm.py
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/nanobind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/attentionOp.h
📚 Learning: 2025-08-20T06:48:45.368Z
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 6768
File: cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h:0-0
Timestamp: 2025-08-20T06:48:45.368Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, updateSequenceCacheBlockOffsets is only called when adding a sequence, not during detach operations. During detach, the cache block bookkeeping is handled by GenerationRequest::removeFrontBlock.

Applied to files:

  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
  • cpp/tensorrt_llm/pybind/thop/bindings.cpp
  • tensorrt_llm/_torch/pyexecutor/resource_manager.py
  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
  • tensorrt_llm/_torch/attention_backend/trtllm.py
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/nanobind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/attentionOp.h
📚 Learning: 2025-08-19T12:45:35.429Z
Learnt from: amitz-nv
Repo: NVIDIA/TensorRT-LLM PR: 7033
File: tensorrt_llm/_torch/pyexecutor/model_engine.py:2086-2092
Timestamp: 2025-08-19T12:45:35.429Z
Learning: DoRA (Delta Orthogonal Rank Adaptation) functionality has been removed from the PyTorch flow in tensorrt_llm/_torch/pyexecutor/model_engine.py. The is_dora field is computed but not used downstream in the PyTorch flow, so converting it to a tensor would be wasteful overhead.

Applied to files:

  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
📚 Learning: 2025-08-20T06:56:02.889Z
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 6768
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:577-579
Timestamp: 2025-08-20T06:56:02.889Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, maxSequenceLength is now enforced as a non-optional argument in the BlockManager constructor, so concerns about std::nullopt defaulting to 0 are not applicable. When windowSize > maxSequenceLength, a warning should be added instead of handling optional parameter cases.

Applied to files:

  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
  • cpp/tensorrt_llm/thop/attentionOp.cpp
📚 Learning: 2025-08-15T06:46:54.897Z
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 6767
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:0-0
Timestamp: 2025-08-15T06:46:54.897Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp addToken function, newly allocated blocks are unshared by design. The beam search path in addToken (when sequence.getNumTokens() > windowSize) is currently broken/non-functional with SWA, so the block allocation doesn't follow a shared-then-unshared pattern.

Applied to files:

  • cpp/tensorrt_llm/thop/dsv3RopeOp.cpp
  • tensorrt_llm/_torch/pyexecutor/resource_manager.py
  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
  • tensorrt_llm/_torch/attention_backend/trtllm.py
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/thop/attentionOp.h
📚 Learning: 2025-12-12T03:27:08.565Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 9655
File: tensorrt_llm/_torch/pyexecutor/sampler.py:3031-3031
Timestamp: 2025-12-12T03:27:08.565Z
Learning: In files under tensorrt_llm/_torch/pyexecutor, avoid accessing torch.Tensor objects inside for-loops when iterating over requests. Convert batched tensors to Python lists beforehand using tensor.tolist(), and then iterate over those lists. This improves performance by reducing tensor-bound operations inside hot loops. Apply this pattern to similar code paths that process batches to access simple Python data structures (lists) inside loops.

Applied to files:

  • tensorrt_llm/_torch/pyexecutor/resource_manager.py
📚 Learning: 2025-08-14T15:38:01.771Z
Learnt from: MatthiasKohl
Repo: NVIDIA/TensorRT-LLM PR: 6904
File: cpp/tensorrt_llm/pybind/thop/bindings.cpp:55-57
Timestamp: 2025-08-14T15:38:01.771Z
Learning: In TensorRT-LLM Python bindings, tensor parameter collections like mla_tensor_params and spec_decoding_tensor_params are kept as required parameters without defaults to maintain API consistency, even when it might affect backward compatibility.

Applied to files:

  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
📚 Learning: 2025-08-21T02:39:12.009Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 7104
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:1475-1480
Timestamp: 2025-08-21T02:39:12.009Z
Learning: The min latency mode functionality in TensorRT-LLM MOE kernels (cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu) is deprecated and no longer being maintained/updated, as confirmed by djns99. Bug reports and optimization suggestions for the computeStridesTmaWarpSpecializedLowLatencyKernel and related min latency code paths should be deprioritized.

Applied to files:

  • cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp
📚 Learning: 2025-08-14T15:43:23.107Z
Learnt from: MatthiasKohl
Repo: NVIDIA/TensorRT-LLM PR: 6904
File: tensorrt_llm/_torch/attention_backend/trtllm.py:259-262
Timestamp: 2025-08-14T15:43:23.107Z
Learning: In TensorRT-LLM's attention backend, tensor parameters in the plan() method are assigned directly without validation (dtype, device, contiguity checks). This maintains consistency across all tensor inputs and follows the pattern of trusting callers to provide correctly formatted tensors.

Applied to files:

  • tensorrt_llm/_torch/attention_backend/trtllm.py
  • cpp/tensorrt_llm/thop/attentionOp.cpp
📚 Learning: 2025-08-15T06:46:53.813Z
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 6767
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:0-0
Timestamp: 2025-08-15T06:46:53.813Z
Learning: In the TensorRT-LLM KV cache manager, SWA (Sliding Window Attention) combined with beam search is currently in a broken/non-functional state and is planned for future rework. During preparatory refactoring phases, code related to SWA+beam search may intentionally remain in a non-working state until the broader rework is completed.

Applied to files:

  • tensorrt_llm/_torch/attention_backend/trtllm.py
  • cpp/tensorrt_llm/thop/attentionOp.cpp
📚 Learning: 2025-08-21T00:16:56.457Z
Learnt from: farshadghodsian
Repo: NVIDIA/TensorRT-LLM PR: 7101
File: docs/source/blogs/tech_blog/blog9_Deploying_GPT_OSS_on_TRTLLM.md:36-36
Timestamp: 2025-08-21T00:16:56.457Z
Learning: TensorRT-LLM container release tags in documentation should only reference published NGC container images. The README badge version may be ahead of the actual published container versions.

Applied to files:

  • tensorrt_llm/_torch/attention_backend/trtllm.py
🧬 Code graph analysis (2)
tensorrt_llm/_torch/attention_backend/trtllm.py (1)
tensorrt_llm/_torch/pyexecutor/resource_manager.py (1)
  • copy_batch_block_offsets (1280-1293)
cpp/tensorrt_llm/thop/attentionOp.cpp (2)
tensorrt_llm/runtime/generation.py (1)
  • use_kv_cache (1214-1215)
tensorrt_llm/_torch/attention_backend/trtllm.py (1)
  • host_kv_cache_pool_pointers (710-714)
⏰ 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 (14)
cpp/tensorrt_llm/thop/attentionOp.h (1)

41-74: LGTM - Signature update correctly removes unused parameter.

The function signature update removing host_kv_cache_block_offsets aligns with the PR objective. The remaining kv_cache_block_offsets parameter is sufficient for KV cache block offset handling.

cpp/tensorrt_llm/thop/dsv3RopeOp.cpp (2)

123-125: LGTM - Parameter removal correctly applied.

The function signature update properly removes host_kv_cache_block_offsets while maintaining the required parameters for KV cache handling.


150-151: LGTM - use_kv_cache logic correctly updated.

The condition now properly checks the three essential tensors (kv_cache_block_offsets, host_kv_cache_pool_pointers, host_kv_cache_pool_mapping) without the removed host_kv_cache_block_offsets parameter.

cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp (2)

160-167: LGTM - loadPagedKVCacheForMLA signature correctly updated.

The parameter removal is consistent with the broader PR refactoring. The function continues to use kv_cache_block_offsets for KV cache block handling via createKVBlockArray.


347-355: LGTM - MLARopeAppendPagedKVAssignQ signature correctly updated.

The signature update aligns with the other MLA-related functions in this file and maintains consistency with the Torch bindings defined at lines 536-563.

tensorrt_llm/_torch/pyexecutor/resource_manager.py (1)

1280-1293: LGTM - copy_batch_block_offsets method implementation.

The method correctly:

  1. Copies context request offsets with beam_width=1
  2. Copies generation request offsets with the actual beam width
  3. Uses non_blocking=True for efficient pinned-to-device copy
cpp/tensorrt_llm/thop/attentionOp.cpp (2)

597-635: LGTM - Attention function signature and use_kv_cache logic correctly updated.

The parameter removal is consistent with the header declaration, and the use_kv_cache condition properly validates the essential tensors (kv_cache_block_offsets, host_kv_cache_pool_pointers, host_kv_cache_pool_mapping).


884-915: LGTM - runner->run() calls correctly updated for both context and generation paths.

Both invocations at lines 889 and 908 properly pass the updated parameter list without host_kv_cache_block_offsets, maintaining consistency with the RunnerBase::run signature.

cpp/tensorrt_llm/nanobind/thop/bindings.cpp (1)

39-76: LGTM!

The removal of host_kv_cache_block_offsets from the nanobind binding aligns with the PR objective. The binding now correctly exposes only kv_cache_block_offsets with default std::nullopt, which is consistent with the underlying C++ function signature changes.

cpp/tensorrt_llm/pybind/thop/bindings.cpp (1)

39-76: LGTM!

The pybind11 binding change mirrors the nanobind binding change, ensuring consistent Python API across both binding mechanisms. The removal of host_kv_cache_block_offsets is correctly applied.

tensorrt_llm/_torch/attention_backend/trtllm.py (2)

241-245: LGTM!

The docstring update correctly reflects the removal of host_kv_cache_block_offsets. The description now focuses solely on kv_cache_block_offsets for GPU-side block offsets.


975-988: LGTM!

The refactored KV cache block offset handling correctly uses the new copy_batch_block_offsets API from the KV cache manager. This centralizes the offset batching logic and aligns with the removal of host_kv_cache_block_offsets from the public API.

The method call correctly passes:

  • self.kv_cache_block_offsets as the destination tensor
  • self.request_ids for request identification
  • self.beam_width, self.num_contexts, self.num_generations for batching configuration

This matches the signature in resource_manager.py where context requests are processed first (with beam_width=1), followed by generation requests.

cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h (2)

58-58: LGTM! Documentation renumbering is correct.

The renumbering from 8.2 to 8.1 for host_pool_pointers correctly reflects the removal of the host_block_offsets parameter.


197-197: No action needed—HOST_KV_CACHE_BLOCK_OFFSETS is actively used in the implementation.

The enum entry remains necessary and should not be removed. It is actively referenced in gptAttentionPlugin.cpp in the isEntryUsed() method (line 167) and in input validation logic (line 398), where it controls conditional behavior based on KV cache configuration. The documentation update and code logic are independent concerns.

Likely an incorrect or invalid review comment.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@yizhang-nv yizhang-nv force-pushed the remove-unused-params branch 2 times, most recently from f4d16bc to 5148d3c Compare January 14, 2026 02:55
@yizhang-nv
Copy link
Member Author

/bot run

@yizhang-nv
Copy link
Member Author

/bot kill

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31875 [ run ] triggered by Bot. Commit: 5148d3c

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31876 [ kill ] triggered by Bot. Commit: 5148d3c

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31875 [ run ] completed with state ABORTED. Commit: 5148d3c

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31876 [ kill ] completed with state SUCCESS. Commit: 5148d3c
Successfully killed previous jobs for commit 5148d3c

@yizhang-nv yizhang-nv force-pushed the remove-unused-params branch 2 times, most recently from 546f1ca to a855a42 Compare January 14, 2026 05:24
@yizhang-nv
Copy link
Member Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31893 [ run ] triggered by Bot. Commit: a855a42

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31893 [ run ] completed with state FAILURE. Commit: a855a42
/LLM/main/L0_MergeRequest_PR pipeline #24696 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

@yizhang-nv
Copy link
Member Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31897 [ run ] triggered by Bot. Commit: a855a42

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31897 [ run ] completed with state FAILURE. Commit: a855a42
/LLM/main/L0_MergeRequest_PR pipeline #24700 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

@yizhang-nv yizhang-nv force-pushed the remove-unused-params branch from a855a42 to bc8d63e Compare January 14, 2026 08:24
@yizhang-nv
Copy link
Member Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31942 [ run ] triggered by Bot. Commit: d705540

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31942 [ run ] completed with state FAILURE. Commit: d705540
/LLM/main/L0_MergeRequest_PR pipeline #24741 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

@yizhang-nv yizhang-nv force-pushed the remove-unused-params branch from d705540 to 57164a0 Compare January 14, 2026 14:52
@yizhang-nv
Copy link
Member Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31988 [ run ] triggered by Bot. Commit: 57164a0

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31988 [ run ] completed with state SUCCESS. Commit: 57164a0
/LLM/main/L0_MergeRequest_PR pipeline #24781 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: yizhang-nv <[email protected]>
Signed-off-by: yizhang-nv <[email protected]>
@yizhang-nv yizhang-nv force-pushed the remove-unused-params branch from ff44e27 to 336d7e2 Compare January 15, 2026 02:18
@yizhang-nv
Copy link
Member Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32047 [ run ] triggered by Bot. Commit: 336d7e2

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32047 [ run ] completed with state SUCCESS. Commit: 336d7e2
/LLM/main/L0_MergeRequest_PR pipeline #24836 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

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.

3 participants