Skip to content

[Rust Frontend] Add per-request speculative decoding metrics - #61877

Merged
BugenZhao merged 3 commits into
vllm-project:mainfrom
xinnywinne:feat/rust-spec-decode-request-metrics
Oct 27, 2026
Merged

BugenZhao merged 3 commits into
vllm-project:mainfrom
xinnywinne:feat/rust-spec-decode-request-metrics

Conversation

@xinnywinne

@xinnywinne xinnywinne commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds speculative-decoding acceptance statistics to per-request metrics in the Rust OpenAI frontend.

This is a follow-up to #59314, which added the base per-request timing metrics support. It is not duplicate work: the Rust Chat Completions and Completions routes do not currently propagate the engine's per-request speculative-decoding statistics. This PR reuses the converter already used by /inference/v1/generate.

  • exposes metrics.speculative_decoding for /v1/chat/completions and /v1/completions
  • supports both non-streaming and streaming responses
  • emits streaming metrics only on the final usage chunk
  • keeps timing metrics and speculative-decoding metrics independently configurable
  • reuses the existing speculative-decoding conversion shared with /inference/v1/generate

The response follows the existing Python/OpenAI per-request metrics schema, including summary and detailed speculative-decoding modes.

Validation

  • cargo fmt --all -- --check
  • cargo check --workspace --tests
  • cargo clippy -p vllm-text -p vllm-chat -p vllm-server --all-targets -- -D warnings
  • cargo test -p vllm-server routes::openai:: — 153 passed
  • cargo test -p vllm-text --lib — 111 passed, 1 ignored
  • cargo test -p vllm-chat --lib — 389 passed
  • focused shared converter and propagation tests
  • pre-commit hooks
  • A100 end-to-end validation with n-gram speculative decoding:
    • Chat Completions, streaming and non-streaming
    • Completions, streaming and non-streaming
    • timing-only, speculative-decoding-only, and combined response behavior
    • intermediate streaming chunks omit metrics; the final usage chunk includes them

Notes

A broader cargo test -p vllm-text -p vllm-chat run also exercised the integration suites. Two model round-trip snapshot cases (roundtrip_mimo_v26 and roundtrip_step5) failed because the locally resolved model/tokenizer data no longer matched the checked-in snapshots; this PR only adds spec_decode_metrics: None to their terminal-output test fixture.

AI assistance was used to implement and validate this change. I reviewed every changed line and understand the implementation.

@mergify mergify Bot added rust gpt-oss Related to GPT-OSS models labels Oct 15, 2026
@xinnywinne
xinnywinne force-pushed the feat/rust-spec-decode-request-metrics branch from 700f6b2 to 54f8409 Compare October 19, 2026 17:52
@mergify

mergify Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @xinnywinne.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Oct 20, 2026
@xinnywinne
xinnywinne force-pushed the feat/rust-spec-decode-request-metrics branch from 54f8409 to 2de327e Compare October 20, 2026 20:55
@mergify mergify Bot removed the needs-rebase label Oct 20, 2026
@xinnywinne
xinnywinne marked this pull request as ready for review October 20, 2026 21:01

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

xinnywinne and others added 2 commits October 27, 2026 11:44
Expose speculative decoding acceptance statistics in OpenAI chat and completion response metrics while reusing the existing generate endpoint conversion.

Assisted-by: OpenAI Codex <noreply@openai.com>

Signed-off-by: wxin <wxin@nvidia.com>
Signed-off-by: xinnywinne <36653773+xinnywinne@users.noreply.github.com>

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
…tils::metrics

Keep the per-request metrics family in one module: `PerRequestMetrics`
and `StreamPerRequestMetrics` already live in `openai/utils/metrics.rs`,
and `/inference/v1/generate` already imports from `openai::utils`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CJckCEER627cygWfxcyUPH
Signed-off-by: Bugen Zhao <i@bugenzhao.com>

@BugenZhao BugenZhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @xinnywinne

@github-project-automation github-project-automation Bot moved this from To Triage to Ready in gpt-oss Issues & Enhancements Oct 27, 2026
@BugenZhao
BugenZhao force-pushed the feat/rust-spec-decode-request-metrics branch from 2de327e to 70106b8 Compare October 27, 2026 11:48
@BugenZhao BugenZhao added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 27, 2026
@BugenZhao

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

✅ @xinnywinne, CI is now available for this PR.

  • /ci run starts upstream CI; /amd-ci run starts AMD CI only.
  • Run commands test your branch with every commit currently on its upstream target branch. If it is behind, the bot merges the target branch into it first (pull before pushing again). Append --allow-stale to a run command to test an outdated branch as is, at your own risk.
  • /ci retry retries failed jobs in the CI build for the current PR head. If the current head has no CI build, it starts a new CI build for the current head containing only jobs that failed in the latest earlier CI build for this PR.
  • /amd-ci retry retries failed jobs in AMD CI for the current PR head. Use /amd-ci run when the current head has no AMD CI build.
  • /ci cancel cancels scheduled or running CI builds for this PR branch; /amd-ci cancel does the same for AMD CI only.

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #97623 for commit f42c7c387eb5.

ℹ️ This PR is 2 commits behind upstream main. Merged upstream main into this branch as f42c7c387eb5 before starting CI. Pull the branch before pushing more changes.

@BugenZhao
BugenZhao merged commit 4216a23 into vllm-project:main Oct 27, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpt-oss Related to GPT-OSS models ready ONLY add when PR is ready to merge/full CI is needed rust

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants