Skip to content

Fix experiemental CI trigger condition + Fix RL CI editable install permission error - #3541

Merged
wwwjn merged 17 commits into
mainfrom
fix-rl-ci
Jun 10, 2026
Merged

wwwjn merged 17 commits into
mainfrom
fix-rl-ci

Conversation

@wwwjn

@wwwjn wwwjn commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Fix 3 things related to experimental CI:

  1. In RL integration test: editable install torchtitan caused permission issue
  2. When first create a RL PR (with ciflow/rl tag), the first commit doesn't trigger the CI run, only triggered a set-matrix
  3. is-experimental flag in set-matrix will trigger a empty ROCm matrix but runs nothing.

After fix, the CI trigger will be:

  • experimental + labeled -> CUDA only
  • experimental + main push -> CUDA only
  • experimental + schedule -> CUDA only
  • non-experimental ROCm label/tag behavior preserved.

Other changes need to be fixed when RL CI is down:

  • Updates RL integration tests to run via python -m torchtitan.experiments.rl.train.
  • Uses varlen RL configs in CI, disables Qwen3 thinking, sets group_size=2, raises seq_len to 1024, and caps generation with generator.sampling.max_tokens=256 so rollout rows are not all filtered as overlength.
  • Splits H100 bitwise parity into separate Varlen and Flex torchrun invocations so each gets a fresh process group / vLLM lifecycle.
  • Fixes teardown hangs by not destroying Monarch-owned distributed state from actor close() methods: VLLMGenerator.close() only shuts down renderer-local resources, and PolicyTrainer.close() leaves process group teardown to ProcMesh.stop(). cc @felipemello1 @pzhan9
  • Routes trainer checkpoint/debug dump paths through the CI output directory to avoid permission/path issues.
  • Renames/updates RL docs and helper imports to the varlen config names.

@wwwjn
wwwjn requested review from fegin, tianyu-l and wconstab as code owners June 4, 2026 23:57
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 4, 2026
@wwwjn
wwwjn requested a review from huydhn June 5, 2026 15:40
@wwwjn wwwjn changed the title [DO NOT REVIEW][rl] Fix RL CI editable install permission error by using pytorch path instead [DO NOT REVIEW]Fix experiemental CI trigger condition + Fix RL CI editable install permission error Jun 5, 2026
# Step 2: Use the dynamic matrix in the build-test job
build-test:
needs: set-matrix
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ciflow/rl')

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.

This line is moved to first step set-matrix. This bug is only in RL integration test yaml file, didn't find the same issue in other yaml files

@wwwjn wwwjn changed the title [DO NOT REVIEW]Fix experiemental CI trigger condition + Fix RL CI editable install permission error Fix experiemental CI trigger condition + Fix RL CI editable install permission error Jun 5, 2026
@wwwjn
wwwjn requested a review from felipemello1 June 5, 2026 15:46
Comment thread torchtitan/experiments/rl/README.md Resolved
Comment on lines +61 to +63
5. From the TorchTitan repository root, add the checkout to `PYTHONPATH`. Monarch-spawned RL worker processes inherit this environment variable, so they can import the local `torchtitan` package:
```bash
uv pip install -e .
export PYTHONPATH="$PWD:${PYTHONPATH:-}"

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.

yeah, i never did this, and it works fine. Perhaps this is necessary for worktree? I think that for worktree this is actually necessary.

can you ask claude to create a new env and verify this claim (i.e. do with it and without it, confirm that it fails without it?)

but in any case, we would still need to run uv pip install -e no?

# python grpo.py as a subprocess
uv pip install -e .
# 4. Make the checkout importable for subprocesses spawned by the test.
export PYTHONPATH="$PWD:${PYTHONPATH:-}"

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.

same here, wouldnt we need to still run pip install -e? otherwise, how is torchtitan installed?

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.

torchtitan doesn't need to be installed to run?

@felipemello1 felipemello1 Jun 5, 2026 •

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.

i have always used pip install -e . as a way for programs to find imports, right? as if the library is installed and is importable. "from torchtitan.X import Y"

I guess the export PYTHONPATH also works? i just haven't seen similar instruction in other libraries. So i dont know if this is a good solution, or claude slop

But if both of you are confident, lets go with it

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.

wouldnt we need to still run pip install -e?

No, export PYTHONPATH also works for the same purpose of "from trochtitan.X import Y", We don't use pip install -e . because it will have permission issue in CI, eg: https://github.com/pytorch/torchtitan/actions/runs/27032930788/job/79789585434#step:17:14902 This stops us running the CI.

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.

torchtitan doesn't need to be installed to run?

The main purpose we'll have this is for Monarch / vllm spawned children process - The children process need to know where to import torchtitan. To let them know the torchtitan path, we'd put it in a env variable which will be inherited by child process, or install torchtitan via editable mode pip install -e .

I don't know if there's a better work around, but the env variable could be a possible one

@wwwjn
wwwjn requested a review from felipemello1 June 8, 2026 15:47

@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.

unblock


Command to run:
python3 torchtitan/experiments/rl/train.py \
--module rl --config rl_grpo_qwen3_0_6b \

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.

This config field is renamed to rl_grpo_qwen3_0_6b_varlen, but test is not updated

"--group_size 2",
"--batcher.batch.seq_len 1024",
"--renderer.enable-thinking False",
"--generator.sampling.max_tokens 256",

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.

Increase the number of tokens being generated, to include meaningful answer to the SumDigts task

"""Destroy the worker's torch.distributed process group."""
if torch.distributed.is_initialized():
torch.distributed.destroy_process_group()
"""Close actor-local resources before the process mesh stops.

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.

This change is because CI hang during tear down, so I vibe coded this solution which looks reasonable - cc @felipemello1 @pzhan9 , I might want to land this PR first and if it breaks the shutdown, would love to have a forward fix

@wwwjn
wwwjn merged commit e6adf26 into main Jun 10, 2026
21 of 24 checks passed
saforem2 pushed a commit to saforem2/torchtitan that referenced this pull request Jun 10, 2026
…ermission error (pytorch#3541)

Fix 3 things related to experimental CI:
1. In RL integration test: editable install `torchtitan` caused
permission issue
2. When first create a RL PR (with `ciflow/rl` tag), the first commit
doesn't trigger the CI run, only triggered a `set-matrix`
3. `is-experimental` flag in `set-matrix` will trigger a empty ROCm
matrix but runs nothing.

After fix, the CI trigger will be: 
- experimental + labeled -> CUDA only
- experimental + main push -> CUDA only
- experimental + schedule -> CUDA only
- non-experimental ROCm label/tag behavior preserved.


Other changes need to be fixed when RL CI is down:
- Updates RL integration tests to run via python -m
torchtitan.experiments.rl.train.
- Uses varlen RL configs in CI, disables Qwen3 thinking, sets
group_size=2, raises seq_len to 1024, and caps generation with
generator.sampling.max_tokens=256 so rollout rows are not all filtered
as overlength.
- Splits H100 bitwise parity into separate Varlen and Flex torchrun
invocations so each gets a fresh process group / vLLM lifecycle.
- Fixes teardown hangs by not destroying Monarch-owned distributed state
from actor close() methods: VLLMGenerator.close() only shuts down
renderer-local resources, and PolicyTrainer.close() leaves process group
teardown to ProcMesh.stop(). cc @felipemello1 @pzhan9
- Routes trainer checkpoint/debug dump paths through the CI output
directory to avoid permission/path issues.
- Renames/updates RL docs and helper imports to the varlen config names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rl ciflow/8gpu 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.

3 participants