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

オープン
#22,105 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Epsilon006 がすでに取り組んでいます。

2026年11月13日 から。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
Python
スター
15.2k
フォーク
3k
平均マージ
2日 21時間
マージ済み PR(30日)
477

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/TensorRT-LLM のほかの issue

NVIDIA/TensorRT-LLM の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。