Skip to content

[rl] Fix RL CPU unit tests resolving a month-old torch nightly - #5083

Merged
wwwjn merged 2 commits into
pytorch:mainfrom
wwwjn:fix-rl-cpu-unit-test-nightly-resolution
Oct 6, 2026
Merged

wwwjn merged 2 commits into
pytorch:mainfrom
wwwjn:fix-rl-cpu-unit-test-nightly-resolution

Conversation

@wwwjn

@wwwjn wwwjn commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Why

RL CPU Unit Tests is red on main and on every PR that runs it. Four test modules fail at collection:

ERROR tests/rl/unit_tests/cpu/test_alphabet_sort.py
ERROR tests/rl/unit_tests/cpu/test_verifiers_example.py
ERROR tests/rl/unit_tests/cpu/test_vllm_registry.py
ERROR tests/rl/unit_tests/cpu/test_vllm_wrapper.py
E   ImportError: cannot import name 'analyze_pipeline_activation_liveness' from 'torch.distributed.pipelining'

The cause is the torch the job ends up with. The CPU job resolves torch 2.15.0.dev20260830 + vllm 1.0.0.dev20260830, while the RL GPU jobs in the same run get 20261005 for both. The CPU job installs the Verifiers example requirements first and then passes them as a --constraint to the nightly install:

  • verifiers==0.3.1 requires mcp>=1.24.0,<2.
  • vLLM nightlies since about 2026-10-01 require mcp>=2.0.0,<3.0.0.

uv therefore falls back to the newest vLLM that accepts mcp 1.x (1.0.0.dev20260830), which pins a torch from the same day. That torch predates analyze_pipeline_activation_liveness, which dist_moe started importing in #4541.

To reproduce, force a current vLLM next to the Verifiers requirements:

$ uv pip compile in.txt --prerelease allow ... # vllm>=1.0.0.dev20261001, verifiers==0.3.1
  × No solution found when resolving dependencies:
  ╰─▶ Because vllm>=1.0.0.dev20261001+cu132 depends on mcp>=2.0.0,<3.0.0 [...]
      And because you require mcp>=1.24.0,<2, we can conclude that your
      requirements are unsatisfiable.

What

  • Install torch/torchvision/vLLM nightlies the same way the RL GPU jobs do (no Verifiers constraint), then run the CPU suite. The plain DAPO example requirements (torchtitan/rl/examples/dapo_math/requirements.txt, i.e. math-verify==0.9.0 for test_dapo_math.py) are still installed first and passed as a constraint. They resolve fine with the current nightlies.
  • After that, install the Verifiers requirements with the installed torch/torchvision/vLLM versions as constraints, and run test_verifiers.py and test_verifiers_example.py. Verifiers only changes its own dependencies: uv swaps mcp 2.x -> 1.30.0 and websockets 17.1 -> 16.1.1 and leaves the nightlies alone.
  • Add pytest.importorskip("verifiers") to test_verifiers.py, the same guard test_verifiers_example.py already has, so the first run skips it instead of failing at collection.
  • Drop the mcp>=1.24.0,<2 line from dapo_math/requirements.txt. It only existed to constrain the nightly install, and verifiers==0.3.1 already requires the same bound.

Tests

Run locally with torch 2.15.0.dev20260926 and vLLM 1.0.0.dev20260926 (mcp 2.2.0):

  • First run, without Verifiers: pytest tests/rl/unit_tests/cpu gives 474 passed, 6 skipped. That includes the three non-Verifiers modules above; both Verifiers files skip with "could not import 'verifiers'".
  • Second run, with verifiers==0.3.1 installed on top: test_verifiers.py and test_verifiers_example.py give 11 passed, and vLLM still imports with mcp 1.30.0.
  • Dry run of the new uv pip install -r .../requirements.txt --constraint <nightly pins> against that env: it installs 19 packages, changes only mcp and websockets, and leaves torch/torchvision/vLLM untouched.
  • uv pip compile of the nightlies plus math-verify==0.9.0 resolves to torch/vLLM 20261005.
  • CI on the first commit picked up torch/vLLM 20261005, but test_dapo_math.py failed to collect because math_verify was missing. That's fixed by the DAPO requirements step above.

Follow-up

Outside CI, the Verifiers example still can't share an environment with current vLLM nightlies, since verifiers==0.3.1 needs mcp<2. The verifiers 0.3.2 dev releases move to mcp==2.0.0, but they also require renderers>=0.1.12.dev2, while torchtitan pins renderers==0.1.11. Bumping verifiers makes sense once a 0.3.2 release is out.

The RL CPU job installed the Verifiers example requirements first and used
them as constraints for the torch/vLLM nightly install. verifiers==0.3.1
requires mcp<2, but vLLM nightlies since ~2026-10-01 require mcp>=2, so uv
fell back to vllm 1.0.0.dev20260830, which pins torch 2.15.0.dev20260830.
That torch lacks torch.distributed.pipelining.analyze_pipeline_activation_liveness
(used by dist_moe since pytorch#4541), so four test modules failed at collection.

Install the nightlies the same way as the RL GPU jobs, run the CPU suite,
then install the Verifiers requirements with torch/torchvision/vLLM held
fixed and run the two Verifiers test files. Add the importorskip guard that
test_verifiers_example.py already has to test_verifiers.py so the first run
skips it, and drop the mcp pin that only existed to constrain the nightly
install (verifiers==0.3.1 already requires mcp<2).
@pytorch-bot pytorch-bot Bot added ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl labels Oct 6, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 6, 2026
test_dapo_math.py imports math_verify through the DAPO math rubric. It used
to come from the Verifiers requirements, which now install after the main
suite. Install torchtitan/rl/examples/dapo_math/requirements.txt up front
and constrain the nightly install with it; math-verify==0.9.0 resolves with
the current torch/vLLM nightlies.
@tianyu-l

tianyu-l commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@claude review this PR

@claude

claude Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 1m 23s —— View job


PR Review: Fix RL CPU unit tests resolving a month-old torch nightly

  • Gather context (diff, workflow, tests)
  • Review workflow changes
  • Review test/requirements changes
  • Post review

I think this PR is good to merge. The diagnosis holds up: verifiers==0.3.1 needs mcp<2, and vLLM nightlies since about 2026-10-01 need mcp>=2. Resolving them together makes uv fall back to an older vLLM, which pins an older torch. The fix is to install the nightlies first, then add Verifiers on top with the installed torch/torchvision/vllm versions as constraints. That keeps the Verifiers tests running without letting them choose the nightlies. I have one small suggestion and a few nits, none blocking.

Suggestion

1. Second install doesn't use .ci/docker/requirements.txt as a constraint (.github/workflows/unit_test_cpu_rl.yaml:94-95)

uv pip install -r torchtitan/rl/examples/verifiers/dapo_math/requirements.txt \
  --constraint "${RUNNER_TEMP}/nightly-constraints.txt"

Only torch, torchvision and vllm are pinned here. Nothing stops Verifiers from moving other packages the repo pins, such as renderers == 0.1.11, datasets < 4.8.0 and spmd_types. Your dry run shows that verifiers==0.3.1 only changes mcp and websockets today. But the PR's own Follow-up says the next Verifiers release (0.3.2) wants renderers>=0.1.12.dev2, so this is exactly the kind of drift that could happen without anyone noticing. With --constraint .ci/docker/requirements.txt added, it would fail to resolve loudly instead of quietly changing a pinned package:

uv pip install -r torchtitan/rl/examples/verifiers/dapo_math/requirements.txt \
  --constraint .ci/docker/requirements.txt \
  --constraint "${RUNNER_TEMP}/nightly-constraints.txt"

xformers is also installed in the nightly step but isn't in nightly-constraints.txt. It's unlikely Verifiers touches it, but adding it to the for name in (...) tuple would make "leave the nightlies alone" fully true.

(I can't push changes under .github/workflows/ because of GitHub App permissions, so this one is yours to apply.)

Nits

  • set -e hides the Verifiers result when the main suite fails. If pytest tests/rl/unit_tests/cpu fails, the Verifiers step never runs, so a single red run can't tell you whether Verifiers is also broken. That's probably fine for now. Just be aware of it when you triage.
  • User-facing docs. torchtitan/rl/examples/verifiers/dapo_math/README.md:16 still says to pip install -r .../requirements.txt on top of the TitanRL setup. With current nightlies, that now quietly downgrades mcp to 1.x under vLLM. You showed vLLM still imports with mcp 1.30.0, so this isn't broken. A one-line note, or a pointer to the Follow-up about moving to Verifiers 0.3.2, could save users some confusion. This can wait for the follow-up.
  • Removing the mcp line from verifiers/dapo_math/requirements.txt. Removing it is right: verifiers==0.3.1 already declares mcp>=1.24.0,<2, and the line only existed to steer the old combined --constraint resolution. Nothing else in the repo references it. I checked the other RL workflows, the READMEs and the .ci/docker requirement files.

What looks good

  • Switching the first install and constraint to torchtitan/rl/examples/dapo_math/requirements.txt (math-verify==0.9.0) brings back the dependency test_dapo_math.py needs, without the mcp<2 constraint.
  • pytest.importorskip("verifiers") in test_verifiers.py matches the guard in test_verifiers_example.py. It sits before the torchtitan.rl.examples.verifiers.* imports, so collection skips cleanly in the first run. Those two files are the only CPU tests that use Verifiers, so the second pytest call covers all of it.
  • Writing the pins to ${RUNNER_TEMP} and reusing the existing importlib.metadata approach keeps the change small and consistent with the version check above it.
  • The workflow comment explains why the step order matters, so nobody "simplifies" it back into one install later.

@tianyu-l tianyu-l left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see if what claude says makes sense

@wwwjn
wwwjn merged commit bfddc6b into pytorch:main Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants