[Feature]: Separate KV cache token caps for the self-attention and cross-attention pools
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 54/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- backend, performance
調査の方向性
Start with _split_kv_cache_budget_for_cross in tensorrt_llm/_torch/pyexecutor/_util.py and the V2 manager in kv_cache/kv_cache_manager_v2.py; trace how each pool applies its byte budget and token cap. Then check the V1 split for compatibility and find the relevant tests and KvCacheConfig.max_tokens description. Done when an optional cross-attention token cap limits that pool while the existing setting and behavior remain intact when it is unset.
索引モデルが issue の本文から書いたものです。
説明
The feature, motivation and pitch
An encoder-decoder model runs with two KV cache pools, one for decoder self-attention and one for cross-attention. KvCacheConfig.max_tokens is a single number and it caps both, under either KV cache manager. _split_kv_cache_budget_for_cross (tensorrt_llm/_torch/pyexecutor/_util.py) gives each pool a share of the memory budget and the same max_tokens. With V2, each pool's manager takes the smaller of its byte budget and the bytes that hold max_tokens (kv_cache/kv_cache_manager_v2.py). With V1, the split caps each pool's token count at the same value. The only setting that differs per pool is cross_kv_cache_fraction, which is a share of a memory budget and not a size.
The two pools need different token counts, and both needs are known in advance:
- Cross-attention: a request holds its encoder output for its whole life. That is the encoder length, whatever the output length.
- Self-attention: a request holds at most the decoder's maximum length, times the beam width.
Whisper is a clear case. Each request holds 1,500 tokens in the cross-attention pool and at most 448 in the self-attention pool. With greedy decoding and 64 concurrent requests, the pools need 96,000 and at most 28,672 tokens. max_tokens must be at least 96,000 to fit the cross-attention pool, so it cannot hold the self-attention pool to its real need. For whisper-large-v3-turbo in fp16, an even split then reserves about 1.8 GiB for a pool that can use at most about 0.55 GiB.
Request: an optional token cap for the cross-attention pool, for example cross_kv_cache_max_tokens.
- When it is set,
max_tokenscaps the self-attention pool only. - When it is unset, behaviour stays as today.
- Each pool holds the smaller of its own token cap and its share of the memory budget.
- The
max_tokensdescription says which pool it caps. Today it reads "The maximum number of tokens that should be stored in the KV cache" and does not say the cap applies to each pool.
Alternatives
max_gpu_total_byteswithcross_kv_cache_fraction. This gives each pool an absolute size, but in bytes and through a ratio. The user has to work out bytes per token for each pool, which depends on layer count, heads, dtype and KV quantization, and redo it when any of them changes. Token counts follow directly from the model and the concurrency.free_gpu_memory_fractionwithcross_kv_cache_fraction. The sizes then depend on the memory that is free at load, so they differ between replicas and with whatever else shares the GPU.- One
max_tokenssized for the larger pool. This over-reserves the other pool, by about 3.3 times for Whisper.
Additional context
- Code references are to main at 9f446f7.
- V1 is deprecated as of 1.4, so the request is mainly for V2.
- Related: #22105, which asks to report the cross-attention pool's statistics.
Before submitting a new issue...
- Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
- 主要言語
- Python
- スター
- 15.2k
- フォーク
- 3k
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 477
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/TensorRT-LLM のほかの issue
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.x対応中かも @NimaVaziri が今日担当しました。 オープンPytorch
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NVIDIA/TensorRT-LLM#23406 ·
メンテナーはふだん 1 日以内に返信
-
Inference runtime Windows
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
NVIDIA/TensorRT-LLM#23394 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: MMLU subsampling changes when evaluators are interleaved対応中かも @LeNeLeNeWo が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NVIDIA/TensorRT-LLM#23273 ·
メンテナーはふだん 1 日以内に返信
-
Trace-replay Pareto window includes the drain when sessions finish out of admission order対応中かも @sbeierle が 3 日前に担当しました。 オープンTesting
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
NVIDIA/TensorRT-LLM#23077 ·
メンテナーはふだん 1 日以内に返信
-
LongBench V2 blog command breaks on inline comments after continuations対応中かも @ddlw が 25 日前に担当しました。 オープンDoc
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
NVIDIA/TensorRT-LLM#21879 ·
メンテナーはふだん 1 日以内に返信
NVIDIA/TensorRT-LLM の issue をすべて見る
似ている issue
-
[Resource]: Spaicelyオープンresource-submission validation-passed
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
hesreallyhim/awesome-claude-code#3875 · コメント 1 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
bvis/aegis-hass#725 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
メンテナーはふだん 1 日以内に返信