Repository navigation
[Rust Frontend] Cap request token histogram buckets at max_model_len - #62644
Merged
BugenZhao merged 2 commits intoOct 20, 2026
Merged
Conversation
The request token-count histograms (prompt, generation, max_num_generation, params_max_tokens, prefill_kv_computed) used a 1-2-5 series fixed at 131072 plus an extra bound at 131072. Python builds `request_tokens` buckets with `build_1_2_5_buckets(max_model_len)` and no extra bound. Set the cap from the engine-reported max_model_len when `Llm` is created, through a shared histogram constructor on the lazily built registry. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Isotr0py
approved these changes
Oct 20, 2026
Member
Author
|
/ci run |
|
✅ Triggered Buildkite CI #96161 for commit ℹ️ This PR is 16 commits behind upstream |
bantianyue
pushed a commit
to bantianyue/vllm
that referenced
this pull request
Oct 28, 2026
…llm-project#62644) Signed-off-by: Bugen Zhao <i@bugenzhao.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: vllm-agent <claw@inferact.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The five request token-count histograms (
vllm:request_prompt_tokens,vllm:request_generation_tokens,vllm:request_max_num_generation_tokens,vllm:request_params_max_tokens,vllm:request_prefill_kv_computed_tokens) usebuild_1_2_5_buckets(max_model_len)in Python (PrometheusStatLogger.__init__,vllm/v1/metrics/loggers.py). The Rust frontend uses a fixed cap of 131072 (with aTODOto usemax_model_len) plus an extra bound at the cap. This PR builds the same bounds as Python from the engine-reportedmax_model_len.Claims
max_model_len=4096,1, 2, 5, …, 1000, 2000.…, 50000, 100000, 131072: unreachable bounds for short-context models, everything above 131072 in+Inffor 1M-context models, andleseries that do not aggregate with Python's inhistogram_quantileover a mixed fleet.Validation
Commands from
.buildkite/scripts/run-rust-frontend-cargo-ci.sh(style-clippyandtest), run from the repo root:request_token_buckets_are_capped_at_max_model_len(vllm-metrics) rendersvllm:request_prompt_tokensformax_model_len=4096and pins1.0 … 2000.0 +Inf. With the old builder's extra bound restored, it fails with an extra4096.0.llmintegration tests (rust/src/llm/tests/generate.rs) record these histograms throughLlm; without theLlm::newcall they panic on the unset cap, so they cover the wiring.Details
The bucket rule stays in
vllm-metrics, next to the other bucket constants. The global registry is built lazily, before any engine is connected, and aFamilyfixes its metric constructor at registration, so the five families share a smallRequestTokensHistogramconstructor whose buckets are set once throughRequestMetrics::set_max_model_len. Histograms are created per label set on the first recorded request, which is always after that call.Llm::newowns the request metrics and the connectedEngineCoreClient, so it sets the cap fromclient.max_model_len(): the auto-fitted engine value, the minimum across DP engines, which is also the limit the text layer enforces. The registry is process-global and serves one model, so only the first call takes effect.Out of scope:
--custom-histogram-buckets(#48867) can override this family in Python; the Rust frontend rejects the flag at startup (#62431). Supporting it later means filling the same constructor from the override.Not a duplicate: no open upstream PR changes these Rust bucket bounds; #58563 adds connector metrics descriptors, not request token buckets.
AI assistance (Claude Code) was used to prepare this change; the human submitter reviewed every changed line.
🤖 Generated with Claude Code
Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.