Repository navigation
[rl] Scheduler launchers on the Monarch actor system, starting with SLURM - #5572
Conversation
5fc6827 to
70c9ebd
Compare
|
reply from claude: two notes for landing:
|
felipemello1
left a comment
There was a problem hiding this comment.
The TODO is a major bug and I dont think that we should ship it as is. Is it a big lift to fix?
| # Node-local JIT caches: the default caches live under the home directory, which | ||
| # SLURM clusters usually put on a shared network filesystem; nodes compiling | ||
| # into one shared cache can hang or crash. | ||
| cache_root = f"/tmp/torchtitan-{os.getuid()}" |
There was a problem hiding this comment.
sounds a bit odd that user has to remember to define this in every slurm config, or things crash. Can we make it a default for our launcher somehow?
|
Review by claude: the design looks right and is close to landing. One I'd land it after the 4 changes below. Changes 1, 3 and 4 are code for the inline asks. 1. Pack roles smaller than a node (the On 4-GPU nodes, a 4-GPU trainer and four 1-GPU generators take 5 nodes today and leave 12 GPUs idle. Before ( if world_size < gpus_per_node:
logger.warning(...)
mesh_nodes[role] = 1
...
role_mesh={role: role for role in role_world_sizes},After: """Plan the host meshes: a role of a node or more gets its own nodes, and
smaller roles fill shared nodes in order. Example, 4 GPUs per node:
trainer 8, generators 1 x4 -> trainer: 2 nodes | shared_0: generator_0..3
trainer 2, generators 1 x2 -> shared_0: trainer, generator_0, generator_1
trainer 4, generators 3 x2 -> trainer: 1 node | shared_0: generator_0 | shared_1: generator_1
"""
...
mesh_nodes, role_mesh = {}, {}
num_shared = free_gpus = 0
for role, world_size in role_world_sizes.items():
if world_size >= gpus_per_node:
if world_size % gpus_per_node:
raise ValueError(...)
mesh_nodes[role] = world_size // gpus_per_node
role_mesh[role] = role
continue
# Start a new shared node when the current one is full.
if world_size > free_gpus:
shared = f"shared_{num_shared}"
mesh_nodes[shared], free_gpus = 1, gpus_per_node
num_shared += 1
free_gpus -= world_size
role_mesh[role] = shared
idle_gpus = sum(mesh_nodes.values()) * gpus_per_node - sum(role_world_sizes.values())
if idle_gpus:
logger.warning(f"{idle_gpus} GPUs stay idle: {role_mesh}")
return Layout(gpus_per_node=gpus_per_node, mesh_nodes=mesh_nodes, role_mesh=role_mesh)
2. Keep the launcher's hosts in
Before ( # TODO: remove _host_meshes (and the host_meshes argument) once internal
# ad-hoc launchers have migrated to MonarchLauncher.
host_meshes = self._host_meshes
if host_meshes is None and self._launcher is not None:
...
host_meshes = layout.host_meshes(self._launcher_meshes)
...
host_meshes=host_meshes,After: # TODO: remove the host_meshes argument once internal ad-hoc launchers have
# migrated to MonarchLauncher.
if self._host_meshes is None and self._launcher is not None:
...
self._host_meshes = layout.host_meshes(self._launcher_meshes)
...
host_meshes=self._host_meshes,3. Node-local JIT caches by default in Then no SLURM recipe has to copy them, and a value from the recipe's Before ( cache_root = f"/tmp/torchtitan-{os.getuid()}"
...
env={"TRITON_CACHE_DIR": ..., "VLLM_CACHE_ROOT": ..., "FLASHINFER_WORKSPACE_BASE": ...},After ( os.environ.update(plan.env)
# Node-local JIT caches: home is usually on NFS, and nodes compiling into
# one shared cache can hang or crash.
cache_root = f"/tmp/torchtitan-{os.getuid()}"
os.environ.setdefault("TRITON_CACHE_DIR", f"{cache_root}/triton")
os.environ.setdefault("VLLM_CACHE_ROOT", f"{cache_root}/vllm")
os.environ.setdefault("FLASHINFER_WORKSPACE_BASE", f"{cache_root}/flashinfer")The recipe also drops 4. Example recipe: the trainer on one node, then one 1-GPU generator per GPU on a second node (needs change 1). Before ( config.num_generators = 2
...
launcher = SlurmLauncher.Config(gpus_per_node=2, env={...})After: gpus_per_node = 4 # your nodes' GPU count
config = rl_grpo_qwen3_0_6b_flex()
config.trainer.parallelism = ParallelismConfig(data_parallel_shard_degree=gpus_per_node)
config.generator.parallelism = InferenceParallelismConfig() # 1 GPU
config.trainer.model, config.generator.model = _qwen3_rl_model_configs(
"0.6B",
seq_len=config.trainer.training.max_context_length,
attn_backend="flex",
trainer_parallelism=config.trainer.parallelism,
generator_parallelism=config.generator.parallelism,
)
# Node 0: the trainer. Node 1: one generator per GPU.
config.num_generators = gpus_per_node
config.actor_system = MonarchActorSystem.Config(
launcher=SlurmLauncher.Config(gpus_per_node=gpus_per_node)
)
Smaller:
Related: felipemello1#412 needs change 2. It matters only when both PRs land and the trainer spans several nodes. |
|
@felipemello1 The TODO is not a bug. We have been using this internally for several months. |
|
@pzhan9 , you are saying that:
Is that correct? If so, to me it looks like a terrible footgun. I had it patched in my runs. I don't think that the fix is that complex, since I ran probably >100 experiments with it fixed. But if you think we shouldn't do it in this pr, we should at least not allow the footgun, or have another diff in this stack with the fix |
| ```python | ||
| def my_rl_slurm(): | ||
| config = rl_grpo_qwen3_0_6b_flex_slurm() | ||
| config.actor_system.launcher.slurm_args += ["--account=my-account", "--partition=gpu"] |
There was a problem hiding this comment.
This doesn't feel the most natural way of launching jobs
To me, the overall training config (here Controller.Config) should not have launcher details, so
- either launcher config is at a strictly higher level -- launcher owns controller.config, not vice versa
- or launcher doesn't belong to the python config tree at all
|
@claude review my review |
|
Claude finished @tianyu-l's task in 1m 0s —— View job Review of @tianyu-l's review (
|
70c9ebd to
f0c70be
Compare
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the
problem, why
this approach, and what you checked yourself. -->
## Why
The Real PG integration suite (`8 GPU Integration (Real PG - full suite
- features)`) and the ROCm integration suite have failed the `sft` loss
check on main since #5757 (`899480301`; `a87db08ea` before it passed):
```
[sft] AssertionError: 7.889825820922852 != 7.887711524963379 : loss mismatch at step 1 # A10G
[sft] AssertionError: 7.890093803405762 != 7.887524604797363 : loss mismatch at step 1 # MI350X
```
#5757 renders `bos_token`/`eos_token` in Hugging Face chat templates, an
intended change to the SFT token stream. It regenerated
`tests/assets/losses/fake_pg/a10g/sft.txt` but not the real-PG A10G and
MI350X goldens.
## What changed
- `tests/assets/losses/real_pg/a10g/sft.txt` and
`tests/assets/losses/real_pg/mi350x/sft.txt`: steps 1-10 regenerated;
headers unchanged.
## Numerics
The new values are the full-precision TensorBoard metrics of the failing
main runs' baseline training (the same values `loss_compare.py
--export-result` writes), read with `scripts/loss_compare.py`'s own
extraction from the uploaded `integration-8gpu-features-outputs`
artifacts:
- A10G: run 41746280593 (`e6ca6d861`). Step 1 matches the log's baseline
(7.889825820922852, grad_norm 4.189799785614014).
- MI350X: the ROCm run on `73c4ebdac`. Step 1 matches the log's baseline
(7.890093803405762, grad_norm 4.189815998077393).
The commits between #5757 and those runs (#5572, #5787, #5776, #5774,
#5779, #5741, #5786) do not change SFT numerics.
## Testing
- CI: Real PG (`ciflow/real-pg`) and ROCm (`ciflow/rocm`) integration
suites.
- A manual `export_results` run of the integration workflow for `sft` on
main (run 41760303504) exported a real-PG A10G golden identical to this
one.
- `Multi-GPU Unit Tests` fails here with the `_VisionEncoder ...
named_preserve_dtype_params` error that is also on main; #5795 fixes it.
This PR was AI-assisted.
…group compute_host_memory_metrics read only the controller cgroup's cgroup.procs. Under Slurm's cgroup v2 plugin each job step has its own cgroup (job_<id>/step_<step>/user/task_<n>). SlurmLauncher (#5572) runs the controller as the batch step and starts the Monarch workers with srun, in another step, so the trainer ranks on the controller's host were missed: host_memory/*/trainer read 0 in a real Slurm job that had 12 trainer processes on that host. Now the metric scans the controller's nearest job_<id> ancestor and every cgroup below it; outside Slurm it reads the controller's own cgroup as before. host_memory/cgroup_memory_current_gib becomes the job's total on this host, and `other` now includes the job's other steps (step_extern).
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the arguments refuse a loopback Mooncake master for a multi-node run. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the arguments refuse a loopback Mooncake master for a multi-node run. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
Like torchtitan's SlurmLauncher (pytorch/torchtitan#5572), a multi-node --cluster-backend monarch run is submitted as one Monarch SlurmJob in batch mode. - `python -m miles.utils.workers.monarch.slurm --nodes N --gpus-per-node G [--slurm-arg ...] -- <launcher command>` submits one allocation. The job runs the launcher command unchanged on its first node, Monarch starts a worker loop on every node, and SLURM frees the nodes when the command exits. Flags the submission sets itself are refused in --slurm-arg. --no-exclusive shares nodes instead of reserving them whole, with --monarch-port for the worker loops' port; --bind-to sets where they listen, e.g. :: on a dual-stack cluster, where a node resolves its own hostname to IPv6 and the driver dials IPv4. - The driver attaches to the job's hosts through the job state the submission saves (MILES_MONARCH_JOB_STATE), before this_host() starts its runtime: loading the job state sets the transport the job's hosts reply on, which a runtime already serving on a node-local socket would never hear. An attach that times out says where to look. - In the job the launcher allows multi-node, points MASTER_ADDR and, unless set, MOONCAKE_MASTER at the head node instead of loopback, and runs per-node commands (prepare_cmd, multi-node conversion) through srun with the same placeholders the ray launcher substitutes. It runs no cleanup sweep, which on a shared node would kill other runs, and refuses a Mooncake master port another job holds; the worker manager refuses a loopback Mooncake master when its hosts span more than one node. - Every worker gets the variables the launcher exports to the driver (PYTHONPATH, --extra-env-vars, ...), as ray's runtime env passes them on: a process on another host does not inherit the driver's environment.
## Summary (human-written) Part of the RFC #5401 (GRPO on Intel XPU). RL recipes on main can only be launched on SLURM clusters, so PBS systems like Aurora had no supported launcher. `PBSLauncher` adds one next to `SlurmLauncher`, on the launcher interface from #5572, using Monarch's `PBSJob`. It only handles what PBS does differently: it submits with `qsub -V`, since PBS doesn't pass the submit environment, and it copies the job state Monarch writes to a per-job path, since PBS has no `--chdir` (removable once meta-pytorch/monarch#5414 lands). The README's PBS section shows a launch recipe and the site settings PBS clusters need: `python_exe` as a script that loads the environment, and a short `TMPDIR` (meta-pytorch/monarch#5415). Tested: - `test_launcher.py`: the job is built correctly, hosts are acquired, invalid `pbs_args` are rejected. - On ALCF Aurora (PBS Pro, Cray PALS) with current Monarch main: a 1-node job submits, the controller attaches, and with #5402 Qwen3-0.6B GRPO trains 5/5 steps through `PBSLauncher`. - Earlier 2-node jobs placed the trainer and generators on the planned nodes and tiles. Needs a Monarch with meta-pytorch/monarch#5273 (`PBSJob` without `rank_env`).
…er override; agent self-review; rl/transport (#6407) ## Summary (human-written) <!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why this approach, and what you checked yourself. --> ## Why Since #5667, `@claude review` has reviewed 459 PRs. Of the 380 PRs it approved, 30 then got a formal "request changes" from a maintainer, and about 20 more got substantive inline asks. In nearly all of them the bot either saw the problem and approved anyway, or never asked the questions maintainers ask most ("does the repo already do this?", "who should own this?"). The opposite failure, the bot blocking something a maintainer was fine with, is rare: in the PRs we sampled, 2 of its 81 must-fix items were wrong and about a third were minor (the empty human-written summary was the biggest source). **Example** (#6112, controller sizes the rollout worker pool): ``` before: bot approved 10 times; tianyu-l then blocked: "the controller reads rollouter.rollouts_per_worker to compute a count it hands back to the Rollouter -- violates encapsulation" after: same commit, new skill -> Request changes, must-fix #1: "controller.py:589 -- wrong owner for the worker count ..." ``` There was also no way for a code owner to overrule the bot except dismissing its review in the GitHub UI, and a later `@claude review again` would block again. ## What changed **Review skill** (`.claude/skills/pr-review/`, `review-checklist.md`): - Verdict rules: Approve only when every remaining item is an edit the bot could write itself. Anything the author still owes (a design change, an unexplained golden change, evidence the PR rests on) is Request changes; anything only a maintainer can decide is Needs discussion. A hedge like "a maintainer should decide" can't come with Approve. - Always must-fix: a violated written rule, a silent wrong result, a second definition of an existing concept, a gate finding. - Design gate: new questions for the existing counterpart, in-repo ownership, and the design behind a bug; "ban only what doesn't work on main"; read the numbers behind a claim. The overlapping-PR search is mandatory and reported. - Re-review covers every commit since the last full review, including code taken from the bot's own suggestions. A scoped question gets a `COMMENT`, not a whole-PR verdict. - The bot fact-checks its own proposed fixes, and cites a source for claims about external tools or marks them unverified (never must-fix). - An empty "Summary (human-written)" is a one-line "Before merge" note that never affects the verdict. - Checklist: config ownership direction, general shared wrappers, dead code the PR creates, model variants as flavors, a mechanical pass over every new or changed function. **Code owner override** (`SKILL.md`, `claude-code.yml`, `CONTRIBUTING.md`): a code owner comments `@claude override` (optionally `@claude override 2,3: <reason>`); the bot approves if nothing else is open and doesn't re-raise the overridden items. A code owner's GitHub approval or "LGTM" is not an override, so a teammate can approve without the bot dropping its findings. Dismissing the bot's review still unblocks the PR, but isn't an override: the bot can't tell who dismissed it. **Agent self-review** (`CLAUDE.md`, `pr-description`): an agent preparing a PR runs `pr-review` in branch mode first and records unaddressed items in an optional "Self-review" section. PRs written without an agent are unaffected; a missing section is never a finding. Where each new rule comes from (maintainer asks the bot missed): | Change | PRs | | --- | --- | | No Approve with open design/evidence items or a "maintainer should decide" hedge | #6007, #5837, #5997, #5712, #5511, #5996 | | Author waiver can't clear a must-fix | #6201, #6202, #6203 | | Existing counterpart; one source of truth | #5228, #6169, #5881, #5823, #5824, #6059, #5812 | | Responsibility owner; config ownership direction | #6112, #6332, #5802, #5803, #6325 | | Fix the design behind the bug; a TODO doesn't justify a workaround | #5572, #5689, #5657 | | Fact-check the bot's own suggested fixes | #5740, #5802, #5511, #4819, #5543 | | Re-review covers all new commits; scoped asks don't approve | #5824, #5842 | | Mandatory overlap search | #5885, #6248 | | Ban only what doesn't work on main | #5543 | | Summary placeholder no longer a must-fix | #6119, #6174, #6112, #5868 | **Rules**: `design.md` gets the one-general-wrapper rule (moved from `models.md`, whose glob skipped `torchtitan/rl`), thin adapters, and the consumer owning its values; `config.md` gets ownership direction and "a Config doesn't read runtime state"; `direction.md` calls all-to-all the MoE reference implementation, so a new vendor-specific dispatch path (e.g. #6242) needs a reason the existing backends can't serve. **Area reviewers**: `.ci/` -> huydhn, wwwjn; `torchtitan/rl/transport/` -> d4l3k. **Mechanical, skim**: `torchtitan/rl/transport/` holds data movement between RL actors. - `rl/model_state_dict_transport.py` -> `rl/transport/model_state_dict.py` - `rl/MODEL_STATE_DICT_TRANSPORT.md` -> `rl/transport/MODEL_STATE_DICT_TRANSPORT.md` - `rl/trainer/rdma_microbatch.py` -> `rl/transport/rdma_microbatch.py` - tests: `tests/rl/unit_tests/cpu/test_{model_state_dict_transport,rdma_microbatch}.py` -> `tests/rl/unit_tests/cpu/transport/test_{model_state_dict,rdma_microbatch}.py` - imports, READMEs and `scripts/install_rl_env.sh` updated; no code changes. ## User-facing changes | Before | After | | --- | --- | | Overrule the bot: dismiss its review in the UI, and it blocks again on the next run | `@claude override [items]: <reason>`; the bot approves and doesn't re-raise them | | Empty human-written summary: bot must-fix | One "Before merge" line, no effect on the verdict | | `from torchtitan.rl.model_state_dict_transport import ...` | `from torchtitan.rl.transport.model_state_dict import ...` | | `from torchtitan.rl.trainer.rdma_microbatch import ...` | `from torchtitan.rl.transport.rdma_microbatch import ...` | ## Testing Backtest: the new skill run locally (nothing posted) on each PR at the commit and thread state the bot originally saw. | PR | Bot then | New skill | What the maintainer asked | | --- | --- | --- | --- | | #6112 | Approve | Request changes | worker-count ownership (caught) | | #5837 | Approve | Request changes | apply to `dp_shard` too (caught) | | #5572 | Approve | Request changes | delete the injection design (caught) | | #6201 | Approve after author waived pins | Request changes, waiver ignored | pins broke GPU tests after merge (caught) | | #6007 | Approve | Request changes | fold K3.1 into K3 (caught) | | #5543 | Request changes: "ban it" | Request changes: keep main's path | don't break gpt-oss + DeepEP (fixed) | | #6144, #5905 (controls) | Approve | Approve | -- | | #6137 (control) | Approve | Needs discussion | -- (merge gate on an upstream API) | Code owner override, simulated on #6201: override by a code owner lifts the named item; `@claude override` from the author changes nothing; a code owner's "LGTM" approval followed by "review again" keeps Request changes. Transport move: 83 RL CPU unit tests pass locally (`transport/test_model_state_dict.py`, `test_trainer.py`, `test_engine_loop.py`). `transport/test_rdma_microbatch.py`, `test_generator.py` and `test_batcher_actor.py` fail to collect in my env on `origin/main` too (stale attention-gym / Monarch), so CI is the check for those. ## Known issues / follow-ups - Open PRs that edit the moved files rebase cleanly (git follows the renames), but new imports of the old module paths will break: #6309 (adds a delta transport that should live in `rl/transport/`), #6237, #6176, #6177, #5862, and drafts #6127, #6393, #6163, #5764. - The Actions bot can't read dependency source (e.g. SGLang); follow-up for the workflow. ## Self-review pr-review (branch mode) at ad905a5: Needs discussion. Fixed: branch mode diffs against `origin/main` and skips description findings before a description exists; the "Config doesn't read runtime state" rule no longer contradicts hardware validation; dismissal dropped as an override form (the bot can't tell who dismissed); `test_rdma_microbatch.py` added to the transport area. Not addressed: - One concern per PR -- the five changes ship together at the maintainer's request. - Open PRs touching the moved files -- listed above; the maintainer will coordinate.
Summary (human-written)
This PR adds a slurm launcher, so we can launch a job using multiple hosts. See
rl_grpo_qwen3_0_6b_flex_slurmfor the example of how it is used.Why
TitanRL can run on several hosts only through a launcher that builds
MonarchActorSystem(host_meshes=...)itself; the in-repo path(
python -m torchtitan.rl.train) runs every role on the controller's host. Thereis no way to submit a recipe to a cluster scheduler from this repo.
Example. Qwen3-0.6B GRPO on two 4-GPU SLURM nodes:
What changed
launcher/base.py):MonarchControllerWithLauncheris aControllersubclass whoseConfigaddslauncherat the root, so a launchrecipe is "this RL recipe on this cluster", built with
MonarchControllerWithLauncher.Config.from_controller_config(config, launcher=...).Controller.ConfigandMonarchActorSystem.Confighave nolauncher settings.
controller.py):setup_asyncbuilds itthrough a new
Controller._build_actor_system(), which buildsconfig.actor_system.MonarchControllerWithLauncheroverrides it to acquirethe planned hosts and build
MonarchActorSystem(host_meshes=...)fromself.config.launcher/submit.pyplans the layout on the submit host andsubmits. The scheduler runs the unchanged
python -m torchtitan.rl.trainwiththe same arguments;
config.build()buildsMonarchControllerWithLauncher.MonarchLauncher._layout): places the trainer, then eachgenerator, filling one node before the next. A role using a node or more gets
whole nodes; smaller roles share nodes; idle GPUs are logged as one warning.
Table of examples in
torchtitan/rl/actors/monarch/README.md("Layout").SlurmLauncher(launcher/slurm.py): one MonarchSlurmJobin batchmode, controller on SLURM's head node. Site settings go in
slurm_args; flagsthe launcher owns are rejected. JIT caches (Triton, vLLM, FlashInfer) default to
node-local
/tmp/torchtitan-<uid>.rl_grpo_qwen3_0_6b_flex_slurminalphabet_sort.py.MonarchActorSystem'sgenerator_envargument (andextra_envbehind it): unused since [RL] Remove FULL_AND_PIECEWISE CUDA graph mode #4834 removed its only caller.Controller.Config.resolve_overrides()(moved out ofController.__init__sosubmitplans from the overridden config);generator_role_namesinprovisioning.py, shared by the planner andMonarchActorSystem.Alternatives considered
MonarchActorSystem.Config(an earlier version of this PR): makesevery recipe pick its scheduler and adds a second way to pass hosts.
train.mainhook andsetup_async(actor_system=...)(an earlier version ofthis PR): more code, and the hook got the config before overrides were
applied, so root-level overrides never reached the job.
Controller.Configin ajobfield:--overrideneeds
overrideat the root, so CLI overrides and--print-configwould change.--launcher module:fn):launches are defined per recipe and cluster in practice, as in fairtitan.
User-facing changes
host_mesheslauncher.submitwith aMonarchControllerWithLauncher.Configrecipepython -m torchtitan.rl.traincontroller.setup_async(actor_system=...)Controllerand override_build_actor_systemMonarchActorSystem(..., generator_env=...)Numerics
No computation change. Without a launcher,
Controller._build_actor_systembuilds
config.actor_system, assetup_asyncdid before.Testing
pytest tests/rl/unit_tests/cpu/: 530 passed, 9 skipped, 1 failed. Thefailure,
test_model_defaults[dapo_math], also fails without this PR: thelocal venv's
torch_checkpointinglacksCallbackArgs.test_dapo_math.pyisnot collected locally (optional
math_verifymissing).test_launcher.pycovers the layout planner (examples, idle warning, fits the hosts, rejected
sizes, shared mesh objects),
submit,MonarchControllerWithLauncher(buildsthe subclass, requires a Monarch actor system, acquires hosts from the layout),
and
SlurmLauncher'ssbatcharguments, env and validation.sysml,--segment=1,bind_to="::",HF_HUB_OFFLINE,HF_DATASETS_OFFLINEandMONARCH_RDMA_IBVERBS_TARGETinlauncher.env, W&B disabled; launch recipeslocal, not committed:
rl_grpo_qwen3_0_6b_flex_slurmat the head commit (MonarchControllerWithLauncher): node 0: trainer (TP=2 x FSDP=2); node 1: generator_0..3 (1 GPU each)torchtitan.rl.train; trainer mesh dp_shard=2 x tp=2; 10 steps (loss -0.0032 -> -0.0024, grad norm 2.17 -> 0.62); weight sync to the generator node every step; validation reward 0.181 -> 0.216rl_grpo_qwen3_0_6b_flex_slurm, before theControllersubclass: node 0: trainer (TP=2 x FSDP=2); node 1: generator_0..3 (1 GPU each)launcher.job; trainer mesh dp_shard=2 x tp=2; 10 steps (loss -0.0064 -> -0.0022, grad norm 5.09 -> 0.53); weight sync to the generator node every step; validation reward 0.181 -> 0.197launcher.jobpython -m torchtitan.rl.train --module torchtitan_recipes.rl.alphabet_sort --config rl_grpo_qwen3_0_6b_flexon one4-GPU node, this PR vs. its base
01586df70(the recipe is not seeded ordeterministic, so losses are compared by range, not bitwise):
01586df70Known issues / follow-ups
generators on other nodes; a 3-node smoke test once both are in.
SlurmLauncherreads the SLURM job id through a private Monarch attribute(TODO in
slurm.py).setup_async(actor_system=...); it moves tothis launcher in a companion change.