Skip to content

Conversation

@NVShreyas
Copy link
Collaborator

@NVShreyas NVShreyas commented Jan 23, 2026

Summary by CodeRabbit

  • New Features

    • Added transfer buffer management capabilities with dynamic and pre-allocated memory path support.
    • Introduced FabricMemory backing for transfer operations.
    • Enhanced KV-cache transfer infrastructure with improved state management and resource handling.
  • Refactor

    • Reorganized cache transfer architecture for improved modularity and separation of concerns.
    • Simplified public interfaces while maintaining functionality through layered abstraction.

✏️ 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.

@NVShreyas NVShreyas requested a review from a team as a code owner January 23, 2026 15:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new abstract base class BaseTransBufferManager to manage transfer buffers with support for dynamic/pre-allocated memory paths and optional FabricMemory backing, refactors CacheTransBufferManager to inherit from this base while simplifying its public API, and comprehensively restructures the data transceiver architecture with new BaseCacheSenderImpl and BaseCacheReceiverImpl base classes for asynchronous KV-cache send/receive operations.

Changes

Cohort / File(s) Summary
New Base Buffer Manager
cpp/tensorrt_llm/batch_manager/baseTransBuffer.h, cpp/tensorrt_llm/batch_manager/baseTransBuffer.cpp, cpp/tensorrt_llm/batch_manager/CMakeLists.txt
Introduces new abstract BaseTransBufferManager class (+144H, +284C) managing transfer buffers with allocation, indexing, and retrieval; supports dynamic/pre-allocated memory paths and FabricMemory backing via ConcurrenceResource struct with mutex-protected state; CMakeLists updated to include compiled source.
Cache Transfer Buffer Refactoring
cpp/tensorrt_llm/batch_manager/cacheTransBuffer.h, cpp/tensorrt_llm/batch_manager/cacheTransBuffer.cpp
CacheTransBufferManager now inherits from BaseTransBufferManager; public API simplified (removed buffer index/allocation methods); added FabricMemory implementation with aligned sizing; constructor signature simplified to accept cache manager, max tokens, and transfer indexer flag; sizing computation delegated to static helper.
Data Transceiver Architecture Refactoring
cpp/tensorrt_llm/batch_manager/dataTransceiver.h, cpp/tensorrt_llm/batch_manager/dataTransceiver.cpp
Major restructuring introducing BaseCacheSenderImpl and BaseCacheReceiverImpl base classes (+199H, +665C/-778C); CacheSender/CacheReceiver now derive from these bases; new async APIs with promises/futures for request-response handling; reorganized threading, synchronization, and per-request resource management; added getSelfState() accessors and request info exchange methods.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant Sender as BaseCacheSenderImpl
    participant Mgr as ConnectionManager
    participant Fmt as BaseCacheFormatter
    participant Queue as AsyncSendResource

    App->>Sender: sendAsync(llmRequest)
    activate Sender
    Sender->>Queue: enqueue(request, promise)
    activate Queue
    Sender-->>App: return future
    deactivate Sender
    
    Queue->>Fmt: format(request)
    activate Fmt
    Fmt-->>Queue: formatted data
    deactivate Fmt
    
    Queue->>Mgr: send(formatted data)
    activate Mgr
    Mgr-->>Queue: success/error
    deactivate Mgr
    
    Queue->>Queue: signal promise
    deactivate Queue
    App->>App: await future
Loading
sequenceDiagram
    participant App as Application
    participant Receiver as BaseCacheReceiverImpl
    participant Mgr as ConnectionManager
    participant Fmt as BaseCacheFormatter
    participant BufMgr as BufferManager

    App->>Receiver: receiveAsync(llmRequest)
    activate Receiver
    Receiver->>Mgr: recv(request info)
    activate Mgr
    Mgr-->>Receiver: received data
    deactivate Mgr
    
    Receiver->>BufMgr: allocate buffer
    activate BufMgr
    BufMgr-->>Receiver: buffer
    deactivate BufMgr
    
    Receiver->>Fmt: deserialize(data, buffer)
    activate Fmt
    Fmt-->>Receiver: deserialized request
    deactivate Fmt
    
    Receiver-->>App: return future
    deactivate Receiver
    App->>App: await future
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • pcastonguay
  • chuangz0
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description is entirely blank with no content provided beyond the template structure and checklist. Please provide a detailed description explaining: (1) what changes are being made and why, (2) the scope of the refactor (cache sender, receiver, buffer managers), (3) test coverage for the changes, and (4) any architectural impact. Use the template sections for Description and Test Coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change as a refactor to prepare for RNN cache transceiver functionality with the TRTLLM-10197 ticket reference.

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

Caution

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

⚠️ Outside diff range comments (5)
cpp/tensorrt_llm/batch_manager/cacheTransBuffer.h (1)

60-82: Use //!-style Doxygen comments in headers.

Lines 60–82 use /// for documentation comments; headers must use //! and //!< per the project guidelines. Update all doc comments to the correct style.

cpp/tensorrt_llm/batch_manager/cacheTransBuffer.cpp (2)

131-187: Replace #ifdef with #if defined(...) for non-include-guard preprocessor conditionals.

Line 133 uses #ifdef __aarch64__; per coding guidelines, use #if defined(__aarch64__) instead. The #ifdef directive should only be used for header include guards.


194-255: Guard cacheManager before dereference in computeTransferBufferSize.

computeTransferBufferSize dereferences cacheManager at lines 199, 203, and 206 without any null check. Since the constructor calls this function in the initializer list before the body executes the check at line 260, a null pointer will cause undefined behavior. Add TLLM_CHECK(cacheManager); at the start of computeTransferBufferSize.

Suggested fix
size_t CacheTransBufferManager::computeTransferBufferSize(
    KVCacheManager::BaseKVCacheManager* cacheManager, std::optional<size_t> maxNumTokens, bool transferIndexerKCache)
{
+    TLLM_CHECK(cacheManager);
     nvinfer1::DataType dataType;
     if (transferIndexerKCache)
     {
         dataType = cacheManager->getIndexerKCachePool()->getDataType();
cpp/tensorrt_llm/batch_manager/dataTransceiver.h (2)

52-62: Duplicate type alias for BlockKey.

BlockKey is defined twice: on line 53 and again on line 60. Both refer to the same type (kv_cache_manager::BlockKey). Remove one of these duplicate aliases.

🔧 Proposed fix
 using BaseCacheFormatter = kv_cache_manager::BaseCacheFormatter;
 using BlockKey = kv_cache_manager::BlockKey;
 
 // TODO: unify the following class into a namespace like tensorrt_llm::transmission
 using DataContext = tensorrt_llm::executor::kv_cache::DataContext;
 using Connection = tensorrt_llm::executor::kv_cache::Connection;
 using ConnectionManager = tensorrt_llm::executor::kv_cache::ConnectionManager;
 using SizeType32 = tensorrt_llm::runtime::SizeType32;
-using BlockKey = tensorrt_llm::batch_manager::kv_cache_manager::BlockKey;
 using UniqueToken = tensorrt_llm::runtime::UniqueToken;

161-162: Remove redundant duplicate type aliases.

Both UniqueToken (line 61) and BlockKey (lines 53, 60) are already defined earlier in this file within the same namespace. These duplicate declarations are unnecessary and should be removed.

🔧 Proposed fix
     BlockKey mLastBlockKey{};
 };
 
-using UniqueToken = tensorrt_llm::runtime::UniqueToken;
-using BlockKey = tensorrt_llm::batch_manager::kv_cache_manager::BlockKey;
-
 struct TransceiverTag
🤖 Fix all issues with AI agents
In `@cpp/tensorrt_llm/batch_manager/baseTransBuffer.cpp`:
- Around line 1-16: Update the SPDX header in baseTransBuffer.cpp to reflect the
2026 modification by changing the copyright year from "2025" to either "2026" or
the range "2025–2026" in the top comment block (the SPDX-FileCopyrightText line
and any other matching year occurrences in the same header).

In `@cpp/tensorrt_llm/batch_manager/baseTransBuffer.h`:
- Around line 1-16: Update the header copyright year in the top-of-file license
block in baseTransBuffer.h from "2025" to reflect the latest change (use either
"2025–2026" or "2026"); modify both the SPDX-FileCopyrightText line and any
other occurrences of the year in the same comment block so the SPDX header and
license text consistently show the updated year.
- Around line 41-102: Replace the triple-slash Doxygen comments in this header
with the project-preferred single-line `//!` style: update the class-level and
method comments for BaseTransBufferManager and each member
(assignBufferIndexForSend, freeBufferIndexForSend, assignBufferIndexForRecv,
freeBufferIndexForRecv, getOrAllocateSendBuffers, getOrAllocateRecvBuffers,
getSendBuffer, getRecvBuffer, getRecvBufferCount, getSendBufferCount,
getMaxNumTokens and the mMaxNumTokens member) so that `///` becomes `//!` and
any trailing member descriptions use `//!<` where appropriate to document class
members.

In `@cpp/tensorrt_llm/batch_manager/dataTransceiver.cpp`:
- Around line 458-584: The code has multiple race conditions accessing
mReadyResponses and mAnyReady from response() and sendResponse(); fix by
consistently taking mSenderMutex for any lookup/iteration/empty check on
mReadyResponses (e.g., wrap the find at sendResponse, the empty checks at lines
like the if (!mReadyResponses.empty()) and the getCurrentResponse()/iteration
loops inside scoped_lock(mSenderMutex)), and ensure mAnyReady is either made
atomic or always read/updated under the same mutex used to set it (prefer
reading/updating mAnyReady under mCondMutex or under mSenderMutex consistently).
Change response() to acquire mSenderMutex to extract or move the current
response entry into a local variable before releasing the lock and calling
sendAndRemoveResponse/asyncSendAndRemoveResponse/removeResponse so iterators
won't be invalidated by concurrent sendAsync/cancelRequest; similarly protect
accesses to mCancelledRequests. For the TODO about cancelled requests
persisting, add cleanup logic (e.g., when isReady==false remove the request from
mCancelledRequests and mRemainSendCount under mSenderMutex or schedule a
timeout-based cleanup) so cancelled entries cannot remain indefinitely.
- Around line 1020-1107: Guard the empty block-range before dereferencing within
sendRequestInfo: check requestedBlockRange.getBlockIdsPerWindow().empty() (from
getBlockRangeForReceiving / requestedBlockRange) and TLLM_CHECK_WITH_INFO or
early-return/skip the block-specific logic if empty before calling
begin()->second.size() and computing indexFromEnd; ensure requestedBlockSize is
validated. Fix the TODO mapping for validConnectionIdx in the loop over
counterPartConnections: use auto it = std::find(pickUpIdx.begin(),
pickUpIdx.end(), i); if it == pickUpIdx.end() skip/continue that connection (or
handle as an error), otherwise compute size_t validConnectionIdx =
std::distance(pickUpIdx.begin(), it) before calling sendRequestAndBufferInfo on
the AgentConnection to avoid out-of-bounds indices.

In `@cpp/tensorrt_llm/batch_manager/dataTransceiver.h`:
- Around line 449-451: Typo: the mutex member is declared as
mProcessIoResouceMutex (missing 'r'); rename it to mProcessIoResourceMutex
everywhere to fix the spelling. Update the declaration in dataTransceiver.h and
all uses/references (e.g., lock_guard, std::unique_lock, or any member access)
to the corrected symbol so the class (and any other files) compile and
consistently refer to mProcessIoResourceMutex.
🧹 Nitpick comments (1)
cpp/tensorrt_llm/batch_manager/baseTransBuffer.h (1)

129-141: Prefer private data members with protected accessors.

This class is non-POD; guidelines require private members. Consider making these private and exposing protected getters/setters for derived classes. As per coding guidelines, please adjust the member visibility.

Comment on lines +1 to +16
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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 | 🟡 Minor

Update copyright year to 2026.

This new header still lists 2025; please update to 2025–2026 or 2026. As per coding guidelines, the year should reflect the latest meaningful modification.

🤖 Prompt for AI Agents
In `@cpp/tensorrt_llm/batch_manager/baseTransBuffer.h` around lines 1 - 16, Update
the header copyright year in the top-of-file license block in baseTransBuffer.h
from "2025" to reflect the latest change (use either "2025–2026" or "2026");
modify both the SPDX-FileCopyrightText line and any other occurrences of the
year in the same comment block so the SPDX header and license text consistently
show the updated year.

Signed-off-by: Shreyas Misra <shreyasm@nvidia.com>
Signed-off-by: Shreyas Misra <shreyasm@nvidia.com>
Signed-off-by: Shreyas Misra <shreyasm@nvidia.com>
Signed-off-by: Shreyas Misra <shreyasm@nvidia.com>
@NVShreyas NVShreyas force-pushed the user/shreyasm/mamba-disagg-refactor branch from da98411 to 67c68c8 Compare January 23, 2026 16:13
@NVShreyas
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #33395 [ run ] triggered by Bot. Commit: 67c68c8

@tensorrt-cicd
Copy link
Collaborator

PR_Github #33395 [ run ] completed with state FAILURE. Commit: 67c68c8
/LLM/main/L0_MergeRequest_PR pipeline #25776 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: Shreyas Misra <shreyasm@nvidia.com>
@NVShreyas
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #33398 [ run ] triggered by Bot. Commit: 4acf9d7

@tensorrt-cicd
Copy link
Collaborator

PR_Github #33398 [ run ] completed with state SUCCESS. Commit: 4acf9d7
/LLM/main/L0_MergeRequest_PR pipeline #25779 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

@NVShreyas
Copy link
Collaborator Author

/bot run --disable-fail-fast --reuse-test

@tensorrt-cicd
Copy link
Collaborator

PR_Github #33417 [ run ] triggered by Bot. Commit: 4acf9d7

@tensorrt-cicd
Copy link
Collaborator

PR_Github #33417 [ run ] completed with state SUCCESS. Commit: 4acf9d7
/LLM/main/L0_MergeRequest_PR pipeline #25794 completed with status: 'ABORTED'

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

2 participants