Make ART a native multi-node RL runtime with Monarch - #808
Conversation
…ode_training # Conflicts: # src/art/trajectories/__init__.py # src/art/trajectories/_capture/core.py # src/art/trajectories/_compact.py # src/art/trajectories/_scope.py # src/art/trajectories/tensors.py # tests/unit/trajectories/test_compact_serialization.py
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
Codex/Claude found two potential blockers:
-
LocalBackend training breaks for Unsloth and Tinker.
_resolve_grad_accumulation_sequencesalways callsservice.resolve_global_grad_accumulation_sequences(), but neitherUnslothServicenorTinkerServiceimplements the method. The first non-empty training batch raisesAttributeError, including with an explicitly configured accumulation value. Restoring the previous fallback or implementing the method on both services would resolve the issue. A real-service regression test would help prevent recurrence. -
Multi-member vLLM startup fails during NCCL preflight. The embedded preflight script imports
_runtime_python_for_nccl_discovery, which the PR removes fromart.vllm_runtime. Executing the child script produces anImportError. Every model service with at least two members runs this preflight, preventing multi-node serving from starting. Restoring the helper or using the remaining runtime-resolution helpers would resolve the issue. A test executing the embedded script would cover the import.
Additional findings are listed below. Use your discretion to determine whether fixes belong in this PR or follow-up work:
_advance_skipped_step()removesself._services[model.name], while the dictionary uses model storage tuples as keys. A failed adapter registration can leave a closed service cached.- NIXL adapter transfers have no deadline and can occupy the single transport worker indefinitely.
- Managed etcd listens unauthenticated on
0.0.0.0. An earlier cleanup failure can skip etcd shutdown and leave the subprocess orphaned. import artredirects unset Hugging Face, Torch, Triton, and vLLM cache paths to shared/tmp/art-cache. Client-only usage and shared hosts may encounter unexpected downloads, permission failures, or cache-isolation problems.- Closing an
InMemoryPackedBatchleavesbatch.tensorsreferencing unmapped shared memory. Post-close access produced a segmentation fault during reproduction, although no current production call path accessing the tensors after close was found. - IPv6 endpoint URLs lack brackets, and multi-host model-service validation accepts a loopback leader endpoint.
- Adding
numpy<2to base dependencies can force downgrades for lightweight installations.
|
@bradhilton Thanks for the detailed review. I addressed both blockers and all secondary findings in Blockers
Additional findings
Physical validation also exposed and fixed SSH workers not receiving the admitted NCCL/runtime environment. Final selective validation was:
|
Summary
This PR turns ART into a native distributed RL runtime rather than a single-node trainer wrapped in remote launch glue. Monarch owns process lifecycle and typed RPC, ART owns RL semantics and policy state, Megatron/NCCL owns distributed training, and vLLM owns inference execution.
Distribution remains an execution topology, not a second programming model. Existing single-node training code continues to use
MegatronBackend()andPipelineTrainer; internally, it now compiles to the same one-host runtime used by multi-node jobs. Advanced users can provide explicit placement and service topology without changing the training loop.The PR also adds production GLM-5.2 support optimized on H200 and B300, composable CP/EP/DP/PP/VPP training, multi-node inference, CUDA 13/Blackwell support, and the asynchronous data, packing, publication, and durability paths needed to keep those systems efficient.
Design Decisions
PYTHONPATHso your rollout fn can be imported.TrainingProgramSpecare intentionally not prerequisites. Existing trajectories, trajectory groups,backend.train(), and pipeline training remain valid.Public API
art.init_megatron_runtime_config(...)HostSpec,ClusterSpec,GpuPlacementTrainerMeshSpec,ModelServiceSpec,VllmParallelSpeccompile_topology(...)ArtRuntime.start(...)ArtRuntime.start_local(...)MegatronBackend()path uses.InstalledAsyncCallableandruntime.rollout_executor(...)PackingRequestandPackedBatchRefruntime.start_trainer(...)TrainerRuntimeSpec,TrainingRunSpec, job contracts, and progress/completion events.runtime.start_model_service(...)art-monarchNormal single-node usage remains:
Explicit multi-node usage supplies a compiled runtime and rollout executor, then uses the same backend and
PipelineTrainerAPIs:These APIs allow multiprocessing rollout workers, which is useful when rollouts perform CPU-heavy environment execution.
Runtime Flow
Policy version, adapter generation, logprobs, rewards, timing, MoE routes, and mid-prefill policy changes remain attributable through this flow.
Implementation Map
The total branch diff is 280 files,
+64,465/-17,589. Excluding tests and lockfiles, production, setup, examples, and documentation contribute+40,016/-9,631; tests contribute+17,163/-5,841.src/art/distributed/+10,221: typed topology, Monarch lifecycle, rollout execution, trajectory ownership, leased queues, packing, batch transport, NIXL adapter transfer, admission, and model-service supervision.src/art/megatron/runtime/+4,426/-211: typed runtime/job/event contracts, local and Monarch executors, warm trainer supervision, managed package runtime, compilation identity, publication, and recovery.src/art/megatron/+12,851/-5,189: backend cutover, distributed service coordination, CP/EP/HybridEP, optimizer state, asynchronous snapshots, BF16 LoRA serialization, and trainer instrumentation. The old filesystemservice.pyis deleted.+3,535: sparse MLA, indexer, CP stages, LoRA projections, model spec/state, TileLang kernel, and ART model-support integration.training/pipeline_schedule.py+995: PP/VPP scheduling with variable sequence lengths, executed batch size one, recomputation, CP, and route-replay integration.+3,955/-1,699excluding lockfiles: vLLM 0.25.1 integration, distributed deployment lifecycle, binary MoE routes, policy spans, pooled fast metrics, and model-specific patches still required upstream.+1,959/-781: bounded queue control, packing lookahead, logical/executed token accounting, and async trainer dispatch.examples/multinode/tests/+17,163/-5,841: runtime lifecycle, topology, data-plane, failure/recovery, publication, model correctness, numerical parity, packing, trainability, and E2E throughput coverage.Workflow Tests
The workflow is a set of tests which run for each handler, proving things like parity with HF transformers, invariance to prefix tree packing, correct parallelism implementations, minimal train-inf mismatch, trainability and now e2e throughput. The throughput test uses a set of layers which fits a 128k packed seq on 2 gpus, cp2 ep2. vLLM is deployed with 2 gpus as well, and a synthetic workload is trained on. We assert things like a gap under 230ms p50 between consecutive fwd_bwd work, vLLM and trainer load, time to activate an adapter, trainer throughput matching expected isolated throughput (also catches recompilation issues), and overall tok/s. These ensure that the system is properly async and components are performing at peak speed.
In addition to the new stage, we redesigned how the workflow schedules itself, combined stages, and minimized imports, process startup, and repeated work. This turns a 70-90 minute run for one handler into approximately 60 minutes for all ten, with further scaling from additional GPUs.
Performance And Validation
Intentional Scope
This PR does not add a second training API, Ray, generalized-RL program definitions, multiple independent inference replicas, merged-weight serving, the old NCCL weight-transfer engine, file-backed job dispatch, JSONL polling, or nested multi-node
torchrun. Those omissions are deliberate: the delivered core is the smallest coherent runtime compatible with the efficiency target that provides correct multi-node rollout, inference, training, data movement, policy publication, durability, and single-node collapse.