Skip to content

[rl] Respect CUDA_VISIBLE_DEVICES in single-host GPU allocation - #5647

Draft
vkuzo wants to merge 1 commit into
mainfrom
gh/vkuzo/4/head
Draft

vkuzo wants to merge 1 commit into
mainfrom
gh/vkuzo/4/head

Conversation

@vkuzo

@vkuzo vkuzo commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary:

The single-host RL launcher used to assign physical GPUs starting at zero to every spawned role, even when the controller was launched with CUDA_VISIBLE_DEVICES=4,5,6,7. The bootstrap environment for the trainer and generators replaced that parent setting with 0,1 and 2,3. On a shared devgpu this could place a run on GPUs already in use, making startup appear stuck.

Read the controller-visible GPU list before spawning actors and pass it to PerHostProvisioner. Allocate successive slices of that list to the trainer and generators, preserving the specified order. When CUDA_VISIBLE_DEVICES is absent, retain the previous allocation starting at GPU 0. Reject empty, duplicate, or insufficient device lists before spawning any process. Explicit multi-host mesh allocation retains its existing behavior.

Document the single-host launch pattern and cover default selection, nonzero/reordered devices, extra visible GPUs, malformed lists, and multi-host behavior with CPU tests.

Test Plan:

  • pytest -q tests/rl/unit_tests/cpu/test_shutdown.py (25 passed)

  • flake8 torchtitan/rl/actors/monarch/provisioning.py tests/rl/unit_tests/cpu/test_shutdown.py

  • git diff --check HEAD

  • Four-GPU toy dense job (from the repository root):

    CUDA_VISIBLE_DEVICES=4,5,6,7
    VLLM_ALLREDUCE_USE_SYMM_MEM=0
    VLLM_ALLREDUCE_USE_FLASHINFER=0
    PYTHONPATH="$PWD:${PYTHONPATH:-}"
    python -m torchtitan.rl.train
    --module torchtitan_recipes.rl.alphabet_sort
    --config rl_grpo_qwen3_0_6b_flex
    --output-dir outputs/rl/alphabet_sort_0_6b_flex_nccl

[ghstack-poisoned]
@vkuzo

vkuzo commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant