Skip to content

buffer size insuffient Dspark sd for FlashInfer MNNVL allreduce - #50932

Open
khushali9 wants to merge 12 commits into
vllm-project:mainfrom
khushali9:DSpark_bufferSizeinsuffient
Open

buffer size insuffient Dspark sd for FlashInfer MNNVL allreduce#50932
khushali9 wants to merge 12 commits into
vllm-project:mainfrom
khushali9:DSpark_bufferSizeinsuffient

Conversation

@khushali9

@khushali9 khushali9 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

fixes #50877

Purpose

FlashInferAllReduce.should_use_fi_ar gates on:

self.max_num_tokens = max_workspace_size // (hidden_dim * element_size)

max_workspace_size is the size of the whole MNNVL allocation (2 MB for TP8). But
the MNNVL backend is Lamport-based and rotates through NUM_LAMPORT_BUFFERS=3
buffers, so only ~1/3 of the budget backs any single all-reduce:

budget 2,097,152 bytes → gate says 146 tokens
per-buffer 698,368 bytes → real capacity is 48 tokens

Any tensor between 49–146 tokens passes the gate and then aborts inside the kernel.
The drafter produces B × (1 + num_speculative_tokens) tokens per step — e.g. 14
requests × 4 = 56 tokens — landing exactly in this window. Without a drafter,
decode batches produce B tokens and stay below 48.

The same defect exists in fused_allreduce_gemma_rms_norm._can_use_flashinfer,
which its docstring notes "mirrors FlashInferAllReduce".

Fix

After the existing budget bound (kept as a cheap pre-filter), call the workspace's
own is_buffer_size_sufficient(tp_size, num_tokens, hidden_dim, dtype) method rather
than reimplementing the Lamport arithmetic. This is on the abstract base class
(flashinfer-python==0.6.15.post1, the pinned version), correct for both mnnvl and
trtllm, and version-proof.

What this does NOT fix

AllReduceFusionPass has the same too-permissive bound
but self.max_token_num there also drives the workspace allocation request — fixing it
requires separating those two concerns and verifying the one-shot/two-shot split,
which needs GB200 hardware. Leaving that for a follow-up.

Workaround (no code change needed)

VLLM_ALLREDUCE_USE_FLASHINFER=0

Disables the eager FlashInferAllReduce path; the compiled fusion pass is unaffected.

Test Plan

I have added test file and you can see output below,
every assertion in the capacity-accounting logic changed ran and succeeded.

pytest tests/compile/passes/distributed/test_fusion_all_reduce.py -v , already existing test.

On GB200

python -m vllm.entrypoints.openai.api_server
--model --speculative-config '{"model": ""}' --tensor-parallel-size 8

if reporter can test on GB200 that would be perfect.

Test Result

Cannot test as I do not have GB200, if @ilmarkov can test it, that would be best.

AI assistance

This fix was developed with Claude (claude-opus-4-6) assistance. I have reviewed
every changed line and understand the root cause and the design.

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.

BEFORE SUBMITTING, PLEASE READ https://docs.vllm.ai/en/latest/contributing (anything written below this line will be removed by GitHub Actions)

Signed-off-by: khushali9 <khushali.desai9@gmail.com>

@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.

@khushali9

Copy link
Copy Markdown
Contributor Author

@ilmarkov Can you please verify and report your findings, it would be super helpful.

Comment thread vllm/distributed/device_communicators/flashinfer_all_reduce.py Outdated
Comment thread vllm/model_executor/layers/fused_allreduce_gemma_rms_norm.py Outdated
Signed-off-by: khushali9 <khushali.desai9@gmail.com>
Comment thread vllm/model_executor/layers/fused_allreduce_gemma_rms_norm.py
Comment thread tests/distributed/test_flashinfer_all_reduce.py Outdated

@ilmarkov ilmarkov 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.

Small comments. Also cc @wzhao18

Signed-off-by: khushali9 <khushali.desai9@gmail.com>
Signed-off-by: khushali9 <khushali.desai9@gmail.com>
@khushali9

Copy link
Copy Markdown
Contributor Author

@ilmarkov @wzhao18 Can someone help with reviewing this. Thanks

@khushali9

khushali9 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@ilmarkov Do you know anyone who can help us with this one ? Also @wzhao18 Can you please review this one ?

@wzhao18

wzhao18 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Thank you for the PR! The PR makes sense to me.

I suggest cleaning up the PR and only adding the minimal changes to add workspace.is_buffer_size_sufficient to the use-kernel condition check. I don't think the test is much meaningful as it basically just asserts the condition checks again so I suggest removing it. Please feel free to ping me again when ready I can review the PR again.

Signed-off-by: khushali9 <khushali.desai9@gmail.com>

@wzhao18 wzhao18 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.

LGTM. Thanks. @mgoin @ilmarkov

@wzhao18

wzhao18 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

please fix precommit

@khushali9

Copy link
Copy Markdown
Contributor Author

@wzhao18 The pre-commit fix needs to be fix by reviewers right ? , I dont have 4 merged PRs with vllm yet, only 2. cc -@mgoin

@wzhao18

wzhao18 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@khushali9 My bad. no worries then.

@khushali9

Copy link
Copy Markdown
Contributor Author

@wzhao18 then can you add those tags to run all the tests, as you reviewed the PR.

@mgoin mgoin added bug Something isn't working ready ONLY add when PR is ready to merge/full CI is needed labels Aug 12, 2026
@mgoin

mgoin commented Aug 12, 2026

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

@khushali9, CI is now available for this PR.

  • /ci run starts a CI build.
  • /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.
  • /ci cancel cancels scheduled or running CI builds for this PR branch.

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #83463 for commit 46312161ea99.

@khushali9

Copy link
Copy Markdown
Contributor Author

/ci retry

@github-actions

Copy link
Copy Markdown

✅ Queued 2 failed job(s) for retry in Buildkite CI #83463.

@khushali9

Copy link
Copy Markdown
Contributor Author

@mgoin @wzhao18 failing CI tests seems not related to my change at all.

@khushali9

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #83572 for commit 8570ccd594d0.

@khushali9

Copy link
Copy Markdown
Contributor Author

/ci retry

@wzhao18

wzhao18 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@khushali9 no worry about unrelated CI failure. @mgoin can help with force merge.

@khushali9

Copy link
Copy Markdown
Contributor Author

@wzhao18 that would be great, thank you so much.

Comment thread vllm/distributed/device_communicators/flashinfer_all_reduce.py Outdated
Signed-off-by: khushali9 <khushali.desai9@gmail.com>
@khushali9

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #83759 for commit 0e93d92eacd2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dflash nvidia ready ONLY add when PR is ready to merge/full CI is needed

Projects

Status: No status
Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Bug]: DSpark speculative decoding triggers FlashInfer MNNVL allreduce "buffer size insufficient" via draft model's embed_input_ids (TP8, GB200 NVL72)

5 participants