vllm - ✅(Solved) Fix [Feature]: Batch invariance on 3090 [1 pull requests, 4 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#38286Fetched 2026-04-08 01:36:47
View on GitHub
Comments
4
Participants
2
Timeline
15
Reactions
0
Author
Participants
Assignees
Timeline (top)
commented ×4mentioned ×3subscribed ×3assigned ×1

PR fix notes

PR #38427: [Bugfix] Enable batch-invariant Triton matmul on all Ampere GPUs (SM 8x)

Description (problem / solution / changelog)

Purpose

Enable batch-invariant Triton matmul on all Ampere GPUs (SM 80, 86, 87), fixing batch invariance on RTX 3090/3080/A6000/Jetson Orin.

The Triton matmul overrides in batch_invariant.py were only registered for SM 80 (A100), SM 89 (4090), and SM 100 family (Blackwell). SM 86 (3090) was not matched by is_device_capability(80) (exact match), so it fell through to CUBLAS which picks different tiling/accumulation algorithms depending on batch size, breaking batch invariance in bfloat16.

Fix: change is_device_capability(80) to is_device_capability_family(80).

How we found it

The determinism tests had 3 failures on RTX 3090. We isolated the source by testing each component individually (BS=1 vs BS=4):

  • flash_attn_varlen_func — batch-invariant ✓
  • log_softmax (Triton) — batch-invariant ✓
  • torch.nn.functional.linear (CUBLAS) — not batch-invariant
  • matmul_persistent (Triton) — batch-invariant ✓

This confirmed CUBLAS matmul was the source, and traced why the Triton replacement wasn't active on SM 86 to the exact-match check.

Closes #38286

Test Plan

.venv/bin/python -m pytest tests/v1/determinism/ -v --timeout=1000

Test Result

Before fix (RTX 3090, SM 86): 97 passed, 3 failed
FAILED test_batch_invariance.py::test_decode_logprobs_match_prefill_logprobs[FLASH_ATTN]
FAILED test_online_batch_invariance.py::test_logprobs_bitwise_batch_invariance_bs1_vs_bsN[FLASH_ATTN]
FAILED test_online_batch_invariance.py::test_logprobs_bitwise_batch_invariance_bs1_vs_bsN[TRITON_ATTN]

After fix: 100 passed, 0 failed 
100 passed, 27 warnings in 318.41s 
                  
- Pre-commit checks pass
- AI assistance (Claude) was used for investigation and this PR

Changed files

  • vllm/model_executor/layers/batch_invariant.py (modified, +3/-5)
RAW_BUFFERClick to expand / collapse

🚀 The feature, motivation and pitch

Batch Invariance does not work on the 3090 (two unit tests failing) but in my testing I had managed to run Qwen3-0.6B and get deterministic results. As such I would like to work on getting the failing unit tests passing and batch invariance support on the 3090.

This has been discussed briefly with @yewentao256 in #27433.

Alternatives

NA

Additional context

I include here the summary test output, from #27433

https://github.com/vllm-project/vllm/issues/27433#issuecomment-4137438472

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

Fix Plan

To fix the batch invariance issue on the 3090, we need to ensure deterministic behavior in our GPU computations.

  • Update the CUDA version to the latest stable release.
  • Set the CUDA_DETERMINISTIC environment variable to True.
  • Use the torch.backends.cudnn.deterministic flag in PyTorch.

Example code:

import torch
import os

# Set environment variable
os.environ['CUDA_DETERMINISTIC'] = 'True'

# Set PyTorch flag
torch.backends.cudnn.deterministic = True

# Verify CUDA version
print(torch.cuda.get_device_name(0))

Verification

Run the unit tests again to verify that batch invariance is working correctly on the 3090.

Extra Tips

  • Make sure to update the CUDA drivers to the latest version.
  • Consider using a fixed seed for random number generation to ensure reproducibility.
  • Refer to the PyTorch documentation for more information on deterministic behavior: https://pytorch.org/docs/stable/notes/randomness.html

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

vllm - ✅(Solved) Fix [Feature]: Batch invariance on 3090 [1 pull requests, 4 comments, 2 participants]