Skip to content

[Feature]: Batch Invariant Feature and Performance Optimization #27433

Open

Description

@yewentao256

🚀 The feature, motivation and pitch

We have basically support Batch Invariant based on https://thinkingmachines.ai/blog/defeating-nondeterminism-in-llm-inference/

Batch-invariant Inference (view)

But there are still some work to be done, so here is the issue to track the work

TODOs:

Nice to have:

Model coverage

https://docs.vllm.ai/en/latest/features/batch_invariance/#tested-models

🙋Help needed for validations of more models.

  1. Test a model using the script in https://github.com/vllm-project/vllm/tree/main/tests/v1/determinism
  2. Submit a PR updating the document

Activity

  1. self-assigned this
    on Oct 24, 2025
  2. PaulZhang12 commented on Oct 25, 2025

    @PaulZhang12
    Contributor

    Happy to look into the torch.compile batch invariance

  3. bwasti commented on Oct 31, 2025

    @bwasti
    Contributor

    documentation done! happy to take more of these on

  4. anxiang1836 commented on Nov 14, 2025

    @anxiang1836

    Will this feature support on GPU L20 (Ada Lovelace) in vllm 0.11.1?

  5. quanliu1991 commented on Nov 14, 2025

    @quanliu1991
    Contributor

    Will this feature support on GPU L20 (Ada Lovelace) in vllm 0.11.1?

    We are currently implementing Batch-invariant Inference for FlashAttention2 on A800 and L20 GPUs. The work is now in the testing phase, and we plan to submit the code once the tests are successfully completed.

  6. bi1101 commented on Nov 25, 2025

    @bi1101

    Hi, I enabled batch invariant in 0.11.2 with ELVISIO/Qwen3-30B-A3B-Instruct-2507-AWQ. And tested the output for determinism, but it didn't seem to work. The result still varies. I'm testing on 5090, which is supported and has compute capability above 9.0. Does Batch Invariant work for awq quantized model?

  7. 100 remaining items

  8. yifanFengg commented on Oct 4, 2026

    @yifanFengg
    Contributor

    Validated three more models on GB300 (Qwen3-32B, QwQ-32B, Qwen3-235B-A22B, all 22/22) and found that the Qwen3-Next entry in the tested list no longer starts in batch-invariant mode since #40193. PR: #59972

  9. yifanFengg commented on Oct 4, 2026

    @yifanFengg
    Contributor

    While validating large models on GB300 I found that zai-org/GLM-4.5-Air is not batch invariant with VLLM_BATCH_INVARIANT=1 (12 of 22 suite tests fail). The cause is GateLinear's specialized router GEMM tiers, which bypass the batch-invariant linear path and dispatch on token count. Fix with a regression test: #59985. Docs update from the same validation runs (six models added, Qwen3-Next and GPT-OSS entries corrected): #59972.

  10. yifanFengg commented on Oct 9, 2026

    @yifanFengg
    Contributor

    Status update on the batch-invariance fixes from my side, in case it helps the tracker:

    Known gaps I have not touched: GPTQ/AWQ MoE experts on Marlin (AutoGPTQMoEMethod), the FA4 scheduler on Blackwell (forced to FA2), and INT8 W8A8 on SM 10.x (CUTLASS has no kernel there, unrelated to invariance).

  11. mawong-amd commented on Oct 9, 2026

    @mawong-amd
    Member

    AMD support update on #52231: rebased on current main, green in upstream CI on both pipelines — the determinism suite passes on MI250, MI300 and MI355, including the distributed steps at TP=4 (with and without custom all-reduce) and DP=4 with expert parallelism, and on the ROCm 10 image. Back under review.

    Also updating the DP note above, since it's outdated: DP+EP is supported now — #45683 (merged) made the MoE combine deterministic, and @yifanFengg validated one config above (DP=2×TP=2 with EP, bitwise equal on GB300). On AMD, #45683's fixed-root reduce measures batch-variant on RCCL at 4 ranks, so #52231 routes the MoE combine (and reduce-scatter generally) through an all-to-all plus a fixed-order rank sum instead; the DP=4+EP arm (OLMoE, online quantization) is bitwise invariant with it at 4 ranks. Dense DP needs no support — ranks run decoupled — and #52231 absorbs the MoE DP padding (1→200 rows across replicas). A custom-kernel reduce-scatter stays a perf follow-up.

  12. Laurent-Zhang commented on Oct 14, 2026

    @Laurent-Zhang
    Contributor

    PR submitted: #61575 — validated Qwen/Qwen2.5-Coder-1.5B-Instruct on RTX 4090 (sm_89). All 6 test variants passed (FLASH_ATTN / TRITON_ATTN / FLEX_ATTENTION × default / vllm_c).

  13. chf003 commented on Oct 23, 2026

    @chf003
    Contributor

    Hi! I validated Qwen/Qwen3-4B for batch invariance using the official test suite on a single NVIDIA A100 80GB (BF16, TP=1, default compiled mode).

    I opened #63348 to add the model to the tested-models list.

  14. added
    batch-invarianceBatch invariance and deterministic inference (VLLM_BATCH_INVARIANT)
    on Nov 2, 2026
  15. yifanFengg commented on Nov 3, 2026

    @yifanFengg
    Contributor

    Model coverage note for the list: zai-org/GLM-5.3 (DSA sparse MLA) cannot run under VLLM_BATCH_INVARIANT=1 today (no sparse backend opts in), and with a measurement-only opt-in it is not batch invariant on 4x GB300: 6/6 suite ids fail in all three backend/KV configs, and a short request's first-token logprob changes with its position in a 16-request batch while every layer-0 projection stays bitwise identical; the first divergence is inside the layer-0 sparse-MLA attention core. Kernel probes, model-level logs, the per-module bisection and the opt-in diff are in #65278.

  16. imthomp commented on Nov 4, 2026

    @imthomp

    Proposal for the Hopper/Blackwell Linear path (under "Optimize the batch invariant performance"): #65569 . On H100, routing UnquantizedLinearMethod to cuBLAS under batch-invariant mode cut batch-32 decode cost from 63.1% to 0.2% on Qwen2.5-7B, with identical outputs across cache and batch conditions. Feedback welcome before I open a PR.

  17. imthomp commented on Nov 12, 2026

    @imthomp

    For the SM100 part of this tracker, in case it helps whoever upgrades vLLM's cuBLAS: cuBLAS 13.8's experimental batch-invariance mode (CUBLAS_BATCH_INVARIANCE_FLAGS=8, AUTO) is bitwise batch invariant on a B200 in my tests (batch sizes 1-8192; 25 shapes including the gpt-oss router, odd widths and large projections; bf16, fp16, fp32), but only if batch-invariant mode's PyTorch reduced-precision setting is not also applied. With allow_{fp16,bf16}_reduced_precision_reduction = (False, False) (how the mode disables split-k through PyTorch), odd widths (97, 127, 129) differ; with only cuBLASLt preferred and that setting left at its default, 0 of 408,828 comparisons differ. Pinning the alignment class instead does not help (ALIGN_2B makes it worse; ALIGN_16B rejects odd widths). So when vLLM's pinned cuBLAS includes the mode, enabling it on SM100 would mean skipping that PyTorch setting there. Details and raw data in #65569 and https://github.com/imthomp/vllm-batch-invariance (PROTOCOL.md, Phases 1e/1f).

  18. mosafariuk commented on Nov 14, 2026

    @mosafariuk
    Contributor

    CPU backend proposal for VLLM_BATCH_INVARIANT=1: #67696. Today the flag refuses to start on CPU_ATTN. With a local prototype, one request's top-5 logprobs were bit-identical alone and in batches for facebook/opt-125m on x86 (fp32, bf16) and macOS, and on Linux arm64 up to 77 prompt tokens. The issue lists five sources and the open design question (the matmul kernel). Is CPU in scope for this tracker?

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

Metadata

Metadata

Labels

batch-invarianceBatch invariance and deterministic inference (VLLM_BATCH_INVARIANT)feature requestNew feature or requestgood first issueGood for newcomers

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions