Skip to content

[https://nvbugs/6721558][fix] Only record first token time when collecting perf metrics - #18746

Closed
trtllm-agent wants to merge 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6721558
Closed

trtllm-agent wants to merge 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6721558

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: e11905f5c6 swapped the stateless get_steady_clock_now_in_seconds() for the instance-state self._adjusted_steady_clock.now() at three streaming first-token sites without applying the self._collect_perf_metrics gate it added at the equivalent _extract_metrics read.
  • Fix: Route all three streaming sites through a new _record_server_first_token_time() helper carrying the same _collect_perf_metrics gate as line 1762.
  • Original test: pytest tests/unittest/llmapi/test_llm.py::test_openai_completion_list_prompt_stream_reuses_stream_metadata -v
  • Automated fix generated by repair-bot

Test plan

  • Verify fix on the same GPU type as the original failure
  • Check for regressions in related tests

Links

Reproduction comparison

  • Failed commit: repro_on_failed_commit at 53bb31f
    Signature: AttributeError: 'OpenAIServer' object has no attribute '_adjusted_steady_clock'
  • ToT: repro_on_tot at 17803f6
    Signature: AttributeError: 'OpenAIServer' object has no attribute '_adjusted_steady_clock'
  • Signature relation: needs_agent

Dev Engineer Review

  • Added _record_server_first_token_time() to centralize first-token timestamp recording.
  • The helper checks _collect_perf_metrics, request availability, and existing timestamp state before recording.
  • Chat, completion, and Harmony streaming paths now use the gated helper.
  • Non-streaming metric extraction uses the helper as a fallback.
  • The change prevents ungated _adjusted_steady_clock access and fixes the reported completion-streaming AttributeError regression.
  • No public API, configuration, or test-list changes were identified.
  • The implementation is consistent across streaming paths and avoids duplicate timestamp writes.
  • Verdict: sufficient.

QA Engineer Review

No test files are touched.

…on perf metrics

Commit e11905f replaced the module-level get_steady_clock_now_in_seconds()
with the instance-state read self._adjusted_steady_clock.now() at the three
streaming first-token sites, but only gated the equivalent read in
_extract_metrics on self._collect_perf_metrics. The ungated reads raised
AttributeError on completion streaming and sampled a clock whose value is only
consumed by build_request_metrics_record, which itself runs under
_collect_perf_metrics.

Route all three sites through a _record_server_first_token_time helper carrying
the same gate.

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8439646d-48d6-4cce-b538-ddc1def831c9

📥 Commits

Reviewing files that changed from the base of the PR and between fc8969e and 60086d4.

📒 Files selected for processing (1)
  • tensorrt_llm/serve/openai_server.py

Included review availability: Your plan provides up to 12 included reviews per hour; 9 remain after this review.


Walkthrough

The server centralizes guarded first-token timestamp recording. Chat, completion, Harmony, and non-streaming metric paths now use the shared helper.

Changes

First-token metrics

Layer / File(s) Summary
Timestamp helper and request-path integrations
tensorrt_llm/serve/openai_server.py
The new helper records the first-token timestamp only when metrics are enabled, a request exists, and no timestamp is stored. Streaming and non-streaming paths use the helper.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 60086

This change prevents streaming requests from accessing the performance clock when metrics are disabled while preserving first-token timing when metrics are enabled. The affected request paths are consistently routed through the guarded helper, with no remaining merge-blocking risk identified.

Suggested reviewers: bowenfu

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title follows the required NVBugs and type format and clearly describes the fix to gate first-token timing on performance metrics.
Description check ✅ Passed The description explains the root cause, fix, affected behavior, bug link, reproduction details, and test plan. It uses Summary and Test plan headings instead of the template's Description and Test Co…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@QiJune
QiJune requested a review from JunyiXu-nv September 8, 2026 01:41
@tongyuantongyu tongyuantongyu changed the title [https://nvbugs/6721558][fix] Route all three streaming sites through a new… [https://nvbugs/6721558][fix] Only record first token time when collecting perf metrics Sep 8, 2026
@tongyuantongyu

Copy link
Copy Markdown
Member

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #72083 [ run ] triggered by Bot. Commit: 60086d4 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #72083 [ run ] completed with state FAILURE. Commit: 60086d4
/LLM/main/L0_MergeRequest_PR pipeline #59136 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@JunyiXu-nv

Copy link
Copy Markdown
Collaborator

Original issue has been fixed and test unwaived by #18686

@JunyiXu-nv JunyiXu-nv closed this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants