[Bug] /v1/responses does not populate /perf_metrics request entries
[Bug] /v1/responses does not populate /perf_metrics request entries
Description
trtllm-serve exposes /perf_metrics for completed request-level performance metrics. In a current source checkout (c2e0379fb3988b1b7f97fcf6441685f189b805ff), static inspection shows the chat/completions and completions handlers call _extract_metrics(...) after generation, while the Responses API success paths return without an equivalent metrics extraction call.
On an A100 using the official TensorRT-LLM container nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc14, successful /v1/chat/completions and /v1/completions requests produced /perf_metrics entries, but successful /v1/responses requests did not. The same gap reproduced across three non-streaming request orders, repeated /v1/responses requests, streaming /v1/responses, and postprocess-worker mode.
Why this matters
The Responses API is an OpenAI-compatible serving endpoint. Operators using /perf_metrics for latency, KV-cache metrics, or per-request diagnostics may silently miss all /v1/responses traffic. In the same runtime pass, Prometheus request counters also did not advance for /v1/responses while they advanced for chat/completions and completions.
Environment
- TensorRT-LLM source commit inspected:
c2e0379fb3988b1b7f97fcf6441685f189b805ff - TensorRT-LLM runtime version:
1.3.0rc14 - Runtime container:
nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc14 - Container digest:
sha256:da677289043b8e41b734962bca1f52991ff6eed945a603cb99dec521ca6b25d2 - Driver/CUDA: NVIDIA driver
580.126.20, CUDA13.0 - Python: 3.12.3 in the container
- Model:
TinyLlama/TinyLlama-1.1B-Chat-v1.0 - Backend: PyTorch
- Server command:
sudo docker run --rm --name trtllm_metrics_8000_enabled --gpus all --ipc host --ulimit memlock=-1 --ulimit stack=67108864 -p 127.0.0.1:8000:8000 -v "$PWD/artifacts:/artifacts" -v "$HF_CACHE:/root/.cache/huggingface" -e HF_HOME=/root/.cache/huggingface -e TRTLLM_NO_USAGE_STATS=1 -e TOKENIZERS_PARALLELISM=false nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc14 trtllm-serve serve TinyLlama/TinyLlama-1.1B-Chat-v1.0 --host 0.0.0.0 --port 8000 --backend pytorch --tp_size 1 --num_postprocess_workers 0 --no-telemetry --config /artifacts/reducer/serve_enabled_config.yaml
- Perf metrics config:
return_perf_metrics: true
perf_metrics_max_requests: 50
enable_iter_perf_stats: true
enable_iter_req_stats: true
kv_cache_config:
enable_block_reuse: true
iteration_stats_interval: 1
Reproduction
- Start
trtllm-servewith request perf metrics enabled using the command/config above. - Call
GET /perf_metricsand save the baseline. - Send a successful
/v1/chat/completionsrequest. - Call
GET /perf_metricsand observe a new request metric entry. - Send a successful
/v1/responsesrequest. - Call
GET /perf_metricsand observe no corresponding new request metric entry. - Repeat with request order changed and repeated
/v1/responsesrequests.
Minimal repro payloads:
// /v1/chat/completions
{"model":"TinyLlama/TinyLlama-1.1B-Chat-v1.0","messages":[{"role":"user","content":"Return exactly: TRTLLM_METRICS_TEST"}],"temperature":0,"max_tokens":8,"stream":false}
// /v1/responses
{"model":"TinyLlama/TinyLlama-1.1B-Chat-v1.0","input":"Return exactly: TRTLLM_METRICS_TEST","temperature":0,"max_output_tokens":8,"stream":false}
Expected behavior
Successful /v1/responses requests should populate request-level perf metrics consistently with /v1/chat/completions and /v1/completions, unless the endpoint is explicitly documented as unsupported for perf metrics.
Actual behavior
All three endpoint requests below returned HTTP 200. /perf_metrics was drained before each request to make the per-request delta explicit.
| Endpoint | Status | /perf_metrics after request |
Request/response id |
|---|---|---|---|
/v1/chat/completions |
200 | 1 entry | request_id 11, response id chatcmpl-e841acc4c0384fc1a5d1ece1f808bba9 |
/v1/completions |
200 | 1 entry | request_id 12, response id cmpl-a0afd0c1f1d24460bc735daac1281aba |
/v1/responses |
200 | 0 entries | response id resp_7977c4c851234fa5aaebfce0b438df26 |
Minimal /perf_metrics snapshots:
// before chat
[]
// after chat, abbreviated
[
{
"request_id": 11,
"perf_metrics": {
"first_iter": 82,
"last_iter": 89,
"timing_metrics": {
"arrival_time": 1820.188952,
"first_scheduled_time": 1820.190359,
"first_token_time": 1820.219348,
"last_token_time": 1820.241873
},
"kv_cache_metrics": {
"num_total_allocated_blocks": 1,
"num_new_allocated_blocks": 1,
"num_reused_blocks": 1,
"num_missed_blocks": 0
}
}
}
]
// before responses
[]
// after responses
[]
Prometheus request counters also advanced for chat/completions and completions but not for responses in the same order-A run:
| Endpoint | trtllm_request_success_total delta |
trtllm_prompt_tokens_total delta |
trtllm_generation_tokens_total delta |
|---|---|---|---|
/v1/chat/completions |
1 | 30 | 8 |
/v1/completions |
1 | 15 | 8 |
/v1/responses |
0 | 0 | 0 |
Source notes
Current source checkout: c2e0379fb3988b1b7f97fcf6441685f189b805ff.
/perf_metricsis registered inOpenAIServer.register_routes()attensorrt_llm/serve/openai_server.py:566-579.return_perf_metricsis defined attensorrt_llm/llmapi/llm_args.py:3063-3065;perf_metrics_max_requestsis defined attensorrt_llm/llmapi/llm_args.py:3067-3071.self.perf_metricsis initialized inOpenAIServer.__init__attensorrt_llm/serve/openai_server.py:211-213and created in_init_llm()attensorrt_llm/serve/openai_server.py:383-411._extract_metrics()appends{request_id, perf_metrics, time_breakdown_metrics}toself.perf_metricsattensorrt_llm/serve/openai_server.py:930-954.- Chat non-streaming calls
_extract_metrics()through_create_chat_response()attensorrt_llm/serve/openai_server.py:956-979;openai_chat()returns that path attensorrt_llm/serve/openai_server.py:1176-1184. - Chat streaming calls
_extract_metrics()after the stream is consumed attensorrt_llm/serve/openai_server.py:1032-1056. - Completions non-streaming calls
_extract_metrics()attensorrt_llm/serve/openai_server.py:1297-1313. - Completions streaming calls
_extract_metrics()attensorrt_llm/serve/openai_server.py:1345-1356. - Responses non-streaming returns
JSONResponse(content=response.model_dump())attensorrt_llm/serve/openai_server.py:1719-1721; the nestedcreate_response()returnsResponsesResponseattensorrt_llm/serve/openai_server.py:1598-1619. I found no_extract_metrics()call on that path. - Responses streaming returns
StreamingResponse(content=create_streaming_generator(...))attensorrt_llm/serve/openai_server.py:1715-1718;create_streaming_generator()emits events attensorrt_llm/serve/openai_server.py:1621-1635. I found no_extract_metrics()call there either. - Prometheus request metrics are fed by
_extract_metrics()viaself.metrics_collector.log_request_metrics_dict(...)attensorrt_llm/serve/openai_server.py:917-925andtensorrt_llm/metrics/collector.py:471-541. - I found Responses API tests in
tests/unittest/llmapi/apps/_test_openai_responses.py:92-287, but no/perf_metricsassertion for/v1/responses. Existing/perf_metricsunit coverage is completions-only intests/unittest/llmapi/apps/_test_openai_perf_metrics.py:54-101.
Controls
- Perf metrics disabled: with no perf metrics config, all three endpoints returned 200 and
/perf_metricsremained empty. This confirms the positive-control entries require the metrics config. - Buffer control:
perf_metrics_max_requests=50with a nine-request matrix; no eviction should occur. Chat/completions and completions produced entries, Responses did not. - Repeated chat positive control: three non-streaming chat requests returned 200 and produced request IDs
24,25, and26. - Repeated responses target control: three non-streaming Responses requests returned 200 with response IDs
resp_713cc4ede5c44320957ce61c50f86926,resp_ac29b23170bf4c50b931c2d2d16deabf, andresp_eb7f74ade1c74096890ec8e8d78feee5;/perf_metricsreturned zero entries after each. - Request order controls: the gap reproduced in
chat -> completions -> responses,responses -> chat -> completions, andcompletions -> responses -> chat. - Streaming control: streaming chat and completions produced entries; streaming Responses returned 200 and produced no entry.
- Postprocess worker control: with
--num_postprocess_workers 2, the non-streaming matrix reproduced the same result, so the gap was not caused by the default no-worker setting.
Duplicate search
I searched open and closed issues/PRs for:
Responses API perf_metrics, responses perf_metrics, openai_responses _extract_metrics, /v1/responses /perf_metrics, Responses API metrics missing, return_perf_metrics responses, request_perf_metrics responses, Responses API Prometheus metrics, perf_metrics OpenAI responses, TensorRT-LLM responses metrics, and tensorrt_llm openai_responses metrics.
I also inspected nearby metrics and Responses API PRs/issues, including #6985, #8005, #9140, #12545, #13264, #12637, #12868, #12889, #7341, #7600, #9946, #10030, #10104, #12719, #12746, #13779, and #9256. I did not find an exact duplicate.
AI assistance disclosure
AI assistance was used to help prepare this investigation. The human submitter reviewed the commands, logs, artifacts, and conclusions.
@glaziermag , I would like to work on this
@glaziermag , I would like to work on this
Thanks for your interest. I'm not an official maintainer, but I’m not opposed to it.
@glaziermag , I would like to work on this
Thanks for your interest. I'm not an official maintainer, but I’m not opposed to it.
@glaziermag Understood, thanks for the clarification and for the response! I’ll take a look into the issue and see if I can come up with a fix. If I’m able to resolve it, shall I open a PR for this?
Fine with me, thanks!
Great, thanks! I’ll start working on it.
Update on the current state of this issue:
The missing metrics extraction on the Responses API paths was fixed as part of #16668 — openai_responses now calls _extract_metrics on both the non-streaming path (create_response) and the streaming path (create_streaming_generator):
https://github.com/NVIDIA/TensorRT-LLM/blob/40bee2a8/tensorrt_llm/serve/openai_server.py#L2804
https://github.com/NVIDIA/TensorRT-LLM/blob/40bee2a8/tensorrt_llm/serve/openai_server.py#L2821
What was still missing is test coverage: tests/unittest/llmapi/apps/_test_openai_perf_metrics.py only exercised /v1/completions, so a regression on /v1/responses would go unnoticed. I opened #18856 adding non-streaming and streaming /v1/responses perf-metrics tests to that file, which should close this issue once merged.
@DhineshPonnarasan — I did not see a PR linked here since May, so I went ahead with the test coverage; if you have something in flight that overlaps, let me know and I'm happy to adjust.