Skip to content

[Spec Decode] Reduce TP communication for speculative decoding draft token generation - #34049

Merged
houseroad merged 3 commits into
vllm-project:mainfrom
zixi-qi:spec-decode-allgather-optimization
Feb 22, 2026
Merged

houseroad merged 3 commits into
vllm-project:mainfrom
zixi-qi:spec-decode-allgather-optimization

Conversation

@zixi-qi

@zixi-qi zixi-qi commented Feb 7, 2026 •

Copy link
Copy Markdown
Collaborator

Purpose

Reduce TP communication overhead in Eagle speculative decoding by replacing the all-gather of full vocabulary logits with a local argmax + gather reduction.

Problem

During draft token generation, Eagle speculative decoding all-gathers the full logits tensor across TP ranks — O(batch_size × vocab_size) data per step. For large vocabularies (e.g., 200K+ tokens in Llama 4), this becomes unnecessary overhead since only the argmax token ID is needed for greedy draft selection.

Solution

Add a use_local_argmax_reduction option to speculative_config that:

  1. Computes local argmax on each TP rank's vocab shard
  2. Gathers only (max_value, global_index) pairs — O(batch_size × 2 × tp_size) instead of O(batch_size × vocab_size)
  3. Reduces across ranks to find the global argmax

Test Plan

Benchmarked on Llama4 Maverick + EAGLE and observed on par draft acceptance rate + small improvement on TTIT. Generally this optimization is helpful when batch_size * draft_vocab_size is sufficiently large, when bs is small or draft model has smaller vocabulary the gains would become marginal, so default to False.

  Benchmark Results                                                                                                                                
                                                            
  Setup: Llama 4 Maverick 17B-128E-Instruct-FP8 + EAGLE (morgendave/EAGLE-Llama-4-Maverick-17B-128E-Instruct), TP=8, 1000 ShareGPT requests,       
  num_speculative_tokens=5, cudagraph_mode=FULL_AND_PIECEWISE
  ┌────────────────────────────┬──────────┬──────────────┬─────────┐
  │           Metric           │ Baseline │ Local Argmax │  Delta  │
  ├────────────────────────────┼──────────┼──────────────┼─────────┤
  │ Output throughput (tok/s)  │ 2647.27  │ 2634.42      │ -0.5%   │
  ├────────────────────────────┼──────────┼──────────────┼─────────┤
  │ Total throughput (tok/s)   │ 5726.19  │ 5702.24      │ -0.4%   │
  ├────────────────────────────┼──────────┼──────────────┼─────────┤
  │ Request throughput (req/s) │ 14.29    │ 14.24        │ -0.3%   │
  ├────────────────────────────┼──────────┼──────────────┼─────────┤
  │ Acceptance rate (%)        │ 37.44    │ 37.07        │ -0.37pp │
  ├────────────────────────────┼──────────┼──────────────┼─────────┤
  │ Mean acceptance length     │ 2.87     │ 2.85         │ -0.7%   │
  ├────────────────────────────┼──────────┼──────────────┼─────────┤
  │ Mean TPOT (ms)             │ 25.02    │ 24.70        │ -1.3%   │
  ├────────────────────────────┼──────────┼──────────────┼─────────┤
  │ Mean ITL (ms)              │ 62.57    │ 61.97        │ -1.0%   │
  ├────────────────────────────┼──────────┼──────────────┼─────────┤
  │ Mean TTFT (ms)             │ 31009    │ 30910        │ -0.3%   │
  ├────────────────────────────┼──────────┼──────────────┼─────────┤
  │ Mean E2EL (ms)             │ 35051    │ 34934        │ -0.3%   │
  └────────────────────────────┴──────────┴──────────────┴─────────┘

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an efficient local argmax reduction strategy for speculative decoding, aiming to reduce communication overhead across tensor parallel ranks. The changes are well-implemented, gated by a new configuration flag, and include appropriate fallbacks and user warnings. My review identifies one critical issue where a negative logit scaling factor could lead to incorrect behavior in the new optimization path. Otherwise, the changes look solid and improve performance as intended.

Comment thread vllm/model_executor/layers/logits_processor.py
@mergify

mergify Bot commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Hi @zixi-qi, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy or markdownlint failing?
mypy and markdownlint are run differently in CI. If the failure is related to either of these checks, please use the following commands to run them locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10
# For markdownlint
pre-commit run --hook-stage manual markdownlint

@zixi-qi
zixi-qi force-pushed the spec-decode-allgather-optimization branch from 2d8c9b9 to d53c172 Compare February 7, 2026 12:55
@zixi-qi

zixi-qi commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

cc @houseroad could you take a look when you get a chance? Thx a lot!

@mergify

mergify Bot commented Feb 12, 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, @zixi-qi.

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 Feb 12, 2026
@zixi-qi
zixi-qi force-pushed the spec-decode-allgather-optimization branch from d53c172 to 09ccb68 Compare February 13, 2026 15:01
@mergify mergify Bot removed the needs-rebase label Feb 13, 2026
@zixi-qi

zixi-qi commented Feb 13, 2026

Copy link
Copy Markdown
Collaborator Author

Rebase and resolve merge conflict

@houseroad houseroad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good.

@houseroad houseroad added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 22, 2026
@houseroad
houseroad merged commit 2bcf71b into vllm-project:main Feb 22, 2026
63 checks passed
@dosubot

dosubot Bot commented Feb 22, 2026

Copy link
Copy Markdown

Related Documentation

Checked 0 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

jmamou pushed a commit to jmamou/vllm that referenced this pull request Feb 23, 2026
…token generation (vllm-project#34049)

Signed-off-by: qizixi <qizixi@meta.com>
Co-authored-by: Lu Fang <30275821+houseroad@users.noreply.github.com>
Copilot AI pushed a commit to machov/vllm that referenced this pull request Mar 10, 2026
…token generation (vllm-project#34049)

Signed-off-by: qizixi <qizixi@meta.com>
Co-authored-by: Lu Fang <30275821+houseroad@users.noreply.github.com>
@ZJY0516

ZJY0516 commented Mar 15, 2026

Copy link
Copy Markdown
Member

Generally this optimization is helpful when batch_size * draft_vocab_size is sufficiently large,

May I ask which senario people will use large batchsize in spec decoding?

@zixi-qi

zixi-qi commented Mar 15, 2026

Copy link
Copy Markdown
Collaborator Author

Generally this optimization is helpful when batch_size * draft_vocab_size is sufficiently large,

May I ask which senario people will use large batchsize in spec decoding?

Generally speaking when batch size is large, speculative decoding is less helpful, but the exact break even point varies based on the base model, hardware, draft model accuracy etc. So there are certain scenarios where this optimization comes in handy.

jiangkuaixue123 pushed a commit to jiangkuaixue123/vllm that referenced this pull request Apr 28, 2026
…token generation (vllm-project#34049)

Signed-off-by: qizixi <qizixi@meta.com>
Co-authored-by: Lu Fang <30275821+houseroad@users.noreply.github.com>
mystous pushed a commit to mystous/vllm_hybrid that referenced this pull request May 10, 2026
…token generation (vllm-project#34049)

Signed-off-by: qizixi <qizixi@meta.com>
Co-authored-by: Lu Fang <30275821+houseroad@users.noreply.github.com>
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
…token generation (vllm-project#34049)

Signed-off-by: qizixi <qizixi@meta.com>
Co-authored-by: Lu Fang <30275821+houseroad@users.noreply.github.com>
0826joyce pushed a commit to 0826joyce/vllm-serving-optimization that referenced this pull request May 19, 2026
…token generation (vllm-project#34049)

Signed-off-by: qizixi <qizixi@meta.com>
Co-authored-by: Lu Fang <30275821+houseroad@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llama Related to Llama models ready ONLY add when PR is ready to merge/full CI is needed speculative-decoding v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants