Skip to content

fix: skip TPOT recording for non-streaming requests - #2167

Merged
ahg-g merged 1 commit into
llm-d:mainfrom
HipHoff:fix-tpot-nonstreaming
Jul 29, 2026
Merged

fix: skip TPOT recording for non-streaming requests#2167
ahg-g merged 1 commit into
llm-d:mainfrom
HipHoff:fix-tpot-nonstreaming

Conversation

@HipHoff

@HipHoff HipHoff commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind bug

What this PR does / why we need it:

For a non-streaming completion, the entire body arrives as one chunk — FirstTokenTimestamp is stamped on that chunk and coincides with ResponseCompleteTimestamp, so RecordRequestTPOT's validity check (!complete.After(firstToken)) fires and logs an error-level Request latency values are invalid for TPOT calculation line on every non-streaming request (~24K lines/day at our modest production traffic, all at error severity — log-indexing cost plus real-error masking). The values aren't invalid; TPOT is simply undefined without inter-token timing.

This PR threads the same streaming flag RecordRequestTTFT already takes into RecordRequestTPOT (same parameter position), returning early — no metric, no log — when the response was not streamed:

  • pkg/epp/metrics/metrics.go: add streaming bool to RecordRequestTPOT; return false before any computation when not streaming.
  • pkg/epp/handlers/response.go: pass reqCtx.modelServerStreaming at the sole call site.
  • pkg/epp/metrics/metrics_test.go: existing cases updated to streaming=true; new subtest asserting the non-streaming shape (complete == firstToken) is skipped without an error.

go build ./pkg/epp/... and go test ./pkg/epp/metrics/... ./pkg/epp/handlers/... pass.

Which issue(s) this PR fixes:

Fixes #2166

Release note (write NONE if no user-facing change):

TPOT is no longer computed or error-logged for non-streaming requests; the per-request "Request latency values are invalid for TPOT calculation" error line is gone for non-streaming workloads.

Disclosure: this PR was authored by Claude (Anthropic's AI assistant, via Claude Code) on behalf of @HipHoff, who reviewed and takes responsibility for the change.

@HipHoff
HipHoff requested a review from a team as a code owner July 24, 2026 06:48
@HipHoff
HipHoff requested review from liu-cong and vMaroon July 24, 2026 06:48
@github-actions github-actions Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 24, 2026
A non-streaming response arrives as a single body chunk, so the
first-token and completion timestamps coincide and RecordRequestTPOT's
validity check logged an error-level 'Request latency values are invalid
for TPOT calculation' line on every non-streaming request. TPOT has no
meaning without inter-token timing, so thread the existing
modelServerStreaming flag through (mirroring RecordRequestTTFT) and skip
recording silently for non-streaming responses.

Fixes llm-d#2166

Signed-off-by: HipHoff <matt.d.hoffman@gmail.com>
@HipHoff
HipHoff force-pushed the fix-tpot-nonstreaming branch from a4e5588 to 6d7e89c Compare July 24, 2026 07:01
@HipHoff

HipHoff commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

/kind bug

@github-actions github-actions Bot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 24, 2026
@ahg-g
ahg-g merged commit 2b8b61e into llm-d:main Jul 29, 2026
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error-level 'Request latency values are invalid for TPOT calculation' logged per non-streaming request (v0.9.0)

2 participants