Repository navigation
[rl] Bitwise parity test: trainer vs vLLM decode, greedy and at temperature 0.8 - #5928
felipemello1 wants to merge 4 commits into
Conversation
|
Reply from claude: @claude review |
|
Claude finished @felipemello1's task in 1m 47s —— View job Approve, with two items to address before merging: fill in the human-written summary, and confirm the multi-GPU CI run at 04eb450 passes. Review |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. This is a test-only change. It closes a real gap: until now no test checked that the trainer's temperature-scaled logprobs match the generator's at T>0, and that is the ratio RL trains on.
What this PR does. It adds a parity test. vLLM samples 50 tokens at T=0.8, and the trainer prefills prompt + those tokens, divides the logits by a per-token fp32 tensor as DAPOLoss does (dapo.py:102), and must match the vLLM decode logprobs bitwise. It also switches the test engine to logprobs_mode="processed_logprobs", which the production engine already uses (engine.py:272). And vllm_generate now reads each logprob by the sampled token id instead of taking the first dict entry.
Example.
before: test engine on raw_logprobs, greedy only
vLLM decode logprob = log_softmax(logits)[tok] (no /T)
trainer = log_softmax(logits / T)[tok] (DAPOLoss)
-> no test compares the two; at T=0.8 they differ by up to 0.98
after: test engine on processed_logprobs, T=0.8, seed=0
vLLM decode logprob = log_softmax(fp32(logits).div_(T_fp32))[tok]
trainer = compute_logprobs(logits / full((T,), 0.8))[tok]
-> asserted bitwise equal at every generated position
Must fix
- The PR description's "Summary (human-written)" section is empty. Please fill it in.
- The Results table lists the run at 04eb450 (the commit that includes the
processed_logprobsfix) as pending. Please confirmRL Multi-GPU Unit Testspasses there and update the table. The test is meant to pass only because of that fix.
Should consider
tests/rl/unit_tests/gpu/test_bitwise_parity.py:338-- pin the per-token divisor todtype=torch.float32(inline).tests/rl/unit_tests/gpu/test_bitwise_parity.py:11-23-- the module docstring still says "Three tests" and argues "trainer == vLLM decode" by transitivity. The new test checks that directly, at T=0.8, so please add it to the list.
Details
- Necessity: the problem is real. The test engine reimplements engine construction (see the TODO at line 175) and had drifted from the production
logprobs_mode. The CI run at 3143c24 shows the gap (50/50 tokens differ). - Cost: the new test runs one sampled generate and one trainer prefill per class. Putting it on the base class extends existing coverage to every backend and model class (Flex, Qwen3.5 TP=2, MoE EP, Kimi K3, GPT-OSS) rather than adding a new suite, which follows
rules/tests.md. d[token]is safe: withlogprobs=1, vLLM always includes the sampled token in each step's dict. Addingseed=0changes nothing for the existing greedy callers.- The "Python float divisor multiplies by its reciprocal" comment matches PyTorch's CUDA
div_truekernel for a CPU scalar operand. - Under TP (Qwen3.5 TP=2),
logits.shape[0]is still the token dim, so the per-token broadcast is correct for vocab-sharded logits.
Not verified: bitwise equality at T=0.8 for the 04eb450 run (GPU CI pending). Also the V1-vs-V2 runner note in the description; this test is what would catch a change there.
| divisor would multiply by its reciprocal). ``temperature=None`` returns them unchanged.""" | ||
| if temperature is None: | ||
| return logits | ||
| per_token = torch.full((logits.shape[0],), temperature, device=logits.device) |
There was a problem hiding this comment.
The docstring says the divisor is fp32, and bitwise parity depends on that: vLLM's V1 sampler divides fp32 logits by an fp32 temperature tensor. But this tensor's dtype comes from torch.get_default_dtype(). Production sets it explicitly (torch.full_like(generator_logprobs, ...) in batcher.py:903). Pin it here too, so a default-dtype context left active by setup can't change what the test checks:
| per_token = torch.full((logits.shape[0],), temperature, device=logits.device) | |
| per_token = torch.full( | |
| (logits.shape[0],), temperature, dtype=torch.float32, device=logits.device | |
| ) |
There was a problem hiding this comment.
Reply from claude: Done in 0e7f4ba: the divisor is pinned to dtype=torch.float32. The module docstring now lists the new test (4 tests) and says the transitivity argument covers greedy tokens.
|
Claude finished @felipemello1's task in 1m 34s —— View job Request changes: at 0e7f4ba the new test also fails on Kimi K3 in |
There was a problem hiding this comment.
Verdict: Request changes -- at 0e7f4ba the new test also fails on Kimi K3 in RL H100 Integration Tests. Kimi K3's greedy parity tests pass there, so this failure is new, and the description doesn't mention it.
Re-review since the last automated review.
- Resolved: the per-token divisor is now pinned to fp32 (
test_bitwise_parity.py:341), and the module docstring lists the new test and limits the transitivity claim to greedy tokens. - Resolved: the
RL Multi-GPU Unit Testsresult at theprocessed_logprobsfix is now in the description. Varlen and Flex pass bitwise. - Still open: the "Summary (human-written)" section is empty.
Example (from the CI log, job 128352331978).
TestBitwiseParityKimiK3DebugVarlen (H100, TP=1, 128 tokens, T=0.8)
test_trainer_vs_vllm_prefill PASSED (greedy)
test_vllm_decode_vs_prefill PASSED (greedy)
test_trainer_vs_vllm_decode_at_temperature FAILED max_delta 4.33e-02, 95/128 differ
first 5 positions bitwise equal (-7.4213, -7.3997, -6.3708, -5.9912, -9.1480),
later positions drift (e.g. -6.6056 vs -6.5822)
Must fix
tests/rl/unit_tests/gpu/test_bitwise_parity.py:871--KimiK3BitwiseParityTestBaseinherits the new test, and it fails on H100.rl-kimi-k3runs this test before the other tests in its script, so merging turns that job red and the later tests there stop running. Kimi K3's greedy trainer-vs-vLLM tests pass, so this is not the pre-existing Qwen3.5 mismatch. The early positions match and the later ones drift, so the cause could be in the decode state on sampled tokens, not in the divide (unverified). Please find the root cause. Then either fix it, or skip the test for Kimi K3 with a TODO that links an issue and states the cause. Either way, add the Kimi K3 row to the Results table.- The PR description's "Summary (human-written)" section is still empty.
Should consider
TestBitwiseParityQwen35DebugVarlen: the new test fails there (max_delta 6.9e-4, 8/16), on top of the greedy prefill failure already on main. Please link the issue tracking that mismatch in the Results table. Then a maintainer can see that the failure is expected, and when the fix lands, this test confirms it.
Details
- The Kimi K3 failure is in the H100 log at 08:54:09.
RL Multi-GPU Unit Tests(job 128352280060) shows Varlen and Flex PASSED for the new test. Qwen35DebugVarlen failed both the new test andtest_trainer_vs_vllm_prefill. - Kimi K3 runs the trainer in
train()mode (KimiK3BitwiseParityTestBase.setUpClass) and generates 128 tokens, longer than any other class. With sampling, the generated tokens differ from the greedy run's, so the KDA recurrent state and the decode positions get coverage the greedy tests never gave them. The drift starts after the first few positions, which points at decode-state accumulation rather than a rounding difference inlogits / T. That is a hypothesis; I can't run it. - The rest of the diff is unchanged since the last review. I have nothing new on it.
Not verified: the root cause of the Kimi K3 mismatch (needs an H100 run).
|
Reply from claude: Kimi K3 root cause, as far as CI shows: the greedy case fails too (max_delta 3.2e-2, 95/128 tokens), so the temperature is not involved. Past the 64-token prompt the trainer's prefill differs from vLLM's decode, while the prompt-only parity test passes. Skipped for Kimi K3 in d6cb77f with a TODO that states the gap; an upstream issue needs the author's OK, so no link yet. At d6cb77f both RL GPU jobs are green, and Qwen35DebugVarlen passed the new test and its flaky prefill test. Results table updated. @claude review |
|
Claude finished @felipemello1's task in 1m 26s —— View job Approve, with two items to fix before merging: fill in the human-written summary, and reword the Kimi K3 TODO. The gap there is trainer prefill vs vLLM prefill past 64 tokens, not decode, and the TODO needs an issue link. Review |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. At d6cb77f both RL GPU jobs are green. The Kimi K3 failure turned out to be a trainer-vs-vLLM gap that also shows up greedy, so it is unrelated to the temperature. It is skipped with a TODO, which was one of the outcomes the last review accepted.
Re-review since the last automated review (0e7f4ba -> d6cb77f).
- Resolved: Kimi K3 no longer turns
RL H100 Integration Testsred.test_trainer_vs_vllm_decodenow also runs greedy, which separates the temperature from the sequence length. The Kimi K3 override skips it (test_bitwise_parity.py:1105), and the Results table has the Kimi K3 row. - Resolved: Qwen35DebugVarlen. Its prefill failure is flaky on
main(runs on 89dd0b8 and f548851), and both tests pass at d6cb77f. - Still open: the "Summary (human-written)" section is empty.
Example (Kimi K3, H100, greedy, what the four checks tell us).
trainer prefill(prompt, <=64 tok) == vLLM prefill(prompt) PASS
vLLM decode(gen) == vLLM prefill(prompt + gen) PASS
trainer prefill(prompt + gen, <=192 tok) vs vLLM decode(gen) FAIL 3.2e-2, 95/128
=> trainer prefill != vLLM prefill once the sequence goes past 64 tokens; decode is not involved
Must fix
- The PR description's "Summary (human-written)" section is still empty.
tests/rl/unit_tests/gpu/test_bitwise_parity.py:1101-1104-- the TODO points at the wrong side of the gap (see the inline comment). Also, add the issue link once you approve opening the issue. This is a real logprob mismatch between the Kimi K3 trainer and generator on any rollout longer than 64 tokens, which RL training hits, so it needs a tracked issue, not only a test skip.
Details
- The skip is a method override on
TestBitwiseParityKimiK3DebugVarlenonly. Every other class still runs the new test, greedy and at T=0.8. - The greedy subtest is not redundant with tests 2 and 3. Test 2 only covers prompt-length sequences (64 tokens for Kimi K3 and Qwen3.5 debug). The greedy case of test 4 is the only check on trainer prefill over prompt + generated length. It is what found the Kimi K3 gap.
temperature=None if temperature == 0.0 else temperaturematches production, where greedy means no divide. Cost: the test now runs two generates and two trainer prefills per class, which is still small next to setUpClass.- No changes outside the Kimi K3 override and the greedy loop since the last review.
Not verified: which kernel causes the Kimi K3 gap past 64 tokens (needs an H100 run).
| # TODO: past the 64-token prompt, the trainer's prefill differs from vLLM's decode, greedy | ||
| # too: max_delta 3.2e-2 on 95 of 128 generated tokens (H100 CI). The prompt-only | ||
| # test_trainer_vs_vllm_prefill passes, so the gap starts after the prompt. Find the | ||
| # kernel that differs there (KDA's chunked prefill is a candidate), then drop this skip. |
There was a problem hiding this comment.
The TODO says the trainer differs from "vLLM's decode", but for this class test_vllm_decode_vs_prefill passes on H100: vLLM decode == vLLM prefill of prompt + generated tokens. So the gap is trainer prefill vs vLLM prefill once a sequence runs past the prompt (up to 64 + 128 = 192 tokens). Decode is not involved. That moves the search from the decode KV/recurrent state to the prefill kernels, and it explains why the prompt-only test passes: it never goes past 64 tokens. Please reword it so whoever picks this up starts in the right place, and add the issue link once you open the issue:
| # TODO: past the 64-token prompt, the trainer's prefill differs from vLLM's decode, greedy | |
| # too: max_delta 3.2e-2 on 95 of 128 generated tokens (H100 CI). The prompt-only | |
| # test_trainer_vs_vllm_prefill passes, so the gap starts after the prompt. Find the | |
| # kernel that differs there (KDA's chunked prefill is a candidate), then drop this skip. | |
| # TODO: on sequences longer than the prompt (up to 64 + 128 tokens), the trainer's prefill | |
| # differs from vLLM's, greedy too: max_delta 3.2e-2 on 95 of 128 generated tokens (H100 | |
| # CI). vLLM decode == vLLM prefill here (test_vllm_decode_vs_prefill passes), and the | |
| # prompt-only test_trainer_vs_vllm_prefill (<= 64 tokens) passes, so the gap is trainer vs | |
| # vLLM prefill past 64 tokens. Find the kernel that differs there (KDA's chunked prefill | |
| # is a candidate), then drop this skip. |
There was a problem hiding this comment.
Reply from claude: Done in e2aaf2e, with your wording. The issue link waits for the author's OK to open the issue.
|
Reply from claude: @claude review |
|
Claude finished @felipemello1's task in 38s —— View job Approve, with two items to fix before merging: the Kimi K3 TODO wording is now fixed, but the human-written summary is still empty, and the TODO still needs an issue link. Review |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. The only change since d6cb77f is a comment: the Kimi K3 TODO now points at the right side of the gap. Both RL GPU jobs were green at d6cb77f, and a comment-only edit can't change that.
Re-review since the last automated review (d6cb77f -> e2aaf2e).
- Resolved: the TODO at
tests/rl/unit_tests/gpu/test_bitwise_parity.py:1101-1106now says the gap is trainer prefill vs vLLM prefill past 64 tokens, and that decode is not involved. - Still open: the "Summary (human-written)" section is empty.
- Still open: the TODO has no issue link.
Example (Kimi K3, H100, greedy; what the TODO now records).
trainer prefill(prompt, <=64 tok) == vLLM prefill(prompt) PASS
vLLM decode(gen) == vLLM prefill(prompt + gen) PASS
trainer prefill(prompt + gen, <=192 tok) vs vLLM decode(gen) FAIL 3.2e-2, 95/128
=> trainer prefill != vLLM prefill past 64 tokens
Must fix
- Fill in the "Summary (human-written)" section of the PR description.
tests/rl/unit_tests/gpu/test_bitwise_parity.py:1101-- file the Kimi K3 issue (the author has to approve the draft) and put its link in the TODO. Any Kimi K3 rollout longer than 64 tokens has a trainer-vs-generator logprob mismatch, and RL training hits that. A test skip alone won't keep it tracked.
Not verified: which kernel causes the Kimi K3 gap past 64 tokens (needs an H100 run).
…rature 0.8 The GPU parity tests compared the trainer with vLLM only on the prompt, and decoded greedily. The new test_trainer_vs_vllm_decode prefills prompt + generated tokens with the trainer and compares them with vLLM's decode logprobs, greedy and sampled at T=0.8. The trainer passes a per-token fp32 temperature to compute_logprobs, as the batcher does. Every rank runs both temperatures before rank 0 asserts, so a failure can't strand a rank in a TP collective. The test engine now sets logprobs_mode="processed_logprobs", as the production Generator does; with vLLM's default raw_logprobs, the T=0.8 logprobs came before the divide. Kimi K3 skips the new test: its trainer and vLLM prefill differ past the first generated tokens, greedy too (TODO at the skip).
e2aaf2e to
d5b6c3c
Compare
|
Reply from claude: Round of fixes in d5b6c3c (one commit on main): both temperatures run on every rank before rank 0 asserts (no subTest, so a failure can't strand a rank in a TP collective); the trainer passes a per-token fp32 temperature to compute_logprobs, as main does since #5921; comment and TODO fixes; body rewritten with results per class. @claude review |
|
Claude finished @felipemello1's task in 1m 39s —— View job Approve, with three items to address before merging: fill in the human-written summary, add the issue link and the decode == prefill evidence to the Kimi K3 TODO, and confirm the RL GPU and H100 jobs pass at d5b6c3c. Review |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. d5b6c3c drops the test-local divide helper. The test now goes through compute_logprobs(..., temperature=<per-token fp32>), the same path the batcher feeds (batcher.py:903). That makes the T=0.8 check cover the production op, not a copy of it. Every remaining item is a description or comment edit.
Re-review since the last automated review (e2aaf2e -> d5b6c3c).
- Resolved: the trainer side uses
compute_logprobs'stemperatureargument (test_bitwise_parity.py:385-387,429-431).full_like(labels, T, dtype=float32)has shape[T], which matches the logits rows on both the varlen and the padded flex paths. Under TP, the divide is elementwise on each vocab shard before the gather, so the result is unchanged. - Resolved: both temperatures run on every rank before rank 0 asserts (
:870-903). This follows the pattern already used intest_reload_after_generate. - Still open: the "Summary (human-written)" section is empty.
- Still open: the Kimi K3 TODO has no issue link.
Example (what the new test now checks against main's loss path).
vLLM (V1 sampler, processed_logprobs): log_softmax(fp32(logits) / T_fp32[req])[tok]
trainer: compute_logprobs(logits, labels, temperature=full_like(labels, 0.8, fp32))
-> logits / temperature.unsqueeze(-1).expand_as(logits) (loss.py:530)
check: bitwise equal at every generated position, T in {0.0, 0.8}
Must fix
- The PR description's "Summary (human-written)" section is empty.
tests/rl/unit_tests/gpu/test_bitwise_parity.py:1097-- add the issue link once you approve filing it. The rewritten TODO also dropped the "vLLM decode == vLLM prefill" evidence, and it now names only the generator's KDA as the candidate (see the inline comment).- CI at d5b6c3c is still running (
RL GPU Unit Tests,RL H100 Integration Tests). The trainer side now goes through a different code path than at d6cb77f, so please confirm both jobs are green and fill in the "pending" row of the Results table.
Details
- The
VLLM_USE_V2_MODEL_RUNNERcomment rewrite (:202) fixes a comment that contradicted the code next to it ("v2 runner is required" next to= "0"). It matchesengine.py:212, so it is in scope. - Removing the
By transitivityline is correct. Test 4 now checks trainer == vLLM decode directly. seed=0doesn't change the greedy callers (test_vllm_decode_vs_prefill, batch invariance, reload).- Prompt length 64 equals the generator's KDA
_CHUNK_SIZE(kda.py:48). That is why the Kimi K3 gap shows up only once a sequence goes past the prompt.
Not verified: bitwise equality at d5b6c3c (GPU CI pending); which side's KDA chunk handling causes the Kimi K3 gap.
| # TODO: trainer and vLLM prefill differ on prompt + generated tokens, greedy too (seq 0 on H100: | ||
| # the first 5 generated tokens match, 33 of 128 match, max_delta 3.2e-2). The prompt-only test | ||
| # passes. The generator's chunked KDA prefill (paged_chunk_kda) is a candidate. |
There was a problem hiding this comment.
This rewrite lost two things from the version at e2aaf2e.
- The evidence that decode is not involved:
test_vllm_decode_vs_prefillpasses for this class. - The candidate now points only at the generator side. The evidence fits either side's KDA prefill equally well. The generator's
paged_chunk_kdauses_CHUNK_SIZE = 64(torchtitan/rl/generator/vllm/attention/kda.py:48), and the prompt is exactly 64 tokens. So the prompt-only test never crosses a chunk boundary, and this test is the first one that does. Whoever picks this up should compare how the trainer's and the generator's KDA carry state across chunks, not only look atpaged_chunk_kda.
| # TODO: trainer and vLLM prefill differ on prompt + generated tokens, greedy too (seq 0 on H100: | |
| # the first 5 generated tokens match, 33 of 128 match, max_delta 3.2e-2). The prompt-only test | |
| # passes. The generator's chunked KDA prefill (paged_chunk_kda) is a candidate. | |
| # TODO: trainer and vLLM prefill differ on prompt + generated tokens, greedy too (seq 0 on H100: | |
| # the first 5 generated tokens match, 33 of 128 match, max_delta 3.2e-2). vLLM decode == vLLM | |
| # prefill here (test_vllm_decode_vs_prefill passes), and the prompt-only test (64 tokens, one | |
| # 64-token KDA chunk) passes, so compare how the trainer's and the generator's (paged_chunk_kda) | |
| # chunked KDA prefill carry state across chunk boundaries. |
There was a problem hiding this comment.
Reply from claude: done in d64ed6c. The TODO keeps both pieces of evidence in 3 lines: the 64-token prompt (one KDA chunk) matches, and vLLM decode matches its prefill (H100 run 42361174677 at e2aaf2e: test_vllm_decode_vs_prefill and test_trainer_vs_vllm_prefill passed). So the next step is to compare how the trainer and paged_chunk_kda carry KDA state across chunks. The first-5-tokens count and max delta stay in the body and the issue draft.
The trainer vs vLLM gap past the prompt is not in vLLM decode (it matches vLLM prefill) and not in a single KDA chunk (the 64-token prompt matches). Point the TODO at how the trainer and paged_chunk_kda carry KDA state across chunks.
|
Reply from claude: @claude review |
|
Claude finished @felipemello1's task in 43s —— View job Approve, with two items to address before merging: fill in the human-written summary, and add the issue link to the Kimi K3 TODO. Review |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. The only change since d5b6c3c is a comment. Both RL GPU jobs pass at d5b6c3c (RL GPU Unit Tests 42362733852: 1-GPU and multi-GPU jobs pass; RL H100 42362733871: rl-kimi-k3 passes).
Re-review since the last automated review (d5b6c3c -> d64ed6c).
- Resolved: the Kimi K3 TODO (
tests/rl/unit_tests/gpu/test_bitwise_parity.py:1097-1099) again records that vLLM decode == vLLM prefill and that the 64-token prompt (PROMPT_LENGTH = 64at:1090, one KDA chunk) matches. It now points at both sides: how the trainer andpaged_chunk_kdacarry KDA state across chunks. - Resolved: CI at d5b6c3c is green, and the Results table has the numbers.
- Still open: the "Summary (human-written)" section is empty.
- Still open: the Kimi K3 TODO has no issue link.
Example (Kimi K3, H100, greedy; what the TODO now records).
trainer prefill(prompt, 64 tok = 1 KDA chunk) == vLLM prefill(prompt) PASS
vLLM decode(gen) == vLLM prefill(prompt + gen) PASS
trainer prefill(prompt + gen, > 1 chunk) vs vLLM decode(gen) FAIL, 33/128 match
=> the gap opens at the KDA chunk boundary, trainer vs generator prefill
Must fix
- Fill in the "Summary (human-written)" section of the PR description.
tests/rl/unit_tests/gpu/test_bitwise_parity.py:1097-- add the issue link to the TODO once you approve filing the drafted issue. Every Kimi K3 rollout longer than 64 tokens has a trainer-vs-generator logprob mismatch, so the gap needs an issue to track it, not only a skipped test. The same goes for the Qwen35DebugVarlen flake mentioned in the Results section.
Not verified: CI at d64ed6c is still queued. It is a comment-only change, so I expect the same results as d5b6c3c.
## Summary (human-written) Reject non-positive training sampling temperatures (`generator.sampling.temperature <= 0`) at config time in `Controller.Config.__post_init__`. Previously, setting `0.0` (greedy) built without error and produced `NaN` logprobs, loss, and gradients when `compute_logprobs` divided logits by temperature, while also repeating identical rollouts with all-zero group-relative advantages. Keeping the check in `Controller.Config` rather than `SamplingConfig` leaves greedy validation (`async_loop.validation.temperature=0`) unaffected, and `test_greedy_training_sampling_raises` guards against regressions. ## Why `SamplingConfig.temperature` documents `0.0 = greedy`, and `Controller.Config` accepts it as the training sampling temperature. The controller hands `generator.sampling.temperature` to the `Batcher`, which fills every microbatch's `temperature[T]` with it, and `compute_logprobs` scores tokens under `softmax(logits / temperature)`. At 0 the trainer's logprobs, loss and gradients become NaN. A greedy group also repeats one rollout, so its group-relative advantages are all 0. Validation already rejects greedy sampling with more than one sample per prompt (#6266), and the trainer-vs-vLLM parity test in #5928 scores greedy tokens with `temperature=None` rather than 0. Training has no such check. **Example.** `rl_grpo_qwen3_5_debug_varlen(seq_len=128)` with `generator.sampling.temperature=0.0`: ``` main: the config builds; DAPOLoss with temperature[T] = 0 gives loss=nan, non-finite logits gradients and entropy nan (T = 0.8: loss 0.0964, finite) this PR: ValueError: generator.sampling.temperature must be positive, got 0.0: the trainer divides the logits by it. For greedy validation, set async_loop.validation.temperature=0. ``` ## What changed - `Controller.Config.__post_init__` raises `ValueError` when `generator.sampling.temperature <= 0`. - `test_greedy_training_sampling_raises` builds the CI recipe with temperature 0 and expects the error. It catches the check being dropped, which would let a greedy training config train on NaN again. ## Alternatives considered - Check in `SamplingConfig.__post_init__`: validation reuses it through `dataclasses.replace(self._sampling, temperature=validation.temperature)`, so greedy validation would break. - Score greedy tokens without the divide, as #5928's test does: removes the NaN, but a greedy group still trains on all-zero advantages. ## User-facing changes | Before | After | | --- | --- | | `generator.sampling.temperature=0.0` builds and trains on NaN loss | `ValueError` at config time | | `async_loop.validation.temperature=0` (greedy validation) | unchanged | ## Testing WSL2 Ubuntu 24.04, Python 3.12, torch `2.16.0.dev20261123+cpu`, vLLM `1.0.0.dev20261107+cu132` with `VLLM_TARGET_DEVICE=cpu`, base `3f09e7b` and this branch. - `pytest tests/rl/unit_tests/cpu/test_async_controller.py -k greedy_training_sampling`: fails on `main` with `DID NOT RAISE <class 'ValueError'>`, passes on this branch. - `pytest tests/rl/unit_tests/cpu --ignore=tests/rl/unit_tests/cpu/test_dapo_math.py --ignore=tests/rl/unit_tests/cpu/test_geometry3k.py`: `main` 702 passed, 1 failed, 10 skipped; this branch 703 passed, 1 failed, 10 skipped. The failure on both is `test_controller_requires_a_vision_processor_exactly_for_multimodal_models` (`No module named 'math_verify'` in my environment). The two ignored modules need their example dependencies to collect. - Every zero-argument recipe in `torchtitan_recipes/rl` and `torchtitan_recipes/tests/rl` that imports without optional packages (43, at temperature 0.8 or 1.0) builds on both `main` and this branch. Training temperatures 1.0, 0.8 and 1e-3, and greedy validation with a training temperature of 0.8, still build. - On this branch merged with current `main` (`8919259`): `test_async_controller.py` 55 passed. With `main`'s `controller.py`, the new test fails with `DID NOT RAISE`. - `pre-commit run --files` on the two changed files: flake8, ufmt, pydoclint and codespell pass. Pyrefly reports the same diagnostics on these files on `main` and this branch (RL packages missing on my Windows checkout). **AI assistance disclosure:** AI-assisted development tools were used during investigation, implementation, and regression testing. I personally reviewed the final diff, verified the correctness of the changes and validation results, and take full responsibility for the contribution.
Summary (human-written)
Agent details
TLDR: A GPU parity test that runs the real vLLM engine, samples tokens greedy and at T=0.8, and checks that the trainer's logprobs for those generated tokens are bitwise equal to vLLM's. It found two gaps: the test engine returned logprobs before the temperature divide, and Kimi K3's trainer and vLLM differ past the first generated tokens.
Problem
tests/rl/unit_tests/cpu/test_losses.py:24checksDAPOLossagainst a copy of vLLM's op on CPU. Nothing runs the real vLLM engine at a temperature.raw_logprobs, unlike the Generator. At T=0.8 it returned logprobs from before the divide: max delta 0.98 on CI.Solution
test_trainer_vs_vllm_decode: vLLM generates greedy and at T=0.8 (seed 0). The trainer prefills prompt + generated tokens and passes a per-token fp32 temperature tocompute_logprobs, as the batcher does. Every rank runs both temperatures, then rank 0 asserts, so a failure can't strand a rank in a TP collective.logprobs_mode="processed_logprobs", as the Generator does.compute_logprobs.Results
Qwen35Debug is flaky in this job. The class's existing prompt-only
test_trainer_vs_vllm_prefillalso fails on somePR runs that include #5941 (3 of 6 since 11-08, max delta 9e-4 to 1.8e-3); main passed 7 of 7. At 9382daa and
0e7f4ba the new test failed in the same run as the prompt-only test. At the head it failed alone, so the new test
adds a way for the job to fail.
Test plan
ciflow/rl):RL GPU Unit Testsruns Varlen, Flex and Qwen35DebugVarlen;RL H100 Integration Testsruns KimiK3DebugVarlen.