TensorRT-LLMs/cpp/tests/unit_tests/batch_manager
Yueh-Ting (eop) Chen 4882815fa1
[TLLM-6777][feature] Support SWA KV cache reuse OOW block detach (#7922)
This MR is a continuation of #6768. In the previous merge request,
OOW (out-of-window) blocks are only detached when reuse is not enabled,
that is, the block movement behavior is identical between SWA and full
attention when reuse is enabled.

This merge request attempts to enable OOW block detach when reuse is
enabled. The required changes are:

- Let KV cache manager keep track of which block is used by which
  sequence
- Remove restriction for the eviction policy to be able to release a
  non-leaf block

Along with the development, bugs inside freeChildren and offload
mechanism under getFreeBlock is resolved because they will affect the
functionality this merge request is trying to achieve.

When a block goes OOW, it is released from the sequence, it will be
available to be reclaimed and the block is held by the eviction policy
for another sequence to acquire upon calling. On the other hand, we
want to potentially store the sequence for reuse. To safely achieve
this, the record of block ownership is done under
WindowBlockManager::getFreeBlock. If the block acquired was originally
owned by another sequence that is live inside the manager, then we
invalidate the sequence for store for reuse.

At the end of a sequence (when removeSequence is called toward it),
the KV cache manager will check if the sequence has all blocks not
reclaimed by another sequence. If so, then the sequence is safe to
be stored for reuse and store for reuse action will be performed.

Signed-off-by: eopXD <yuehtingc@nvidia.com>
2025-10-13 09:18:12 -07:00
..
blockKeyTest.cpp [None] [ci] Reorganize CMake and Python integration test infrastructure for C++ tests (#6754) 2025-08-24 20:53:17 +02:00
cacheTransBufferTest.cpp [None][feat] Optimize kv cache transfer TEP (#7613) 2025-09-25 20:20:04 -07:00
capacitySchedulerTest.cpp [TRTLLM-6341][feature] Support SWA KV cache reuse (#6768) 2025-09-24 14:28:24 +08:00
CMakeLists.txt [None] [ci] Reorganize CMake and Python integration test infrastructure for C++ tests (#6754) 2025-08-24 20:53:17 +02:00
contextProgressTest.cu fix: remove test relies on timing (#3228) 2025-04-02 18:38:37 +08:00
evictionPolicyTest.cpp Update TensorRT-LLM (#2873) 2025-03-11 21:13:42 +08:00
kvCacheManagerTest.cpp [TLLM-6777][feature] Support SWA KV cache reuse OOW block detach (#7922) 2025-10-13 09:18:12 -07:00
kvCacheUtilsTest.cpp [TRTLLM-6341][chore] Preliminary refactors on the kv cache manager before supporting swa kv cache reuse (#6767) 2025-08-20 13:57:57 +08:00
llmRequestTest.cpp [None] [refactor] Minor cleanup and improvements (#7619) 2025-10-03 11:40:06 +02:00
microBatchSchedulerTest.cpp [TRTLLM-5007][feat] Add multimodal hashing support (image hashing) (#4145) 2025-06-10 01:59:56 +08:00
peftCacheManagerTest.cpp [None] [ci] Reorganize CMake and Python integration test infrastructure for C++ tests (#6754) 2025-08-24 20:53:17 +02:00
staticThreadPoolTest.cpp Update TensorRT-LLM (#2873) 2025-03-11 21:13:42 +08:00