Skip to content

fix(benchmarks): keep histogram quantiles finite in the +Inf bucket - #17264

Open
lonexreb wants to merge 1 commit into
ai-dynamo:mainfrom
lonexreb:lonexreb/fix-16877-histogram-inf-quantile
Open

lonexreb wants to merge 1 commit into
ai-dynamo:mainfrom
lonexreb:lonexreb/fix-16877-histogram-inf-quantile

Conversation

@lonexreb

@lonexreb lonexreb commented Oct 25, 2026 •

Copy link
Copy Markdown

Overview:

Summary

parse_prometheus_text() in the frontend benchmark report interpolates into the +Inf histogram bucket. A finite latency distribution whose tail sits above the last finite bound reports p95/p99 as inf in the stage waterfall and transport breakdown.

Repro on main, from #16877: feed this snapshot to parse_prometheus_text()

dynamo_frontend_stage_duration_seconds_bucket{stage="preprocess",le="0.1"} 50
dynamo_frontend_stage_duration_seconds_bucket{stage="preprocess",le="1.0"} 90
dynamo_frontend_stage_duration_seconds_bucket{stage="preprocess",le="+Inf"} 100
dynamo_frontend_stage_duration_seconds_count{stage="preprocess"} 100

and stage_durations["preprocess"] is {"p50": 0.1, "p95": inf, "p99": inf}.

Details:

When the selected quantile lands in the unbounded bucket, return the highest finite bucket boundary (1.0 above). This is what Prometheus histogram_quantile does. Quantiles inside finite buckets still use linear interpolation, unchanged.

The fix is one condition in histogram_quantile(). The new test covers the tail-in-+Inf case, the all-samples-in-+Inf case, and a finite-only distribution to pin the existing interpolation.

This picks up the fix proposed in #16880, which was closed before review.

Validation

Before the fix, the two +Inf cases fail:

FAILED tests/benchmarks/test_frontend_parsing_util.py::test_stage_quantiles_stay_finite[tail-in-inf-bucket]
FAILED tests/benchmarks/test_frontend_parsing_util.py::test_stage_quantiles_stay_finite[all-in-inf-bucket]
2 failed, 1 passed

After:

$ python -m pytest tests/benchmarks/test_frontend_parsing_util.py -q
3 passed

pre-commit run --files <changed files>: isort, black, flake8, ruff, codespell pass.

Where should the reviewer start?

benchmarks/frontend/scripts/analysis/parsing_util.py, the histogram_quantile() loop.

Related Issues

Summary by CodeRabbit

  • Bug Fixes
    • Improved percentile calculations for histogram data, returning finite values when samples reach the infinite bucket or have no increase between adjacent buckets.
  • Tests
    • Added coverage for p50, p95, and p99 calculations across histogram samples.

parse_prometheus_text() interpolated into the +Inf bucket, so a finite
latency distribution whose tail sits above the last finite bound reported
p95/p99 = inf in the stage waterfall and transport breakdown.

Return the highest finite bucket boundary when the selected quantile falls
in the unbounded bucket, matching Prometheus histogram_quantile. Quantiles
inside finite buckets still interpolate linearly.

Closes ai-dynamo#16877

Signed-off-by: lonexreb <reach2shubhankar@gmail.com>
@lonexreb
lonexreb requested a review from a team as a code owner October 25, 2026 06:02
@copy-pr-bot

copy-pr-bot Bot commented Oct 25, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@lonexreb
lonexreb temporarily deployed to external_collaborator October 25, 2026 06:02 — with GitHub Actions Inactive
@lonexreb
lonexreb temporarily deployed to external_collaborator October 25, 2026 06:02 — with GitHub Actions Inactive
@github-actions github-actions Bot added the fix label Oct 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi lonexreb! Thank you for contributing to ai-dynamo/dynamo.

Just a reminder: The NVIDIA Test Github Validation CI runs an essential subset of the testing framework to quickly catch errors.Your PR reviewers may elect to test the changes comprehensively before approving your changes.

🚀

@github-actions github-actions Bot added the external-contribution Pull request is from an external contributor label Oct 25, 2026
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1ecc870 and 29dfbc3.

Files selected for processing: 2
  • benchmarks/frontend/scripts/analysis/parsing_util.py
  • tests/benchmarks/test_frontend_parsing_util.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Walkthrough

The frontend Prometheus parser now returns the previous finite bucket boundary when a quantile selects the +Inf bucket. New parameterized tests check p50, p95, and p99 values across three histogram count distributions.

Changes

Histogram quantile parsing

Layer / File(s) Summary
Handle unbounded histogram buckets
benchmarks/frontend/scripts/analysis/parsing_util.py, tests/benchmarks/test_frontend_parsing_util.py
histogram_quantile returns the previous bucket boundary when the selected bucket is infinite or has the same count as the previous bucket. Parameterized parser tests check finite expected p50, p95, and p99 values across three count distributions.

Priority: Normal

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

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 29dfb

The quantile fix matches the stated behavior and the added tests check the affected distributions. No actionable issue remains before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: keeping histogram quantiles finite when the selected bucket is +Inf.
Description check Passed The description includes the required overview, details, reviewer starting point, related issues, validation results, and test coverage. It directly matches the pull request changes.
Linked Issues check Passed Directly linked issue #16877 has two coding requirements. (1) When the selected quantile falls in the +Inf bucket, return the highest finite bucket bound. The change in benchmarks/frontend/scripts/ana…
Out of Scope Changes check Passed The whole-PR diff against the merge base 1ecc870 touches two files. parsing_util.py adds import math and the one-condition change in histogram_quantile(). Both directly implement #16877. The new te…
Full details: Linked Issues check

Explanation

Directly linked issue #16877 has two coding requirements. (1) When the selected quantile falls in the +Inf bucket, return the highest finite bucket bound. The change in benchmarks/frontend/scripts/analysis/parsing_util.py, histogram_quantile(), adds math.isinf(le) to the existing count == prev_count early return. For the +Inf bucket it returns prev_le, the highest finite bound. (2) Keep linear interpolation inside finite buckets. The interpolation branch is unchanged. The new parametrized tests in tests/benchmarks/test_frontend_parsing_util.py cover the issue snapshot (tail-in-inf-bucket: p50 0.1, p95 1.0, p99 1.0), an all-in-+Inf case (all quantiles 1.0), and a finite-only case (p50 0.4375, p95 0.94375, p99 0.98875). I checked these expected values by hand against the interpolation formula. The issue asks for parser regression tests, and they exist. I did not run the test suite. The issue is CPU-only and the code uses no GPU or backend dependency. Unverified: the edge case of a snapshot with only a +Inf bucket returns 0.0. Prometheus returns NaN in that case. The issue does not specify this case, so it does not affect the verdict.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base 1ecc870 touches two files. parsing_util.py adds import math and the one-condition change in histogram_quantile(). Both directly implement #16877. The new test file tests/benchmarks/test_frontend_parsing_util.py exercises only the changed behavior and the finite-interpolation regression. No unrelated files, refactors, or behavior changes appear in the diff. The test markers (unit, pre_merge, gpu_0) are test-infrastructure metadata, not feature changes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

This branch was previously deployed

1 inactive deployment
external_collaborator — 29dfbc3b Deployed Oct 25, 2026 by lonexreb via ok-to-test #38491
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contribution Pull request is from an external contributor fix size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Frontend performance reports infinite tail latency from finite histogram samples

1 participant