fix(vllm_engine): actually export VLLM_BATCH_INVARIANT=1 for deterministic inference - #202
Merged
Merged
Conversation
…istic inference --vllm-enable-deterministic-inference's help text promises it "exports VLLM_BATCH_INVARIANT=1 to the vLLM subprocess so attention / comm / MM kernels pick batch-invariant variants", but no code did so -- the flag only forwarded a per-sample seed, and (being an orchestration-only dest) is never passed to `vllm serve`. The only thing that ever set the env was a line in run-qwen2.5-0.5B-reproducibility.sh's runtime-env, which #180 dropped when it re-created the script, leaving nothing to set it. Set VLLM_BATCH_INVARIANT=1 in build_vllm_subprocess_env when the flag is on, so the flag delivers on its documented behavior and seed+kernel determinism both hold without depending on the launch script. Adds two unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds logic to set the VLLM_BATCH_INVARIANT environment variable to '1' in the vLLM subprocess environment when vllm_enable_deterministic_inference is enabled. It also adds unit tests to verify this behavior. There are no review comments, so I have no feedback to provide.
slime sets SLIME_ENABLE_PROFILING here and reads it via its sglang *source patch* (docker/patch/*/sglang.patch: envs.SLIME_ENABLE_PROFILING.get()), which gates prefill/decode timing instrumentation in sglang's scheduler. vime runs vLLM and does not patch that instrumentation in, and nothing in the tree reads VIME_ENABLE_PROFILING -- it was a mechanical slime->vime rename of a flag whose backing reader never came along, so setting it did nothing. Remove it (and the now-unused `import os`); vime profiling is driven by --vllm-profiler-config. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: aoshen02 <aoshen@inferact.ai>
CalvinXKY
approved these changes
Jun 9, 2026
momo609
pushed a commit
that referenced
this pull request
Jun 10, 2026
…istic inference (#202) * fix(vllm_engine): actually export VLLM_BATCH_INVARIANT=1 for deterministic inference --vllm-enable-deterministic-inference's help text promises it "exports VLLM_BATCH_INVARIANT=1 to the vLLM subprocess so attention / comm / MM kernels pick batch-invariant variants", but no code did so -- the flag only forwarded a per-sample seed, and (being an orchestration-only dest) is never passed to `vllm serve`. The only thing that ever set the env was a line in run-qwen2.5-0.5B-reproducibility.sh's runtime-env, which #180 dropped when it re-created the script, leaving nothing to set it. Set VLLM_BATCH_INVARIANT=1 in build_vllm_subprocess_env when the flag is on, so the flag delivers on its documented behavior and seed+kernel determinism both hold without depending on the launch script. Adds two unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * rollout: drop dead VIME_ENABLE_PROFILING env (no reader in vime) slime sets SLIME_ENABLE_PROFILING here and reads it via its sglang *source patch* (docker/patch/*/sglang.patch: envs.SLIME_ENABLE_PROFILING.get()), which gates prefill/decode timing instrumentation in sglang's scheduler. vime runs vLLM and does not patch that instrumentation in, and nothing in the tree reads VIME_ENABLE_PROFILING -- it was a mechanical slime->vime rename of a flag whose backing reader never came along, so setting it did nothing. Remove it (and the now-unused `import os`); vime profiling is driven by --vllm-profiler-config. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Update vllm_engine.py Signed-off-by: aoshen02 <aoshen@inferact.ai> --------- Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
--vllm-enable-deterministic-inference's help text promises it:But no code ever set
VLLM_BATCH_INVARIANT. Grepping the tree, the only occurrence was that help string:vime/rollout/vllm_rollout.py);_VIME_ORCHESTRATION_DESTS), so it is not forwarded tovllm serve;build_vllm_subprocess_envnever set it.The only thing that ever exported the env was a line in
scripts/run-qwen2.5-0.5B-reproducibility.sh'sruntime-env-json(added in #39), which #180 dropped when it re-created that script — leaving nothing to set it. So--vllm-enable-deterministic-inferencedid not actually give batch-invariant kernels, and the reproducibility recipe lost bitwise determinism silently.Fix
Set
VLLM_BATCH_INVARIANT=1inbuild_vllm_subprocess_envwhen the flag is on, so the flag delivers its documented behavior regardless of launch script. Seed + kernel selection now both hold.Tests
Two unit tests in
tests/unit/backends/vllm_utils/test_vllm_engine.py:VLLM_BATCH_INVARIANT == "1"Both pass (
pytest -k "batch_invariant or subprocess_env"→ 3 passed).🤖 Generated with Claude Code