Feat/rl check preflight#2970
Open
anravich13-cloud wants to merge 11 commits into
Open
Conversation
Adds a preflight mode to the rl entrypoint that validates a run can start without launching it or writing to the output directory. Static tier (default, sub-second): client/server port match + bind probe, trainer GPU/cp divisibility (previously floor-divided silently), checkpoint resume-step existence, disk space thresholds, wandb/HF credential presence. Full tier (--check-level full): spawns each configured env server briefly to validate it loads (num_tasks, group scoring), and probes frozen-model and external inference endpoints instead of just logging 'make sure these are serving'. Checks are pure functions (RLConfig, HostProbe) -> [CheckResult] with a mockable HostProbe, unit-tested on CPU. Exit code: 0 if no failures (warnings allowed, CI-friendly), 1 otherwise.
…c doesn't erase the mismatch
…wns (cap 8) One flag, one behavior: the env and endpoint checks are the most valuable part of preflight, so they shouldn't hide behind an opt-in tier. Env servers now spawn with bounded concurrency (ENV_CHECK_CONCURRENCY = 8) so many-env configs finish in a few timeout windows without fork-bombing the launcher host; per-env timeout -> SKIP semantics unchanged.
…ert already catches this; the win is failing before side effects, not preventing stranded GPUs
Env.shutdown only sent SIGTERM and moved on, so a stuck env server could outlive --check (or hang preflight at exit, since the spawn is non-daemon and multiprocessing joins children at interpreter exit). Mirror Envs.shutdown's terminate -> join(25) -> kill -> join(5) sequence, and call it via asyncio.to_thread in the doctor so one wedged env doesn't stall the other parallel env checks.
…ll interfaces port_is_free now takes the host and check_ports passes inference.server.host (falling back to all interfaces, matching vLLM's default bind). Probing the exact address the server will bind keeps the check faithful; the probe never listens, so nothing is exposed.
…check to full ParallelDims validation Env timeout: asyncio.wait_for cannot interrupt the spawn's queue.get worker thread, so the 120s budget silently stretched to the thread's own 600s timeout (and asyncio.run joins executor threads at shutdown, delaying exit too). Env.start/_spawn now take spawn_timeout (default unchanged: ENV_SERVER_SPAWN_TIMEOUT) so preflight bounds the wait at its source; the outer wait_for remains only for the pure-async external-address path. Parallelism: the check only tested num_train_gpus % cp, but trainer startup asserts dp_replicate * dp_shard * cp * pp == world_size and the CP seq-len divisor. Mirror it by constructing ParallelDims (deferred torch import) with the same mapping as get_parallel_dims, plus the seq_len % (2*cp) rule. Explicit integer ep is validated; ep='auto' resolves at trainer startup and is reported as deferred.
…pping get_parallel_dims gains an optional world_size (defaults to dist.get_world_size(), so trainer callers are unchanged), letting preflight validate a hypothetical allocation through the exact function the trainer runs — no duplicated dp_shard/pp mapping or seq-len rule to drift.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 742fdb2. Configure here.
resolve_ep gains an optional world_size (defaults to dist.get_world_size(); trainer callers unchanged) so the parallelism check resolves ep='auto' with the trainer's own logic — MoE detection via the HF model config included — and validates EP divisibility with the value the trainer will actually use. When the HF config is unreachable (offline/gated), the check degrades to ep=1 and says so explicitly in the report instead of implying full validation. Closes the false-pass where e.g. a 12-GPU island with cp=3 auto-resolves ep=8 and crashes ParallelDims after launch prep.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

feat:
rl --checkpreflight doctorAdds a preflight mode to run some basic checks before starting runs:
validates the run and exits — without launching anything and without writing
to the output directory (unlike
--dry-run, which writes resolved configs).Exit code is 0 when nothing failed (warnings allowed, so CI can gate on it)
and 1 otherwise.
What it checks
base_urlport must equalinference.server.port— a mismatch means the orchestrator hangs against a dead port.ParallelDimsvalidation (incl. auto-EP resolution and seq-len divisor) so it fails here instead of after launch prep.resume_stepexists on disk; lists available steps if not.output_dir— FAIL < 5 GB, WARN < 100 GB (checkpoints die at first write, hours in).info— catches broken/missing envs.Design notes
(RLConfig, HostProbe) -> list[CheckResult]; theHostProbeseam (sockets, disk, env vars) exists so checks are unit-testableon CPU without real host state.
rl(), beforevalidate_output_dir/clean_future_steps— preflight must never mutate the output dir (today the first GPU-count
validation fires after the dir has been cleaned).
resuming, no envs) report SKIP with a reason rather than disappearing.
Test plan
examples/reverse_text/rl.toml: all-greenreport, wandb WARN correctly fired on a box without credentials, exit codes
0/1 as expected.
--ckpt.resume-step 999→ FAIL listing available steps.--dry-runand normal launch paths untouched (flag short-circuits beforethem;
checkexcluded from written configs).Follow-ups (out of scope)
rl_localto reuse these check functions at launch time so thelaunch path and
--checkcan't drift.sftentrypoint.minimal; the
HostProbeseam makes them cheap to add back).Note
Medium Risk
Touches the main
rl()entry path and spawns real env subprocesses with network probes, but normal launches are unchanged when--checkis off; optionalworld_sizeon parallel helpers is backward compatible.Overview
Adds
rl @ config.toml --check, a preflight mode that validates the run and exits beforeoutput_diris created or cleaned. Exit 0 if no failures (warnings OK); 1 on any failure.New
RLConfig.checkandprime_rl.utils.doctorrun host/config checks (client/inference port alignment, local inference bind probe, trainerParallelDims/ seq-len / auto-EP via optionalworld_size, checkpoint resume paths, disk space, wandb/HF credentials) plus live probes (HTTP for external/frozen inference URLs; bounded parallel env-server spawns with 120s timeout, SKIP on slow startup).rl()short-circuits torun_checksat the top;checkis excluded from dumped TOML. Envstart/shutdowngain configurablespawn_timeoutand stronger server teardown for the doctor path.Reviewed by Cursor Bugbot for commit f51dead. Bugbot is set up for automated code reviews on this repo. Configure here.