TensorRT-LLMs/examples/models/core
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
..
bert Adding local paths to the datasets to make them loadable in offline mode (#3750) 2025-04-25 03:51:00 +08:00
commandr Doc: Update invalid hugging face URLs (#5683) 2025-07-04 13:14:13 +08:00
deepseek_v3 [None] [doc] Update DeepSeek example doc (#7358) 2025-09-01 14:43:58 -04:00
enc_dec [TRTLLM-6420][feat] add support for Eclairv2 model - cherry-pick changes and minor fix (#6493) 2025-08-08 21:40:48 -04:00
exaone doc: update EXAONE 4.0 news (#6034) 2025-07-15 10:26:51 +09:00
gemma [https://nvbugs/5522332][fix] Pin numpy version for Gemma. (cherry-pick https://github.com/NVIDIA/TensorRT-LLM/pull/7783) (#7797) 2025-09-19 18:50:40 +08:00
glm-4-9b Doc: Update invalid hugging face URLs (#5683) 2025-07-04 13:14:13 +08:00
gpt Doc: Update invalid hugging face URLs (#5683) 2025-07-04 13:14:13 +08:00
gpt_oss [None][feat] support gpt-oss with fp8 kv cache (#7612) 2025-09-15 02:17:37 +08:00
granite move the reset models into examples/models/core directory (#3555) 2025-04-19 20:48:59 -07:00
internlm2 Doc: Update invalid hugging face URLs (#5683) 2025-07-04 13:14:13 +08:00
kimi_k2 [None][doc] Add K2 tool calling examples (#6667) 2025-08-11 16:25:41 +08:00
llama [TRTLLM-6341][feature] Support SWA KV cache reuse (#6768) 2025-09-24 14:28:24 +08:00
llama4 [None][doc] Add deployment guide section for VDR task (#6669) 2025-08-07 10:30:47 -04:00
mamba Doc: Update invalid hugging face URLs (#5683) 2025-07-04 13:14:13 +08:00
mixtral [None][fix] Upgrade dependencies version to avoid security vulnerability (#6506) 2025-08-06 14:21:03 -07:00
mllama doc: fix path after examples migration (#3814) 2025-04-24 02:36:45 +08:00
multimodal [https://nvbugs/5453709][fix] Remove transformers version limit in Qwen2VL (#7152) 2025-09-09 10:38:20 +08:00
nemotron Doc: Update invalid hugging face URLs (#5683) 2025-07-04 13:14:13 +08:00
nemotron_nas doc: fix path after examples migration (#3814) 2025-04-24 02:36:45 +08:00
phi Doc: Update invalid hugging face URLs (#5683) 2025-07-04 13:14:13 +08:00
qwen [None][fix] fix load_model_on_cpu on qwen/convert_checkpoint.py (#2382) 2025-09-18 21:54:26 -07:00
qwen2audio [TRTLLM-6341][feature] Support SWA KV cache reuse (#6768) 2025-09-24 14:28:24 +08:00
qwenvl feat: nanobind bindings (#6185) 2025-07-21 08:56:57 +01:00
recurrentgemma Doc: Update invalid hugging face URLs (#5683) 2025-07-04 13:14:13 +08:00
vit doc: fix path after examples migration (#3814) 2025-04-24 02:36:45 +08:00
whisper Doc: Update invalid hugging face URLs (#5683) 2025-07-04 13:14:13 +08:00