Skip to content

[rl] Add RL unit tests to CI - #4889

Merged
wwwjn merged 24 commits into
mainfrom
feat/rl-unit-tests-ci
Sep 28, 2026
Merged

wwwjn merged 24 commits into
mainfrom
feat/rl-unit-tests-ci

Conversation

@wwwjn

@wwwjn wwwjn commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Why

RL tests were outside the CPU/GPU unit-test workflows, so most RL coverage did not run in CI.

Changes

  • Organize RL unit tests and distributed integration tests under tests/rl/.
  • Publish a separate CUDA RL image variant under an rl- prefixed tag. Keep the original five RL runtime dependencies (Monarch, OpenTelemetry SDK and OTLP exporter, pygtrie, portpicker) in torchtitan/rl/requirements.txt; the Docker build-context requirements contain the same five.
  • Install uv, torch, torchvision, vLLM, xformers, and TorchStore in the RL test YAMLs. Install matching CUDA nightlies for torch, torchvision, and vLLM; install TorchStore from Git with --no-deps after nightlies. Constrain nightly resolution using the existing core datasets bound.
  • Keep the Verifiers and Math-Verify DAPO example dependencies optional. The RL unit workflow installs the example requirements separately and constrains MCP 1.x.
  • Add separate RL CPU/GPU unit-test workflows aligned with the RL integration triggers and a test-status badge table to the RL README.
  • Download only public Muse Glimmer tokenizer files into a writable temporary CI cache so renderer parity tests run without model weights or changes to the shared HF cache.
  • Use existing CI triggers: images build automatically on main Docker changes or via the existing ciflow/docker PR label; RL unit tests run automatically on pull requests and main. No RL-specific tag triggers are required.
  • Rebase onto the latest main and preserve its OSDC BuildKit image builder.

Validation

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 25, 2026
@wwwjn
wwwjn force-pushed the feat/rl-unit-tests-ci branch 3 times, most recently from b35f945 to b788ac2 Compare September 25, 2026 23:15
@wwwjn wwwjn changed the title WIP: Add RL unit tests to CI [WIP][rl] Add RL unit tests to CI Sep 25, 2026
@wwwjn
wwwjn force-pushed the feat/rl-unit-tests-ci branch from 8ff39e5 to 9fa95af Compare September 26, 2026 19:56
@wwwjn wwwjn changed the title [WIP][rl] Add RL unit tests to CI [rl] Add RL unit tests to CI Sep 26, 2026
@wwwjn
wwwjn marked this pull request as ready for review September 26, 2026 21:54
@pytorch-bot pytorch-bot Bot added ciflow/docker ciflow/fake-pg Run 1-GPU Fake PG integration tests labels Sep 26, 2026
pip_install -r /opt/conda/requirements-vlm.txt
pip_install -r /opt/conda/requirements-transformers-modeling-backend.txt
# --no-deps: the image ships no torch on purpose, every job installs a nightly.
if [[ "${INSTALL_RL_DEPS:-0}" == "1" ]]; then

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.

why do we need this flag -- is it because for non-RL test we don't need that in docker image?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes this is a flag to decide if we want to install RL dependencies in docker image. I want to prevent pretraining docker image installing something like vllm, to keep it simple

Comment thread .github/workflows/set-matrix.yaml Resolved

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.

  1. should name this GPU?
  2. where do we do RL CPU test?

Comment thread .github/workflows/unit_test_gpu_rl.yaml Outdated

# TODO: test_gdn_full_runner_matches_eager skips here because
# TORCHTITAN_QWEN3_5_0_8B_HF_PATH is unset. The Hugging Face Qwen3.5-0.8B
# checkpoint ties its embeddings, and the torchtitan 0.8B config does not

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Need #4916 land first to reenable it

@wwwjn
wwwjn requested a review from tianyu-l September 28, 2026 17:06
@wwwjn
wwwjn force-pushed the feat/rl-unit-tests-ci branch from 88eff45 to fb37f11 Compare September 28, 2026 17:10
Comment thread .github/labeler.yml
Comment on lines 16 to +29
"ciflow/rl":
- torchtitan/rl/**
- tests/rl/**
- scripts/rl/**
- torchtitan/trainer.py
- torchtitan/components/checkpointer/**
- torchtitan/components/data/**
- torchtitan/distributed/cuda_graph.py
- torchtitan/models/common/**
- torchtitan/models/qwen3_5/**
- torchtitan/models/qwen3_8/**
- .github/workflows/integration_test_8gpu_rl.yaml
- .github/workflows/unit_test_cpu_rl.yaml
- .github/workflows/unit_test_gpu_rl.yaml

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.

This might have been introduced by me? Feels that it could be revisited.

Mirror the core unit test layout (tests/unit_tests/{cpu,gpu} with a
multi_gpu marker):

- tests/rl/unit_tests/cpu: every RL unit test that needs no GPU, run on the
  CPU runner used by the core CPU unit tests.
- tests/rl/unit_tests/gpu: the GDN cudagraph tests on one A10G, and the
  bitwise parity and uneven-decode tests, marked multi_gpu and run under
  one torchrun launch each on the 8x A10G runner.

The bitwise parity and uneven-decode tests move out of the RL integration
workflow, and the duplicate test_vllm_wrapper.py run there is dropped: that
test is CPU-only and is covered by the CPU job. The integration workflow now
runs only the loss guard and the end-to-end suite.
VllmConfig() infers its device from the current platform, so these tests
fail with 'Failed to infer device type' on the CPU runner, which has no
NVIDIA driver. They exercise CUDA graph dispatch metadata, so run them in
the 1-GPU job.
Split unit_tests_rl.yaml into unit_test_cpu_rl.yaml (RL CPU Unit Tests) and
unit_test_gpu_rl.yaml (RL GPU Unit Tests: the 1-GPU and multi-GPU jobs),
following the core unit_test_cpu.yaml / unit_test_gpu.yaml naming.

Also show both badges in the RL README, add the two workflows to the
ciflow/rl labeler paths so edits to them trigger RL CI, and describe when the
RL unit workflows run: main pushes, every 12 hours, and PRs with the
automatically applied ciflow/rl label.
@wwwjn
wwwjn force-pushed the feat/rl-unit-tests-ci branch from fb37f11 to 0c2735a Compare September 28, 2026 18:12
@wwwjn
wwwjn merged commit 3e764b5 into main Sep 28, 2026
25 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/docker 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