Repository navigation
[RL] KV offload on vLLM 0.33: drop the Mooncake no-forward save workaround - #6389
Merged
Merged
Conversation
vLLM 0.33 replaces skipped_waiting with kv_holding_waiting, which it always drains before waiting, so the shared-ID tie-break between the two queue heads is gone. Rename the queue, and fill in the Scheduler state 0.33 reads in the hand-built test schedulers. On 0.33 the first request's tail no longer saves on an idle step, so the GPU test checks that some tail does.
vLLM 0.33's kv_connector_no_forward calls wait_for_save, so Mooncake submits finish-time saves scheduled on a step without a forward (vllm-project/vllm#69805).
acisseJZhong
force-pushed
the
codex/vllm-033-kv-offload
branch
from
November 25, 2026 13:57
9fa5c1d to
5d037f5
Compare
acisseJZhong
marked this pull request as ready for review
November 25, 2026 14:05
acisseJZhong
requested review from
fegin,
felipemello1,
shuhuayu,
tianyu-l and
wwwjn
as code owners
November 25, 2026 14:05
tianyu-l
approved these changes
Nov 25, 2026
tianyu-l
added a commit
that referenced
this pull request
Nov 26, 2026
… deterministic mode (#6398) ## Summary (human-written) <!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why this approach, and what you checked yourself. --> ## Why Since torch `2.16.0.dev20261125`, "1 GPU Integration (Fake PG)" fails on every PR and "8 GPU Integration (Real PG - full suite - models)" fails on main. The A10G golden losses drift in the low digits. Torch `dev20261124` passed (last green: 11:04 UTC run 45601059954), and every run after the nightly switch fails the same tests with the same values. The cause is pytorch/pytorch#204322, "[inductor] Deterministic mode: turn off Triton FMA contraction, emit explicit FMAs". In `config.deterministic` mode, Inductor now compiles its generated Triton kernels with `enable_fp_fusion=False`, so the result no longer depends on which block size or `num_warps` autotuning picks. The golden runs set `debug.deterministic=True`, so their rounding changes. This is an intentional upstream numerics change, not a torchtitan bug, so the fix is to regenerate the goldens. **Example** (`llama3_fsdp+tp+cp`, Fake PG, A10G): ``` step golden (dev20261124) dev20261125 4 3.6361570 gn 0.76279575 3.6361570 gn 0.76279598 5 3.6227007 3.6228001 10 3.4226971 3.4225903 ``` ## How the cause was isolated The two nightlies are 70 PyTorch commits apart (283f59dd27...122eafd311), and the new torch also pins cuDNN 9.28.1 (was 9.26.0). I bisected locally on GB300 with `deepseek_v3_fsdp+ep` (Fake PG), which reproduces the drift there. Each row below gives bitwise-identical results on repeat runs. | torch binary | cuDNN | Python change | step 1 loss | | --- | --- | --- | --- | | dev20261124 | 9.26.0 | -- | 7.990665912628174 | | dev20261124 | 9.28.1 | -- | 7.990665912628174 | | dev20261125 | 9.28.1 | -- | 7.990651607513428 | | dev20261125 | 9.28.1 | dev20261124's `_inductor`/`_dynamo`/`fx`/... | 7.990665912628174 | | dev20261125 | 9.28.1 | only #204322 reverted | **7.990665912628174** | | dev20261125 | 9.28.1 | only #204320 reverted | 7.990651607513428 | | dev20261125 | 9.28.1 | #184946, #206365, #203784, #203888 reverted | 7.990651607513428 | So the cuDNN bump has no effect, and reverting #204322 alone restores the old numerics bit for bit. ## What changed Mechanical: the numeric rows of 11 golden files are replaced. Headers and step counts are unchanged and were checked against the source blocks. | Golden file | Tests | max rel. loss diff | final loss old -> new | | --- | --- | --- | --- | | `fake_pg/a10g/llama3.txt` | `llama3_fsdp+tp+cp`, `+region_ac` | 3.1e-05 | 3.42270 -> 3.42259 | | `fake_pg/a10g/deepseek_v3.txt` | `deepseek_v3_fsdp+ep` | 4.0e-05 | 6.32932 -> 6.32955 | | `fake_pg/a10g/qwen3.txt` | `qwen3_moe_fsdp+tp+cp+ep_param_groups` | 5.5e-03 | 2.96522 -> 2.98026 | | `fake_pg/a10g/muse_glimmer.txt` | `muse_glimmer_text_fsdp` | 3.4e-04 | 6.71710 -> 6.71748 | | `real_pg/a10g/llama3.txt` | `llama3_fsdp+tp+cp`, `+region_ac` | 7.1e-05 | 4.05240 -> 4.05239 | | `real_pg/a10g/llama3_pp.txt` | `llama3_fsdp+tp+pp` | 6.3e-05 | 4.19607 -> 4.19609 | | `real_pg/a10g/deepseek_v3.txt` | `deepseek_v3_fsdp+ep` | 1.1e-04 | 3.81001 -> 3.81031 | | `real_pg/a10g/deepseek_v3_cp_pp.txt` | `deepseek_v3_fsdp+cp+pp+ep` | 2.5e-04 | 3.83078 -> 3.83064 | | `real_pg/a10g/gpt_oss_pp.txt` | `gpt_oss_pp+fsdp+cp+ep+sacop` | 1.7e-03 | 3.90803 -> 3.90858 | | `real_pg/a10g/qwen3.txt` | `qwen3_moe_fsdp+tp+cp+ep_param_groups` | 6.8e-05 | 5.34935 -> 5.34934 | | `real_pg/a10g/muse_glimmer.txt` | `muse_glimmer_text_fsdp` | 8.0e-03 | 3.71158 -> 3.70928 | Over 10 steps, last-bit differences grow more in some runs than others (`real_pg` `muse_glimmer` 8.0e-3, `gpt_oss_pp` 1.7e-3, `fake_pg` `qwen3` 5.5e-3). Final losses move in both directions. Fake PG grad norms are already meaningless (up to ~1e17) and change by more. `{fake_pg,real_pg}/a10g/sft.txt` are unchanged and still pass. `gpt_oss_fsdp+tp+ep` (`gpt_oss.txt`), and `gpt_oss_pp+fsdp+ep+sacop` in Real PG, crash under `dev20261125` for a separate reason. pytorch/pytorch#206398 made varlen's lse differentiable, and only FA4 can backpropagate through it. That is fixed in a separate PR, so this PR's Fake PG and Real PG jobs still fail on those two tests. ## Numerics The new values are the "Baseline metrics in import file format" blocks that `loss_compare` printed in the A10G CI logs under `dev20261125`. A10G numerics can't be reproduced off that hardware, so they come straight from CI. The values agree across runs: - Fake PG: #6395 (main HEAD deb3e43) == #6245 == #5678 == #6389. #5629 differs only in tests its own changes touch. - Real PG: main 7ccb1bb == d2a8af2 == 7a60bbb == 8919259 (the scheduled run). ## Testing - This PR's CI is the test. `ciflow/fake-pg` checks the 4 fake-PG files. `ciflow/real-pg` is added so the full Real PG suite checks all 7 real-PG files. The `real_pg_required` subset only covers `llama3_pp`, `deepseek_v3_cp_pp` and `gpt_oss_pp`. - The local bisection above used `python -m tests.integration_tests.run_tests --execution_mode fake_pg --ngpu 1 --test_name deepseek_v3_fsdp+ep` on GB300, with each torch/cuDNN combination as a `PYTHONPATH` overlay. - `pre-commit run` on the changed files passes. ## Known issues / follow-ups - `real_pg/mi350x/*` is not updated. The ROCm workflow (`integration_test_rocm.yaml`) still passes on main because the ROCm nightly index serves torch `dev20261119`, which predates #204322 (run 45670678052). Expect the same drift on MI350X once the ROCm nightly advances. Those goldens need a refresh from that run's logs then. - `real_pg/kimi_k3_b200.txt` (B200 workflow) and `rl_grpo_cuda.txt` (RL loss guard) are unaffected for now. Those jobs end up on pinned older torch (`dev20261102` and `dev20261107` in today's runs). Expect the same drift when their torch pins move past `dev20261125`. - The goldens track whatever nightly CI installs, so a later nightly can shift them again.
tianyu-l
added a commit
that referenced
this pull request
Nov 28, 2026
…ve workaround (#6389)" This reverts commit 8ab41b4. #6389 moves the KV offload code to vLLM 0.33 and says it depends on #5498 and #5967 (the vLLM 0.33 upgrade, still open); it landed first, so main runs it on the pinned vllm==1.0.0.dev20261107, where all three of its changes are wrong: - the nightly has no Scheduler.kv_holding_waiting (blocked requests wait in skipped_waiting), so test_kv_offload_coordination fails in RL CPU Unit Tests, VLLMSessionKVHolder reads a missing (FCFS) or never-filled (priority) queue, and KVOffloadScheduler's shared-ID queue replaces a dead attribute; - the nightly still chooses between the waiting and skipped_waiting heads (_select_waiting_queue_for_scheduling), whose shared-ID tie-break override was deleted, so TP ranks can pick different requests; - the nightly's kv_connector_no_forward still passes wait_for_save=False (vllm-project/vllm#69805), whose override was deleted, so Mooncake skips finish-time saves scheduled on a step without a forward. #6389 can reland on top of the vLLM 0.33 upgrade.
tianyu-l
added a commit
that referenced
this pull request
Nov 28, 2026
…ve workaround" (#6389) (#6428) ## Summary (human-written) <!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why this approach, and what you checked yourself. --> ## Why RL CPU Unit Tests fail on main since #6389: ``` FAILED tests/rl/unit_tests/cpu/test_kv_offload_coordination.py::test_terminal_cleanup_preserves_block_identity[FINISHED_ABORTED-True] AttributeError: 'KVOffloadScheduler' object has no attribute 'skipped_waiting' ``` #6389 moves the KV offload code to vLLM 0.33.0 and says it **depends on #5498 and #5967** (the vLLM 0.33 upgrade, both still open): "land this after them. Until then this PR's CI runs on the pinned nightly, where these changes fail." It landed first, so main runs it on the pinned `vllm==1.0.0.dev20261107` (`scripts/install_rl_env.sh`), where each of its three changes is wrong. Checked against that wheel's source: | #6389 change | On the pinned nightly | | --- | --- | | `skipped_waiting` -> `kv_holding_waiting` in `KVOffloadScheduler`, `VLLMSessionKVHolder` and tests | the nightly has no `kv_holding_waiting` (blocked requests wait in `skipped_waiting`): the CPU test fails; the holder reads a queue that is missing under FCFS and never filled under priority; the shared-ID queue replaces a dead attribute | | delete the `_select_waiting_queue_for_scheduling` override (shared-ID tie-break between the `waiting` and `skipped_waiting` heads) | the nightly still chooses between the two heads, by per-process request ID: TP ranks can pick different requests | | delete `worker.py`'s `kv_connector_no_forward` override and its test | the nightly still passes `wait_for_save=False` (vllm-project/vllm#69805): Mooncake skips finish-time saves scheduled on a step without a forward, silently | ## What changed `git revert` of #6389 (8ab41b4), clean: no later commit touches its files. #6389 can reland on top of the vLLM 0.33 upgrade. ## Alternatives considered - Renaming the queue back only (this PR's first revision): fixes the test but leaves the other two regressions on main. ## Testing - `pytest tests/rl/unit_tests/cpu`: 776 passed, 7 skipped (main: 2 failed); includes the restored `test_mooncake_coordination.py` test. - Not run: a GPU KV offload run; the reverted code ran on this vLLM pin before #6389.
wwwjn
added a commit
that referenced
this pull request
Dec 1, 2026
Conflicts: - generate.py: main builds the engine through VLLMEngine, so this PR's block-size and SP changes live in engine.py only. - vllm/engine.py: keep main's KV offload config; block size from vllm_block_size. - vllm/config.py, vllm/worker.py: keep main's KV-transfer and no-forward imports; drop PassConfig and round_up (unused here). - sglang/engine.py: keep main's SGLANG_RETURN_ORIGINAL_LOGPROB check; the deleted SP check stays deleted. - session_kv_holder.py and its test: take main's. Main now filters waiting requests by status (WAITING_FOR_REMOTE_KVS), which get_request_counts() cannot express. The vLLM 0.33 rename (skipped_waiting -> kv_holding_waiting) moves with the vLLM install (#6389).
wwwjn
pushed a commit
that referenced
this pull request
Dec 1, 2026
…round (#6389) <!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why this approach, and what you checked yourself. --> upgrade vlllm to 0.33.0 (the last v1 stable version) and address this issue vllm-project/vllm#69805 vLLM 0.33.0 fixes [vllm-project/vllm#69805](vllm-project/vllm#69805): `kv_connector_no_forward` now calls `wait_for_save`, so Mooncake submits finish-time saves scheduled on a step without a forward. On the pinned nightly (`9f03b510c`) it passes `wait_for_save=False`, which is why `worker.py` overrides it. This PR moves the KV offload code to vLLM 0.33 and drops that override. **Depends on #5498 and #5967** (felipemello1), which move the generator to vLLM 0.33.0; land this after them. Until then this PR's CI runs on the pinned nightly, where these changes fail. - `kv_offload_scheduler.py`, `session_kv_holder.py`: vLLM 0.33 replaced `skipped_waiting` with `kv_holding_waiting`, which it always drains before `waiting`. Rename the queue, and delete the `_select_waiting_queue_for_scheduling` override: there is no longer a choice between two queue heads to tie-break. - `worker.py`: delete the `kv_connector_no_forward` override and its TODO; delete its unit test in `test_mooncake_coordination.py`. - Tests (mechanical): fill in the `Scheduler` state 0.33 reads (`_kv_fetch_stages`, `deferred_loads`, ...) in the hand-built test schedulers. In `test_kv_offload.py`, on 0.33 the first request's tail no longer saves on an idle step, so the check that a finish-time save without forward ran now covers the whole test instead of the first request. main vs this PR on top of #5967. Stock Qwen3-0.6B AlphabetSort GRPO recipe (TP4 generator + 2-GPU trainer, B200), 12 steps, mean of steps 3-12, 3 runs each: | | main (vLLM nightly 11-07, torch 11-07) | this PR (vLLM 0.33.0, torch 11-24) | change | |---|---|---|---| | generator inter-token latency (ms) | 4.64 | 4.80 | +3% | | generator decode time per request (ms) | 143.6 | 149.5 | +4% | | step wall time (s) | 2.64 | 2.64 | 0% | | trainer tokens/s (full step) | 2110 | 2165 | +3% | Per-run inter-token latency: main 4.53 / 4.68 / 4.70, PR 4.96 / 4.85 / 4.58; the runs overlap, so the generator difference is within noise and step time is unchanged. These measure the vLLM/torch upgrade (#5967) as much as this PR. With #5498 and #5967 applied, on vLLM 0.33.0 + torch 2.16.0.dev20261124: - `tests/rl/unit_tests/cpu`: 738 passed except `test_vllm_multimodal_wrapper.py::test_controller_requires_a_vision_processor_exactly_for_multimodal_models` (needs `math_verify`, not installed locally); `test_dapo_math.py` / `test_geometry3k.py` not collected for the same reason. - `tests/rl/unit_tests/gpu/test_kv_offload.py`: 3 passed (the 8-GPU `dp2` case not run). - `generate.py` with vLLM, and with SimpleCPU offload: same text as main. - Mooncake Store end to end (2 generators x TP2, `save_decode_cache=True`, 4 steps): one master on the controller host, 4 segments mounted, ~350 keys loaded per generator, 0 failed loads or saves. (cherry picked from commit 8ab41b4)
Contributor
|
This change is now in #5967 (cherry-picked as 6458f37, authorship kept), so no separate reland is needed. #5967 moves RL to vLLM 0.33.0 and has to land together with this change: main's KV offload code fails on 0.33 without it, and it fails on the pinned nightly (#6428). #5956 (vLLM 0.34) adds one more KV offload fix on top: 0.34's |
This was referenced Dec 1, 2026
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.
Summary (human-written)
upgrade vlllm to 0.33.0 (the last v1 stable version) and address this issue vllm-project/vllm#69805
Why
vLLM 0.33.0 fixes vllm-project/vllm#69805:
kv_connector_no_forwardnow callswait_for_save, so Mooncake submits finish-time saves scheduled on a step without a forward. On the pinned nightly (9f03b510c) it passeswait_for_save=False, which is whyworker.pyoverrides it. This PR moves the KV offload code to vLLM 0.33 and drops that override.Depends on #5498 and #5967 (felipemello1), which move the generator to vLLM 0.33.0; land this after them. Until then this PR's CI runs on the pinned nightly, where these changes fail.
What changed
kv_offload_scheduler.py,session_kv_holder.py: vLLM 0.33 replacedskipped_waitingwithkv_holding_waiting, which it always drains beforewaiting. Rename the queue, and delete the_select_waiting_queue_for_schedulingoverride: there is no longer a choice between two queue heads to tie-break.worker.py: delete thekv_connector_no_forwardoverride and its TODO; delete its unit test intest_mooncake_coordination.py.Schedulerstate 0.33 reads (_kv_fetch_stages,deferred_loads, ...) in the hand-built test schedulers. Intest_kv_offload.py, on 0.33 the first request's tail no longer saves on an idle step, so the check that a finish-time save without forward ran now covers the whole test instead of the first request.Numerics / performance
main vs this PR on top of #5967. Stock Qwen3-0.6B AlphabetSort GRPO recipe (TP4 generator + 2-GPU trainer, B200), 12 steps, mean of steps 3-12, 3 runs each:
Per-run inter-token latency: main 4.53 / 4.68 / 4.70, PR 4.96 / 4.85 / 4.58; the runs overlap, so the generator difference is within noise and step time is unchanged. These measure the vLLM/torch upgrade (#5967) as much as this PR.
Testing
With #5498 and #5967 applied, on vLLM 0.33.0 + torch 2.16.0.dev20261124:
tests/rl/unit_tests/cpu: 738 passed excepttest_vllm_multimodal_wrapper.py::test_controller_requires_a_vision_processor_exactly_for_multimodal_models(needsmath_verify, not installed locally);test_dapo_math.py/test_geometry3k.pynot collected for the same reason.tests/rl/unit_tests/gpu/test_kv_offload.py: 3 passed (the 8-GPUdp2case not run).generate.pywith vLLM, and with SimpleCPU offload: same text as main.save_decode_cache=True, 4 steps): one master on the controller host, 4 segments mounted, ~350 keys loaded per generator, 0 failed loads or saves.