Skip to content

[None][feat] Weight trtllm-bench AR/AL averages by output length#14998

Open
zhaoyangwang-nvidia wants to merge 1 commit into
NVIDIA:mainfrom
zhaoyangwang-nvidia:feature/bench-ar-al-length-weighted
Open

[None][feat] Weight trtllm-bench AR/AL averages by output length#14998
zhaoyangwang-nvidia wants to merge 1 commit into
NVIDIA:mainfrom
zhaoyangwang-nvidia:feature/bench-ar-al-length-weighted

Conversation

@zhaoyangwang-nvidia
Copy link
Copy Markdown
Collaborator

@zhaoyangwang-nvidia zhaoyangwang-nvidia commented Jun 5, 2026

When requests produce different output lengths, an equally-weighted mean over per-request acceptance rate (AR) and acceptance length (AL) biases the reported average toward short requests, which run fewer decoding iterations. Detect inconsistent output lengths and, in that case, report an output-length weighted average for the AR/AL .average statistic so longer requests contribute proportionally. When all output lengths match, behavior is unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Improved accuracy of speculative decoding benchmark metrics reporting when requests produce varying output lengths by using output token count-weighted averaging instead of unweighted calculations.

Summary

In trtllm-bench, the reported average acceptance rate (AR) and acceptance
length (AL) for speculative decoding were computed as an equally-weighted
mean over per-request values. When requests produce different output
lengths, this biases the average toward short requests (which run fewer
decoding iterations).

This PR detects whether all requests share the same output length. When
they do not, the AR/AL .average statistic is reported as an
output-length weighted mean — Σ(output_i · value_i) / Σ(output_i) — so
longer requests contribute proportionally. When all output lengths match,
behavior is unchanged.

Changes

  • tensorrt_llm/bench/dataclasses/reporting.py: compute
    output_lengths_consistent and override the AR/AL average with an
    output-length weighted mean when lengths differ.

Test Coverage

N/A (statistics-only change; min/max/percentiles unchanged).

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

@zhaoyangwang-nvidia zhaoyangwang-nvidia marked this pull request as ready for review June 5, 2026 06:48
@zhaoyangwang-nvidia zhaoyangwang-nvidia requested a review from a team as a code owner June 5, 2026 06:48
@zhaoyangwang-nvidia
Copy link
Copy Markdown
Collaborator Author

Hi @NVIDIA/trtllm-bench-reviewers please help to review this PR, just very small fix, thanks~

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The PR modifies StatsKeeper.generate_statistics_summary() to recalculate speculative decoding percentile averages when request output lengths are inconsistent. When detected, draft acceptance rate and acceptance length percentile aggregates are recomputed using output-token-length weighted means instead of unweighted averages.

Changes

Output-length Weighted Average Calculation

Layer / File(s) Summary
Weighted average calculation for inconsistent output lengths
tensorrt_llm/bench/dataclasses/reporting.py
Adds conditional logic to detect when requests produce varying output lengths and recalculates draft_acceptance_rate_percentiles.average and acceptance_length_percentiles.average using output-token-length weighted means instead of unweighted values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: weighting acceptance rate/acceptance length averages by output length in trtllm-bench.
Description check ✅ Passed The PR description comprehensively explains the problem, solution, affected files, and test coverage, following the repository's template structure.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tensorrt_llm/bench/dataclasses/reporting.py (1)

220-227: ⚡ Quick win

Add strict=True to zip() calls for safer iteration.

Since this codebase targets Python 3.10+ and the output_tokens, draft_acceptance_rate, and acceptance_length lists are populated in the same loop, they should always have the same length. Adding strict=True to the zip() calls will catch any future bugs where the lengths diverge.

✨ Proposed fix
                 if draft_acceptance_rate_percentiles is not None:
                     draft_acceptance_rate_percentiles.average = sum(
                         w * v
-                        for w, v in zip(output_tokens, draft_acceptance_rate
+                        for w, v in zip(output_tokens, draft_acceptance_rate, strict=True
                                         )) / total_output_tokens
                 if acceptance_length_percentiles is not None:
                     acceptance_length_percentiles.average = sum(
-                        w * v for w, v in zip(output_tokens, acceptance_length)
+                        w * v for w, v in zip(output_tokens, acceptance_length, strict=True)
                     ) / total_output_tokens
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/bench/dataclasses/reporting.py` around lines 220 - 227, Update
the two zip() usages that compute weighted averages so they include strict=True
to guard against mismatched lengths: add strict=True to the zip(...) in the
block that sets draft_acceptance_rate_percentiles.average (zipping output_tokens
and draft_acceptance_rate) and to the zip(...) in the block that sets
acceptance_length_percentiles.average (zipping output_tokens and
acceptance_length); this makes zip raise if list lengths diverge (Python 3.10+),
preserving the existing weighted-average logic and dividing by
total_output_tokens as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tensorrt_llm/bench/dataclasses/reporting.py`:
- Around line 220-227: Update the two zip() usages that compute weighted
averages so they include strict=True to guard against mismatched lengths: add
strict=True to the zip(...) in the block that sets
draft_acceptance_rate_percentiles.average (zipping output_tokens and
draft_acceptance_rate) and to the zip(...) in the block that sets
acceptance_length_percentiles.average (zipping output_tokens and
acceptance_length); this makes zip raise if list lengths diverge (Python 3.10+),
preserving the existing weighted-average logic and dividing by
total_output_tokens as before.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 404f3cfa-a004-4b31-add9-a28cff4c94c8

📥 Commits

Reviewing files that changed from the base of the PR and between 21ffdc7 and 1eac86d.

📒 Files selected for processing (1)
  • tensorrt_llm/bench/dataclasses/reporting.py

When requests produce different output lengths, an equally-weighted mean
over per-request acceptance rate (AR) and acceptance length (AL) biases
the reported average toward short requests, which run fewer decoding
iterations. Detect inconsistent output lengths and, in that case, report
an output-length weighted average for the AR/AL .average statistic so
longer requests contribute proportionally. When all output lengths match,
behavior is unchanged.

Signed-off-by: ZhaoyangWang <zhaoyangw@nvidia.com>
@zhaoyangwang-nvidia zhaoyangwang-nvidia force-pushed the feature/bench-ar-al-length-weighted branch from 1eac86d to d33b609 Compare June 5, 2026 08:07
@zhaoyangwang-nvidia
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #52312 [ run ] triggered by Bot. Commit: d33b609 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #52312 [ run ] completed with state SUCCESS. Commit: d33b609
/LLM/main/L0_MergeRequest_PR pipeline #41618 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

@zhaoyangwang-nvidia
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #52325 [ run ] triggered by Bot. Commit: d33b609 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #52325 [ run ] completed with state SUCCESS. Commit: d33b609
/LLM/main/L0_MergeRequest_PR pipeline #41631 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

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.

2 participants