-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Mass-integration 0.20 to main #4577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5b2559a
chore: Remove unused script (#4485)
kaiyux 557ca3d
tests: update api change from decoder to sampler in test (#4479)
crazydemo b927097
docs: Add KV Cache Management documentation (#3908)
Funatiq 02e937e
fix: [TRTLLM-325]WAR against security vulnerabilities in Python packa…
MartinMarciniszyn 803db85
fix: cleanup process tree for disaggregated test (#4116)
tongyuantongyu 259b479
[5141290][5273694][5260696] fix: Fix mrope argument missing issue in …
hyukn abd98bf
chore: Deprecate autopp. (#4471)
yuxianq 18678d2
[5234029][5226211] chore: Unwaive multimodal tests for Qwen model. (#…
hyukn 93a1684
test(perf): Extend the Llama-Nemotron-Nano-8B perf-integration-tests …
venkywonka bc08802
test: fix for perf sanity test and skip fp8 deepseek blackwell cases …
ruodil bc17db5
ci: waive testcase [NVBUG 5297821] (#4616)
stnie 7a59e43
[CI] Waive known errors with test TestDeepSeekV3Lite::test_fp8_block_…
SimengLiu-nv b1f22d7
[TR[TLLM-4618][feat] Add remaining NVFP4 Nemotron Super 49B test on R…
farazkh80 06e438b
[fix] Incorrect mocker argument for a CLI accuracy test in Llama-3.3-…
moraxu 0ed64a8
Add missing rcca folder (#4591)
Tabrizian fa1f0a8
[5180961] chore: Unwaive test for Qwen model. (#4524)
hyukn 60f173d
[TRTLLM-4932] Add CLI accuracy tests for Llama-3_3-Nemotron-Super-49B…
moraxu 33ac282
[fix] Fix Llama4 allgather error due to None tensor (#4511)
jinyangyuan-nvidia ff60c2e
[TRTLLM-4932] Add QA accuracy tests for NIM-prioritized models (#4242)
moraxu fb9bfbb
Add tritonrelease container (#4544)
Tabrizian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,9 @@ | ||
| # These vulnerabilities were inherited from the base image (pytorch:25.05-py3) and should be removed when the base image | ||
| # is updated. | ||
|
|
||
| # WAR against https://github.com/advisories/GHSA-vqfr-h8mv-ghfj | ||
| h11>=0.16.0 | ||
| # WAR against https://github.com/advisories/GHSA-7cx3-6m66-7c5m | ||
| tornado>=6.5.0 | ||
| # WAR against https://github.com/advisories/GHSA-5rjg-fvgr-3xxf | ||
| setuptools>=78.1.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| (kv-cache-management)= | ||
|
|
||
| # KV Cache Management: Pools, Blocks, and Events | ||
|
|
||
| This document provides an overview of the internal hierarchy and event system for paged KV cache management, as implemented in the TensorRT-LLM codebase. | ||
|
|
||
| For more information on KV cache reuse see [KV cache reuse](kv-cache-reuse.md). | ||
|
|
||
| --- | ||
|
|
||
| ## Hierarchy: Pool, Block, and Page | ||
|
|
||
| ### **Block** | ||
| - **Definition:** The smallest unit of KV cache allocation. A `KVCacheBlock` holds metadata (not the actual data) for a chunk of KV cache. | ||
| - **Purpose:** Each block represents a fixed number of tokens' worth of KV data (can be specified by `tokens_per_block` parameter). | ||
| - **Usage:** Blocks are allocated, reused, or evicted as sequences are processed. | ||
|
|
||
| ### **Page** | ||
| - **Definition:** In this codebase, "page" is often used interchangeably with "block" (as in "paged KV cache"), but technically, a page could refer to a memory page (hardware-level), while a block is a logical unit for the cache. | ||
| - **In Practice:** The code uses "block" as the main unit; "page" is not a distinct class or struct. | ||
|
|
||
| ### **Pool** | ||
| - **Definition:** A pool is a contiguous memory buffer (or set of buffers) that holds the actual KV data for one or more layers. | ||
| - **Types:** There are primary pools (fast GPU memory) and secondary pools (slower, e.g., CPU or offload memory). | ||
| - **Organization:** Each pool can serve multiple layers that share the same KV head configuration. Pools are managed by `KVCacheBlockPool` and tracked in vectors in `WindowBlockManager`. | ||
| - **Block ↔ Pool:** Each block is an index into a pool; the pool provides the actual storage, while the block is the metadata handle. | ||
|
|
||
| ### **WindowBlockManager/BlockManager** | ||
|
|
||
| TRT-LLM supports 2 complex features related to KV cache management: | ||
| 1. **Variable Group-Query Attention (VGQA)** - i.e. a different `num_kv_heads` value for different layers. | ||
| 2. **Variable Sliding Window Attention (VSWA)** - i.e. a different `attention_window_size` value for different layers. | ||
|
|
||
| In order to support both of these features, the pool management works as described below. | ||
|
|
||
| But in the simple, *most common case*, for most models, where | ||
| 1. [MHA/MQA/Non-variable GQA](gpt-attention.md#multi-head-multi-query-and-group-query-attention), i.e., same `num_kv_heads` value for all layers, | ||
| 2. Global attention/[SWA](gpt-attention.md#sliding-window-attention-cyclic-rolling-buffer-kv-cache), i.e., same `attention_window_size` value for all layers, | ||
|
|
||
| only a *single* pool will be created within the structure described below. | ||
|
|
||
| #### KV Cache Pool Management | ||
|
|
||
| - **WindowBlockManager:** Manages blocks and pools for a specific attention window size. Within a `WindowBlockManager`, there can be multiple pools - each corresponding a unique number of KV heads - i.e., to support VGQA. | ||
| - **BlockManager:** Manages all `WindowBlockManager` instances, one per unique window size. | ||
|
|
||
| **Hierarchy Summary:** | ||
| - **Pool** (memory buffer for KV data) | ||
| - Contains many blocks. | ||
| - **Blocks** (metadata for a chunk of the pool, each block = `tokens_per_block` tokens) | ||
| - (Optionally, blocks can be swapped between primary/secondary pools.) | ||
| - **BlockManager/WindowBlockManager**: Manage pools and blocks, handle allocation, reuse, and eviction. | ||
|
|
||
| --- | ||
|
|
||
| ## Events in `KVCacheEventManager` | ||
|
|
||
| The `KVCacheEventManager` is responsible for tracking and reporting significant changes in the state of the KV cache. Events are used for logging, debugging, or possibly for external monitoring. | ||
|
|
||
| ### **Types of Events** | ||
| - **Created Event:** When pools or blocks are created/allocated. | ||
| - **Updated Event:** When a block's state changes (e.g., moved between primary/secondary, priority updated). | ||
| - **Removed Event:** When a block is removed from the cache (evicted or released). | ||
| - **Stored Event:** When blocks are stored for potential reuse (e.g., after a sequence finishes and its blocks are reusable). | ||
|
|
||
| ### **What Triggers an Event?** | ||
| - **Allocation/Deallocation:** Creating or freeing memory pools or blocks. | ||
| - **Eviction/Reuse:** When a block is evicted, reused, or its priority changes. | ||
| - **Block Movement:** When a block is moved between memory levels (primary ↔ secondary). | ||
| - **Block Storage:** When blocks are stored for future reuse (e.g., after a sequence completes). | ||
|
|
||
| **In summary:** | ||
| An "event" is any significant change in the lifecycle or state of a KV cache block or pool, tracked for monitoring, debugging, or optimization purposes. | ||
|
|
||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
examples/disaggregated/clients/template_trtllm_openai_completions.json
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.