[Feature]: Separate KV cache token caps for the self-attention and cross-attention pools
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 54/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- backend, performance
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 15.2k
- Forks
- 3k
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 477
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de NVIDIA/TensorRT-LLM
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.xPosiblemente ocupada @NimaVaziri la tomó hoy. AbiertoPytorch
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NVIDIA/TensorRT-LLM#23406 ·
Los mantenedores suelen responder en 1 día
-
Inference runtime Windows
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
NVIDIA/TensorRT-LLM#23394 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: MMLU subsampling changes when evaluators are interleavedPosiblemente ocupada @LeNeLeNeWo la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NVIDIA/TensorRT-LLM#23273 ·
Los mantenedores suelen responder en 1 día
-
Trace-replay Pareto window includes the drain when sessions finish out of admission orderPosiblemente ocupada @sbeierle la tomó hace 3 días. AbiertoTesting
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
NVIDIA/TensorRT-LLM#23077 ·
Los mantenedores suelen responder en 1 día
-
LongBench V2 blog command breaks on inline comments after continuationsPosiblemente ocupada @ddlw la tomó hace 25 días. AbiertoDoc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
NVIDIA/TensorRT-LLM#21879 ·
Los mantenedores suelen responder en 1 día
Todos los issues de NVIDIA/TensorRT-LLM
Issues similares
-
[Resource]: SpaicelyAbiertoresource-submission validation-passed
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
hesreallyhim/awesome-claude-code#3875 · 1 comentario ·
-
[Bug]: Ajax Pro login issueAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
bvis/aegis-hass#725 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
Los mantenedores suelen responder en 1 día