Skip to content

[None][feat] kv cache manager v1 use fabric memory to enable mnnvl transfer for kv cache transfer in disaggregated serving - #12490

Merged
chuangz0 merged 9 commits into
NVIDIA:mainfrom
chuangz0:kv_cache_manager_pool_use_fabric_memory
Jun 30, 2026
Merged

[None][feat] kv cache manager v1 use fabric memory to enable mnnvl transfer for kv cache transfer in disaggregated serving#12490
chuangz0 merged 9 commits into
NVIDIA:mainfrom
chuangz0:kv_cache_manager_pool_use_fabric_memory

Conversation

@chuangz0

@chuangz0 chuangz0 commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added fabric memory allocation support for KV-cache pools to enhance memory management flexibility.
    • Introduced environment variable configuration option to enable fabric memory-backed KV-cache allocation.

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

To see a list of available CI bot commands, please comment /bot help.

@chuangz0
chuangz0 requested a review from a team as a code owner March 24, 2026 08:31
@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #40094 [ run ] triggered by Bot. Commit: 3411faa Link to invocation

@coderabbitai

coderabbitai Bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This pull request introduces fabric memory support for KV-cache pool allocation in TensorRT-LLM. It adds an environment variable flag and integrates FabricMemory into the WindowBlockManager to optionally allocate KV-cache pools using fabric memory instead of standard GPU or UVM allocation paths.

Changes

Cohort / File(s) Summary
KV Cache Manager
cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h, cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp
Added forward declaration for FabricMemory and new member mFabricMemoryPools vector. Modified allocatePools to conditionally allocate primary pools from FabricMemory based on environment config. Updated releasePools to explicitly clear fabric memory pools. Added includes for cacheTransBuffer.h and envUtils.h.
Environment Variable Utilities
cpp/tensorrt_llm/common/envUtils.h, cpp/tensorrt_llm/common/envUtils.cpp
Added new environment-backed accessor function getEnvKVCachePoolUseFabricMemory() to read TRTLLM_KVCACHE_POOL_USE_FABRIC_MEMORY flag with static caching.

Sequence Diagram

sequenceDiagram
    participant Config as Configuration
    participant WBM as WindowBlockManager
    participant FM as FabricMemory
    participant BM as BufferManager
    participant Pool as Pool Storage

    Config->>Config: Read TRTLLM_KVCACHE_POOL_USE_FABRIC_MEMORY
    WBM->>Config: getEnvKVCachePoolUseFabricMemory()
    Config-->>WBM: fabric_enabled (bool)
    
    rect rgba(100, 150, 200, 0.5)
    alt Fabric Memory Enabled
        WBM->>FM: Allocate pool buffer<br/>(size = tensor_volume × dtype_size)
        FM-->>WBM: FabricMemory pointer
        WBM->>WBM: Wrap as ITensor
        WBM->>Pool: Store in mFabricMemoryPools
    else Fallback to Standard
        WBM->>BM: Allocate via managed()/gpuSync()
        BM-->>WBM: Buffer pointer
    end
    end
    
    WBM->>Pool: pool.primaryPtr assignment
    Pool-->>WBM: Pool allocated
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning PR description is incomplete; the author has not filled in the Description or Test Coverage sections, and most PR Checklist items are unchecked despite being required for submission. Fill in the Description section explaining what changes are made and why, provide Test Coverage details listing relevant tests, and review/check the PR Checklist items appropriately before merging.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The PR title clearly describes the main change: adding fabric memory support to the KV cache manager to enable MNNVL transfers for disaggregated serving, which directly aligns with the code changes across all modified files.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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.

Caution

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

⚠️ Outside diff range comments (3)
cpp/tensorrt_llm/common/envUtils.cpp (1)

1-2: ⚠️ Potential issue | 🟡 Minor

Update the modified-file copyright year.

This file changed in 2026, so the header should be bumped from 2022-2024 to 2022-2026.

As per coding guidelines, "Add NVIDIA copyright header on ALL new files, and update year on modified files."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cpp/tensorrt_llm/common/envUtils.cpp` around lines 1 - 2, Update the file
header comment string that currently reads "SPDX-FileCopyrightText: Copyright
(c) 2022-2024 NVIDIA CORPORATION & AFFILIATES." to bump the year range to
"2022-2026" in the top-of-file license block (the SPDX header in envUtils.cpp).
cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp (1)

939-955: ⚠️ Potential issue | 🔴 Critical

Synchronize outstanding work before freeing fabric-backed pools.

mFabricMemoryPools.clear() destroys the external allocation before any stream or transfer-manager fence runs. If a transfer or kernel is still in flight against pool.primaryPtr, this becomes a use-after-free.

💡 Suggested fix
 void WindowBlockManager::releasePools()
 {
+    mTransferManager->syncTransfers();
+    mBufferManager.getStream().synchronize();
     for (auto& pool : mPools)
     {
         if (pool.primaryPtr)
         {
             pool.primaryPtr->release();
@@
         {
             pool.secondaryPtr->release();
         }
     }
-    // Release fabric memory backing (must happen after ITensor release)
+    // Release fabric memory backing after all in-flight work has completed.
     mFabricMemoryPools.clear();
-    mBufferManager.getStream().synchronize();
     mBufferManager.memoryPoolTrimTo(0);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp` around lines 939 - 955, In
WindowBlockManager::releasePools the code clears mFabricMemoryPools before
synchronizing, risking freeing fabric-backed allocations still in use; move the
stream synchronization and memoryPoolTrimTo(0) calls to occur before
mFabricMemoryPools.clear() (i.e., call mBufferManager.getStream().synchronize();
mBufferManager.memoryPoolTrimTo(0); then clear mFabricMemoryPools), ensuring any
in-flight transfers/kernels touching pool.primaryPtr/pool.secondaryPtr complete
before the fabric-backed memory is destroyed.
cpp/tensorrt_llm/common/envUtils.h (1)

1-2: ⚠️ Potential issue | 🟡 Minor

Update the modified-file copyright year.

This header changed in 2026, so the banner should be bumped from 2022-2024 to 2022-2026.

As per coding guidelines, "Add NVIDIA copyright header on ALL new files, and update year on modified files."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cpp/tensorrt_llm/common/envUtils.h` around lines 1 - 2, Update the copyright
banner at the top of cpp/tensorrt_llm/common/envUtils.h: change the
SPDX-FileCopyrightText year range string from "2022-2024" to "2022-2026" so the
header reflects the 2026 modification (look for the comment block starting with
"/*" and the line containing "SPDX-FileCopyrightText: Copyright (c) 2022-2024
NVIDIA CORPORATION & AFFILIATES. All rights reserved.").
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp`:
- Around line 939-955: In WindowBlockManager::releasePools the code clears
mFabricMemoryPools before synchronizing, risking freeing fabric-backed
allocations still in use; move the stream synchronization and
memoryPoolTrimTo(0) calls to occur before mFabricMemoryPools.clear() (i.e., call
mBufferManager.getStream().synchronize(); mBufferManager.memoryPoolTrimTo(0);
then clear mFabricMemoryPools), ensuring any in-flight transfers/kernels
touching pool.primaryPtr/pool.secondaryPtr complete before the fabric-backed
memory is destroyed.

In `@cpp/tensorrt_llm/common/envUtils.cpp`:
- Around line 1-2: Update the file header comment string that currently reads
"SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION &
AFFILIATES." to bump the year range to "2022-2026" in the top-of-file license
block (the SPDX header in envUtils.cpp).

In `@cpp/tensorrt_llm/common/envUtils.h`:
- Around line 1-2: Update the copyright banner at the top of
cpp/tensorrt_llm/common/envUtils.h: change the SPDX-FileCopyrightText year range
string from "2022-2024" to "2022-2026" so the header reflects the 2026
modification (look for the comment block starting with "/*" and the line
containing "SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION &
AFFILIATES. All rights reserved.").

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7ad5e998-6972-4e13-823d-ffc6442cdd48

📥 Commits

Reviewing files that changed from the base of the PR and between e5d8435 and 3411faa.

📒 Files selected for processing (4)
  • cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h
  • cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp
  • cpp/tensorrt_llm/common/envUtils.cpp
  • cpp/tensorrt_llm/common/envUtils.h

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #40094 [ run ] completed with state SUCCESS. Commit: 3411faa
/LLM/main/L0_MergeRequest_PR pipeline #31245 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

Link to invocation

@chuangz0
chuangz0 force-pushed the kv_cache_manager_pool_use_fabric_memory branch from 3411faa to d45c7de Compare March 25, 2026 09:07
@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #40305 [ run ] triggered by Bot. Commit: d45c7de Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #40305 [ run ] completed with state SUCCESS. Commit: d45c7de
/LLM/main/L0_MergeRequest_PR pipeline #31416 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

Link to invocation

@chuangz0
chuangz0 force-pushed the kv_cache_manager_pool_use_fabric_memory branch from d45c7de to 3cadb90 Compare March 30, 2026 06:06
@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #40668 [ run ] triggered by Bot. Commit: 3cadb90 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #40668 [ run ] completed with state FAILURE. Commit: 3cadb90

Link to invocation

@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #40681 [ run ] triggered by Bot. Commit: 3cadb90 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #40681 [ run ] completed with state SUCCESS. Commit: 3cadb90
/LLM/main/L0_MergeRequest_PR pipeline #31711 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

Link to invocation

@chuangz0
chuangz0 force-pushed the kv_cache_manager_pool_use_fabric_memory branch from 3cadb90 to fc8a045 Compare March 31, 2026 03:39
@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #40897 [ run ] triggered by Bot. Commit: fc8a045 Link to invocation

@eopXD eopXD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any test coverage?

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

Link to invocation

ekou24 pushed a commit to ekou24/TensorRT-LLM that referenced this pull request Apr 1, 2026
…rom PR NVIDIA#12490)

Enable MNNVL transfer by setting TRTLLM_KVCACHE_POOL_USE_FABRIC_MEMORY=1.
When enabled, KV cache pools are allocated from FabricMemory instead of
standard GPU allocation.

Signed-off-by: Ethan Kou <ekou@nvidia.com>
Signed-off-by: Ethan Kou <ekou@login-lyris01.lyris.clusters.nvidia.com>
@chuangz0

chuangz0 commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator Author

Any test coverage?

added

@chuangz0
chuangz0 force-pushed the kv_cache_manager_pool_use_fabric_memory branch from 716f1b3 to 2c6fbd8 Compare April 1, 2026 07:04
@chuangz0

chuangz0 commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #41142 [ run ] triggered by Bot. Commit: 2c6fbd8 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #41142 [ run ] completed with state SUCCESS. Commit: 2c6fbd8
/LLM/main/L0_MergeRequest_PR pipeline #32112 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

Link to invocation

@chuangz0
chuangz0 force-pushed the kv_cache_manager_pool_use_fabric_memory branch from 644747e to ff35030 Compare June 26, 2026 05:48
@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "A30-AutoDeploy-1, DGX_B200-AutoDeploy-1, H100_PCIe-AutoDeploy-1, DGX_B200-4_GPUs-PyTorch-Ray-1, DGX_B200-8_GPUs-PyTorch-1, DGX_H100-4_GPUs-PyTorch-Others-1, GB200-8_GPUs-2_Nodes-PyTorch-1"

@chuangz0
chuangz0 force-pushed the kv_cache_manager_pool_use_fabric_memory branch from ff35030 to 7861500 Compare June 29, 2026 02:06
@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "A30-AutoDeploy-1, DGX_B200-AutoDeploy-1, H100_PCIe-AutoDeploy-1, DGX_B200-4_GPUs-PyTorch-Ray-1, DGX_B200-8_GPUs-PyTorch-1, DGX_H100-4_GPUs-PyTorch-Others-1, GB200-8_GPUs-2_Nodes-PyTorch-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56260 [ run ] triggered by Bot. Commit: 7861500 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56260 [ run ] completed with state FAILURE. Commit: 7861500
/LLM/main/L0_MergeRequest_PR pipeline #45118 (Partly Tested) 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

@chuangz0
chuangz0 force-pushed the kv_cache_manager_pool_use_fabric_memory branch from 7861500 to 3121b16 Compare June 29, 2026 08:06
@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "DGX_B200-AutoDeploy-1, H100_PCIe-AutoDeploy-1, DGX_B200-4_GPUs-PyTorch-Ray-1, DGX_B200-8_GPUs-PyTorch-1, DGX_H100-4_GPUs-PyTorch-Others-1, GB200-8_GPUs-2_Nodes-PyTorch-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56333 [ run ] triggered by Bot. Commit: 3121b16 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56333 [ run ] completed with state SUCCESS. Commit: 3121b16
/LLM/main/L0_MergeRequest_PR pipeline #45182 (Partly Tested) 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

@Shixiaowei02

Copy link
Copy Markdown
Collaborator

/bot run --stage-list "DGX_B200-AutoDeploy-1, H100_PCIe-AutoDeploy-1, DGX_B200-4_GPUs-PyTorch-Ray-1, DGX_B200-8_GPUs-PyTorch-1, DGX_H100-4_GPUs-PyTorch-Others-1, GB200-8_GPUs-2_Nodes-PyTorch-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56356 [ run ] triggered by Bot. Commit: 3121b16 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56356 [ run ] completed with state SUCCESS. Commit: 3121b16
/LLM/main/L0_MergeRequest_PR pipeline #45204 (Partly Tested) 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

@chuangz0
chuangz0 force-pushed the kv_cache_manager_pool_use_fabric_memory branch from 3121b16 to 0858b0e Compare June 30, 2026 01:57
@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "H100_PCIe-AutoDeploy-1, DGX_B200-AutoDeploy-1"

chuangz0 added 9 commits June 30, 2026 16:00
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
Signed-off-by: Chuang Zhu <111838961+chuangz0@users.noreply.github.com>
@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "H100_PCIe-AutoDeploy-1, DGX_B200-AutoDeploy-1"

@chuangz0

Copy link
Copy Markdown
Collaborator Author

/bot skip --comment "all related tests have passed"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56556 [ run ] triggered by Bot. Commit: 1c75a23 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56557 [ skip ] triggered by Bot. Commit: 1c75a23 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56556 [ run ] completed with state ABORTED. Commit: 1c75a23

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56557 [ skip ] completed with state SUCCESS. Commit: 1c75a23
Skipping testing for commit 1c75a23

Link to invocation

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.

7 participants