[Feature]: Report the cross-attention KV cache pool in the Triton backend metrics and in the JSON iteration stats

Abierto
#22,105 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Epsilon006 ya está trabajando en esto.

Desde el 13/11/2026.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp, python

Línea de trabajo

Start with the stats loop in triton_backend/inflight_batcher_llm/src/model_instance_state.cc, the metric definitions in custom_metrics_reporter.{h,cc}, and the IterationStats serializer in cpp/tensorrt_llm/executor/jsonSerialization.cpp. Read the existing kvCacheStats handling and check related tests for both output paths. Done means cross-attention stats are reported separately when present and omitted for decoder-only engines.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Triton backend
The feature, motivation and pitch

For an encoder-decoder engine the executor creates two paged KV cache pools, one for self-attention and one for cross-attention (trtGptModelInflightBatching.cpp, the useCrossAttention() branch of the constructor). For those engines getCurrentIterationStats fills the optional IterationStats::crossKvCacheStats next to kvCacheStats. For a decoder-only engine there is no cross-attention pool and the field stays empty.

The Python bindings expose the field (cross_kv_cache_stats). The two paths that leave the process do not:

  • Triton backend. The stats loop in triton_backend/inflight_batcher_llm/src/model_instance_state.cc reads stat.kvCacheStats only. So nv_trt_llm_kv_cache_block_metrics describes the self-attention pool alone, and nothing describes the cross-attention pool.
  • JSON iteration stats. The IterationStats serializer in cpp/tensorrt_llm/executor/jsonSerialization.cpp lists kvCacheStats and not crossKvCacheStats. So to_json_str() and the /metrics route of trtllm-serve do not carry it.

Why it matters for an encoder-decoder engine:

  • A request holds its encoder output in the cross-attention pool for its whole life. That pool can be the one that runs out first. When it does, the only exported cache metric describes the other pool and can read nearly empty.
  • Each pool is sized as the smaller of max_tokens_in_paged_kv_cache and its share of free GPU memory at load. The cross-attention pool can come out smaller than configured, and its capacity is not reported anywhere.

Request: when crossKvCacheStats has a value, report it on both paths.

A sketch, not compiled:

  1. In model_instance_state.cc, next to the existing kvCacheStats block, append the same fields from stat.crossKvCacheStats under distinct keys.
  2. In custom_metrics_reporter.{h,cc}, add a metric family for them with the same kv_cache_block_type label values. A separate family leaves the existing one unchanged, and it is simply absent for decoder-only engines.
  3. In jsonSerialization.cpp, add crossKvCacheStats to the IterationStats serializer.
Alternatives
  • Reading cross_kv_cache_stats through the Python bindings. That works only for code inside the process that owns the executor, so not for a Triton deployment.
  • Inferring a full cross-attention pool from the request metrics (active against scheduled). That shows a symptom and not which pool caused it.
  • Adding the cross-attention values as extra kv_cache_block_type label values on the existing family. That changes what the existing family means for anyone who aggregates it.
Additional context
  • Code references are to v1.2.1. The backend's stats loop is the same in v1.3.0rc1.
Lenguaje dominante
Python
Estrellas
15.2k
Forks
3k
Merge medio
2 d 21 h
PR fusionados (30 d)
477

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NVIDIA/TensorRT-LLM

Todos los issues de NVIDIA/TensorRT-LLM

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.