TensorRT-LLM icon indicating copy to clipboard operation
TensorRT-LLM copied to clipboard

[Bug]: Encoder-decoder KV V2 gives each pool the full disk_cache_size budget

Open Lewis-panda opened this issue 1 month ago • 0 comments

For encoder-decoder models using KV cache manager V2, build_managers() splits the configured GPU and host budgets between self-attention and cross-attention, but copies disk_cache_size unchanged into both managers. Configuring a 1 GiB disk budget therefore hands out two independent 1 GiB disk-tier quotas. A tested patch splits disk alongside host using the existing offload-budget attribute list, with CPU regression tests.

System Info

  • TensorRT-LLM source: main 9fd891783959eed960a6c58144241db38f9b1580.
  • Python 3.12.3, PyTorch 2.14.0+cu132, x86_64 Linux.
  • Real package imports/native dependencies from 1.4.0rc1.dev202610140007; native build da676ffb8b611a1a0a83c862aa094e736f9fe5aa is 39 commits behind the Python source.
  • CPU configuration/construction-path reproduction; CUDA hidden. No model, GPU inference, disk allocation, or disk exhaustion was exercised.

Information

  • [ ] The official example scripts
  • [x] My own modified scripts

Tasks

  • [x] My own task or dataset: configuration-only reproduction, no model/data required.

Reproduction

from tempfile import TemporaryDirectory
from tensorrt_llm._torch.pyexecutor._util import KvCacheCreator
from tensorrt_llm.llmapi.llm_args import KvCacheConfig

with TemporaryDirectory() as directory:
    config = KvCacheConfig(
        use_kv_cache_manager_v2=True,
        cross_kv_cache_fraction=0.25,
        disk_cache_size=1 << 30,
        disk_cache_path=directory,
    )
    creator = KvCacheCreator.__new__(KvCacheCreator)
    creator._kv_cache_config = config
    self_cfg, cross_cfg = creator._split_kv_cache_budget_for_cross()
    print(config.disk_cache_size, self_cfg.disk_cache_size, cross_cfg.disk_cache_size)

Current output: 1073741824 1073741824 1073741824. With the patch: 1073741824 805306368 268435456.

Expected behavior

The self/cross disk quotas should divide the configured disk budget according to cross_kv_cache_fraction, preserving the integer total and leaving the original config unchanged, like the host-budget split.

actual behavior

Both cloned configs retain the full disk budget. Each V2 manager independently creates a DiskCacheTierConfig(quota=disk_cache_size). Native disk slot pools have independent temporary files and preallocate their assigned slots using posix_fallocate; sharing disk_cache_path does not share a quota.

This is a duplicated logical budget. Actual filesystem usage is additionally subject to existing per-pool minimums and allocation rounding (2 MiB for disk), so this report does not claim an exact byte cap or a measured ENOSPC failure.

additional notes

  • Proposed change: apply _OFFLOAD_TIER_BUDGET_ATTRS (host_cache_size, disk_cache_size) to the self/cross split, as the target/draft split already does. No public configuration/schema changes.
  • Focused real-import CPU A/B: 6 failed / 12 passed before; 18 passed after, using identical regression-test source. Cases cover odd byte totals, fractional shares including 0/1, None/zero, construction-path propagation, estimation probes, and composition with target/draft splitting.
  • Full dual-pool and model-config suites: 75 passed. Pre-commit checks pass. The existing CPU CI entry collects unittest/_torch/executor.
  • A broader draft-budget run had 8 fixture failures; all 8 also fail unchanged upstream with missing _cache_transceiver_config / _is_kv_cache_manager_v2 attributes. They are outside this patch.
  • Checked related #17850, #19744, #19302 and current changed-file lists for #20178, #20048, #19650; none includes this correction.

Per CONTRIBUTING, may I submit this focused fix for review?

  • [x] I searched relevant issues and PRs and checked the source and documentation.

Lewis-panda avatar Oct 14 '26 18:10 Lewis-panda