TensorRT-LLMs/cpp/tests/unit_tests/executor
Yueh-Ting (eop) Chen cf100933cc
[TRTLLM-6341][feature] Support SWA KV cache reuse (#6768)
This merge request attempts to support more SWA KV cache functionality
inside the KV cache manager. Before this merge request, the KV cache for
sliding window attention (SWA) only holds "window size" number of blocks
and reuse them in a cyclic manner. We will not be able to utilize more
GPU memory with this design, leading to a limited max batch size
throughput. Additionally, we will not be able to support KV cache reuse
with this design.

In this MR, we change such behavior to let the manager write blocks in
a linear manner. With a linear block writing behavior, as the attention
window moves on, the out-of-window (OOW) blocks will be detached. Right
now for the sake of a correct feature first, we directly offload the
OOW block from the primary block pool (GPU memory) to the secondary
block pool (host memory). We will improve this in the future by
delegating the block movement to the eviction policy.

KV cache reuse for SWA is not developed in this merge request and will
be amended in a follow-up merge request.

Writing the blocks linearly, the maximum number of blocks allocated for
a sequence(`GenerationRequest`) is the "max sequence length" specified.
The `GenerationRequest` that stores the cache block bookkeeping
structure will now keep "max sequence length" tokens of blocks.

Given the above, main changes are (more context in the MR):
- Remove "cyclic" concept under the kv cache manager, such concept
  originally guards the block reuse under kv cache manager.
- Add detach mechanism and have it under `KVCacheManager::addToken`.
  Please note that detach is still guarded off for SWA when reuse
  is enabled. A follow-up merge request will proceed to improve this.
- Enforce "max sequence length" to be a non-optional parameter to
  the `KVCacheManager`/`BlockManager`
- Let all window size resource pool get identical proportion of memory
- Fix free memory calculation under `resource_manager.py`

Signed-off-by: eopXD <yuehtingc@nvidia.com>
Co-authored-by: Tomer Asida <tasida@nvidia.com>
2025-09-24 14:28:24 +08:00
..
agentCommTest.cpp [TRTLLM-6341][feature] Support SWA KV cache reuse (#6768) 2025-09-24 14:28:24 +08:00
CMakeLists.txt Agent interface impl for NIXL (#4125) 2025-05-22 09:09:41 +08:00
decodingConfigTest.cpp Update TensorRT-LLM (#2873) 2025-03-11 21:13:42 +08:00
dynamicBatchTunerTest.cpp Update TensorRT-LLM (#2873) 2025-03-11 21:13:42 +08:00
executorConfigTest.cpp Update TensorRT-LLM (#2873) 2025-03-11 21:13:42 +08:00
executorTestSmall.cpp [https://nvbugs/5501557][fix] Fix out-of-bounds vector access for model with multiple layer types (#7636) 2025-09-22 14:28:38 +08:00
executorTestSmallArbitraryOutputTensors.cpp refactor: remove TrtGptModelOptionalParams (#5165) 2025-06-20 10:31:40 +02:00
intervalSetTest.cpp Update TensorRT-LLM (#2873) 2025-03-11 21:13:42 +08:00
kvCacheConfigTest.cpp Update TensorRT-LLM (#2873) 2025-03-11 21:13:42 +08:00
loraConfigTest.cpp [TRTLLM-6683][feat] Support LoRA reload CPU cache evicted adapter (#6510) 2025-08-07 09:05:36 +03:00
requestTest.cpp [TRTLLM-5007][feat] Add multimodal hashing support (image hashing) (#4145) 2025-06-10 01:59:56 +08:00
requestWithIdTest.cpp Update TensorRT-LLM (#2873) 2025-03-11 21:13:42 +08:00
responseTest.cpp Update TensorRT-LLM (#2873) 2025-03-11 21:13:42 +08:00
samplingConfigTest.cpp Feat: Variable-Beam-Width-Search (VBWS) part4 (#3979) 2025-05-12 22:32:29 +02:00
serializeUtilsTest.cpp [TRTLLM-7361][feat] KV cache transfer for uneven pp (#7117) 2025-09-08 13:37:46 -04:00
tensorTest.cpp Update TensorRT-LLM (#2873) 2025-03-11 21:13:42 +08:00
transferAgentTest.cpp [None][feat] Nixl support for GDS (#5488) 2025-09-09 13:00:38 +08:00
ucxCommTest.cpp [TRTLLM-8044][refactor] Rename data -> cache for cacheTransceiver (#7659) 2025-09-16 08:43:56 -04:00