[AR-Diffusion] Allocate K and V separately so the compiled path stops cloning the pool (#6463)

Signed-off-by: linzhenpl07 <linzhenpl07@gmail.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
linzhenpl07andClaude Sonnet 5 authored and GitHub committed 2026-09-07 11:40:20 +08:00
1 parent 2df95de421
commit 38abc0ba28
5 files changed
+365 -19

No files matched your search

@@ -350,7 +350,9 @@ class ARDiffusionKVCache:
self.null_block_id = self.manager.block_pool.null_block.block_id
# Allocate the per-layer paged K/V pools on the given device.
self._kv_pools: list[torch.Tensor] = []
# Per layer, ``[k_cache, v_cache]`` -- separate allocations; see
# allocate_kv_pool_with_views for why they are not one tensor.
self._kv_pools: list[list[torch.Tensor]] = []
self._k_pools: list[torch.Tensor] = []
self._v_pools: list[torch.Tensor] = []
if device is not None: