Repository navigation
feat(external-vllm): Support for persistent judge model pools - #4542
Conversation
|
/ok to test 2ea4123 |
|
/ok to test b551c62 |
|
@snivertynv I followed up with @yfw Also, on persistent judge pools, @yfw had built some POC here: 11746b3 @yfw could you please take a look at the approach in this PR and we can move this PR forward. |
|
@snivertynv The change looks good to me. Confirming the workflow first: Step 1: start the pool once: EXTERNAL_VLLM_MODE=serve \
EXTERNAL_VLLM_POOL_DIR=/lustre/.../judge-pools/nano-grpo \
sbatch --nodes=22 --exclusive --gres=gpu:4 --time=12:00:00 \
--export=ALL tools/external_gym_vllm/run_in_allocation.shStep 2: start or restart training against it: EXTERNAL_VLLM_POOL_DIR=/lustre/.../judge-pools/nano-grpo \
EXTERNAL_VLLM_POOL_JOB=<pool-job-id> \
COMMAND="... __SAFETY_BASE_URL__ ..." RAY_SUB=/path/ray.sub \
sbatch --dependency=after:<pool-job-id>+15 --nodes=68 ... \
--export=ALL tools/external_gym_vllm/attach_and_run.shSo a warm run is step 2 only? and in that case the A few questions and suggestions: 1. Isolation between pool jobs looks right. The registry file lives under the per-job log dir and the group ID carries the job ID ( One gap at the layer this PR adds: Relatedly, nothing records which training jobs are attached, so there's no safe way to decide whether a pool can be cancelled, and a second attacher silently halves the first one's judge throughput. Having attachers touch Also minor: the default group ID is hardcoded 2. Smallest fix reusing what's there: in the relaunch path, Alternatively the load balancer already publishes the signal but note it has to be compared against the replica count, since The route is 3. Pool-job death. Two things here. No heartbeat, so
Could the serve loop mirror that and reset a step's counter once it's been up for N minutes? 4. Inline mode's teardown guarantee is gone in serve mode. Inline 5. Bug in state=$(squeue -h -j "${EXTERNAL_VLLM_POOL_JOB}" -o %T 2>/dev/null | head -1)
if [[ -z "${state}" ]]; then
echo "[FATAL] judge pool job ${EXTERNAL_VLLM_POOL_JOB} is gone" >&2Under (The existing test passes because the stub 6. Collapsing the launch and attach flows. I'd like one entry point, but I don't think it can live in Separately, the README's two attach paths should become one. Since 7. Publish the pool's remaining time. Attaching a 6-hour training job to a pool with 40 minutes left is an easy and expensive mistake. Writing 8. A requeued pool job is indistinguishable from the original. Slurm keeps 9. Testing. The stub- |
… attach EXTERNAL_VLLM_MODE=serve runs the external vLLM pools as their own plain Slurm job that outlives training jobs: replicas on its nodes, load balancers on its first node. Training jobs attach to it with attach_and_run.sh, so a training job can crash or be resubmitted without the judges reloading. Inline mode is unchanged apart from launching its steps through the same relaunchable helpers. Pool directory (EXTERNAL_VLLM_POOL_DIR): - owner: taken with O_EXCL at start; a second serve job on a directory owned by a live job fails, a dead owner's directory (or this job's own after a requeue) is taken over. - generation (<job-id>-<restart-count>), job_id, log_dir, end_time. - manifest.tsv: base URL, /health URL, expected backends, served model name and startup timeout per pool (plus <pool>_url and pools.env). - READY: published once every load balancer counts every replica healthy, withdrawn while any pool is below full strength (a relaunch loading weights, or a wedged replica) and restored when it is whole again. - heartbeat: rewritten every poll, also while the pools load. - attached/<job-id>: training jobs currently attached, logged by the pool. - STOPPED on exit, after READY is withdrawn. A replica or load balancer that exits is relaunched on the same nodes; its relaunch count resets after EXTERNAL_VLLM_RESTART_RESET_S of uptime, so only a crash loop exhausts EXTERNAL_VLLM_MAX_RESTARTS. Default group ids are mode-aware (serve-<pool>-<job>). attach_and_run.sh waits for READY from the expected pool job with a fresh heartbeat, resolves URL placeholders and the external-service readiness gate from the manifest at job start, warns (or with EXTERNAL_VLLM_ATTACH_REQUIRE_LIFETIME=1 refuses) when the pool ends before the job, registers under attached/, and stops NeMo RL when the pool stops, is replaced or requeued, or its heartbeat goes stale. A failed squeue is only logged; the pool job counts as gone after EXTERNAL_VLLM_POOL_GONE_CHECKS consecutive "finished or unknown" answers. pool_config.sh adds submit_external_vllm_pool_job (reuses a live pool job for the directory, else submits one) and submit_external_vllm_attached_job (depends on the pool job only while it is not READY). pool_dir.sh holds the helpers they share. Signed-off-by: sniverty <[email protected]>
…it helpers Run run_in_allocation.sh (serve), attach_and_run.sh and the pool_config.sh submit helpers end to end against stub srun/scontrol/getent/curl/squeue/ sbatch; the stub replicas register in the real backend registry. The stub squeue fails like the real one (non-zero exit), and the stub curl answers /health with a per-port healthy-backend count so tests can degrade a pool. Covers publishing, relaunch, READY withdrawn while degraded and restored, READY waiting for the load balancers, ownership refusal and takeover (finished, purged and requeued owners), the relaunch-count reset, the readiness gate built from the manifest, stale READY rejection, transient squeue failures, a purged pool job, stopping training on STOPPED, a generation change or a stale heartbeat, the lifetime check, and the submit helpers. The routing test now checks the per-mode srun selectors. Signed-off-by: sniverty <[email protected]>
Submission through the pool_config.sh helpers and attach_and_run.sh as the one attach path, the pool directory, failure handling (including that an attached job stops when its pool does, as inline mode stops NeMo RL when a judge exits), and the new settings. Signed-off-by: sniverty <[email protected]>
b551c62 to
16d060d
Compare
|
@saumishr @yfw , this borrows the manifest idea from your standalone-services POC (health URL + expected backends + restart count), and keeps replica relaunch and deferred attach. Happy to converge further on one design.
On the workflow question: yes a warm run is step 2 only, and the dependency matters only on a cold start. The |
|
/ok to test 16d060d |
…under the shared root run_in_allocation.sh refuses a tools directory outside EXTERNAL_VLLM_SHARED_ROOT (replicas mount it), and the stub environment pointed it at the repository checkout, so every serve-mode test exited before publishing READY. Copy tools/external_gym_vllm into tmp_path, as the stub environment's shared root, and let _attach_env callers override its defaults (COMMAND). Signed-off-by: sniverty <[email protected]>
external_vllm_job_state captured squeue's stderr in a mktemp file, which fails where /tmp is not writable. Capture stdout and stderr together instead; on success squeue prints only the state. Signed-off-by: sniverty <[email protected]>
|
/ok to test da99795 |
yfw
left a comment
There was a problem hiding this comment.
Thanks for working through @saumishr's review so thoroughly. Tying READY to the load balancers' own counts, the heartbeat and attach watcher, and resolving URLs when the job starts make this a solid base. I checked each of the 9 points at da99795, and all of them are in. Inline mode looks unchanged: under the test stubs, a clean run and a replica dying mid-run behave the same before and after this PR, and the only difference is --open-mode=append, which does nothing on fresh log files.
A few minor nits in the inline comments.
On converging with my standalone-services POC (11746b3b): this PR is the better base. It resolves URLs when the job starts, relaunches dead replicas, keeps READY in step with the load balancers, and stops attached jobs when the pool goes away.
Generated by Claude Code
external_vllm_job_state merges squeue's stderr into its output, and squeue can print a non-fatal error there (e.g. a slurm.conf warning on every call) and still succeed. The first line was then taken as the job's state, so a running pool job looked gone: a second pool job could be submitted and take over the live pool's directory, and attached jobs would stop. Keep only the line that is a bare state name. Tests: the stub squeue can print a warning on stderr first, and the serve-side ownership check is covered with a warning and with a failing squeue. Signed-off-by: sniverty <[email protected]>
…unch The replica body started vLLM with > LOG_FILE, which truncated vllm_<i>.log. In serve mode a dead replica is relaunched within one poll with the same log file, so the traceback explaining the crash was erased before anyone saw it. Append instead; inline mode starts every job with a fresh log directory and is unaffected. Signed-off-by: sniverty <[email protected]>
|
/ok to test 92c3a00 |
|
/ok to test 0c8f44b |
…failures-and-redispatch main gained #4745, #4542 and #4596 since the previous merge, which put this head eleven commits behind it; the merge keeps the head within main's up-to-date rule for CI. No conflicts. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
What does this PR do ?
EXTERNAL_VLLM_MODE=serve runs the pools as their own long-lived job; training jobs attach through attach_and_run.sh, which resolves the URLs and #4381's readiness gate from the pool's manifest at job start and stops training if the pool stops, is replaced, or goes silent. pool_config.sh gains submit_external_vllm_pool_job / submit_external_vllm_attached_job as the single entry point. Early Ray start (previously part of this PR) is superseded by #4381 and dropped.
Issues
Depends on NVIDIA-NeMo/Gym#4108: Gym's model-endpoint startup check must treat a load balancer's 503 (no healthy backend yet) as "still starting". Without it, both early Ray and attaching to a pool that is still loading can send rollouts to a judge with no healthy backend. The wait is bounded by env.nemo_gym.model_endpoint_readiness_timeout_seconds (Gym default 600 s); don't set it to 0, which skips the check.
Usage
Early Ray (inline, the existing two-hetgroup job): Ray, the driver and worker setup start as soon as the pools' load balancers are up, instead of after every replica is healthy.
EXTERNAL_VLLM_EARLY_RAY=1 sbatch ... tools/external_gym_vllm/run_in_allocation.sh # otherwise unchangedPersistent pools (serve): run the pools alone as a plain job that outlives any training job.
Once every pool is healthy, the job writes
<pool>_url,pools.env,job_idandlog_dirtoEXTERNAL_VLLM_POOL_DIR, andREADYlast. It relaunches a replica or load balancer that exits on the same nodes, so URLs never change (up toEXTERNAL_VLLM_MAX_RESTARTS, default 5). On exit it removesREADYand writesSTOPPED.Attach a training job:
READY, substitute each URL for its placeholder inCOMMANDand submitray.subdirectly.attach_and_run.shas the batch script. It waits forREADYfrom the expected pool job (EXTERNAL_VLLM_ATTACH_TIMEOUT, default 3600 s), then fills in the URLs and runsray.sub:inlinemode (the existing heterogeneous job) is unchanged, andEXTERNAL_VLLM_EARLY_RAYdefaults to 0.Before your PR is "Ready for review"
Pre checks:
Additional Information
End-to-end (Nemotron-3.5-nano GRPO recipe with GenRM, NL2Bash and safety-judge pools, on a GB300 Slurm cluster):
READY, then ran.