Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
amazloumi
left a comment
There was a problem hiding this comment.
Approve. The vote timing adds no collective and leaves every stop decision unchanged: in a 4-rank run with a shutdown signal on one rank, head and main stop and save at the same step, the logged mean counts NaN-skipped steps correctly, and on GPU the new metric shows sub-millisecond values with throughput unchanged. The new tests catch every mutation tried, and the gate is green.
Two points that should not hold up the merge:
-
Merging this will close #564, although #564 still needs the multi-node measurement this PR only makes possible: the body's last paragraph says "otherwise close #564", which GitHub reads as a closing keyword. Rewording that line keeps #564 open.
-
The paragraph in docs/resilience/slurm-preemption.md about folding the vote into the NaN check describes a decision still open in #564, so it goes stale once that is settled; the docs could keep only what the metric measures and leave the decision to the issue.
Summary
Part of #564, which asks for a measurement of the per-step shutdown vote on 8 or more GPU nodes before deciding whether to fold it into the NaN check's all-reduce.
_shutdown_if_requestedcasts the shutdown vote: one blocking gloo MAX all-reduce over the control group, which carries the shutdown flag and, since Publish an async checkpoint once every rank's write has ended, and fit the shutdown timer to the signal lead #723,CheckpointManager.flushing. It runs aftertracker.end_step, sostep_time, tok/s and MFU leave it out, and no metric showed what it costs.time.perf_counter, with no synchronization added; the flags are read before the clock starts. On each step whose metrics are logged, it logs the mean over the votes since the last logged step asdistributed/shutdown_vote_ms, throughtracker.log_eval, so it reaches stdout, W&B, TensorBoard and MLflow like the loop's other metrics. The vote of a step skipped for a NaN loss counts toward the next logged mean, a shutdown at a logged step logs its vote before the emergency checkpoint, and eachrun_training_loopcall starts its own interval. The loop keeps a running sum and count of the votes' times, so its memory stays the same whatevermetrics.log_intervalis.[step 10] distributed/shutdown_vote_ms=0.3540, and its backends get the new series. A single-process run is unchanged. Nothing else changes: the vote, its flags, its place in the step and every stop decision stay as they are, and no collective is added.docs/metrics-and-profiling/index.mdandmetrics-tracker.mdlist the key and say what it measures,docs/training/training-loop.mdnames it beside the checkpoint times, anddocs/resilience/slurm-preemption.mdsays what it is for: deciding Fold the per-step shutdown vote into the NaN check's all-reduce #564 from a multi-node run, where folding would move both of the vote's flags into the NaN check and save only the all-reduce's own latency.codebase-map.jsonlists the new test classes.Defaults taken, each yours to reverse
log_evalline after the vote, not a field of the step line. The vote runs afterend_step, so a value in the step line would cover the previous interval's votes and be missing at step 1.Testing
uv run ruff check .passesuv run ruff format --check .passesuv run pyright kempnerforge/passes (0 errors)uv run pytest tests/unit/ -v --timeout=60passes on the first two commits (c1e6f222), apart from 39 failures the CPU test machine causes (6636 passed, 14 skipped): 38 tests intest_vlm_dataset.pyandtest_video_dataset.pyneedgpt2from a Hugging Face cache this offline machine no longer has, and onetest_hooks.pycase hitErrno 39while removing its temporary directory on the shared filesystem;test_hooks.pypasses when run alone (43 passed). The three later commits were run on the two test files they touch, as listed below.uv run torchrun --nproc_per_node=4 -m pytest tests/distributed/ -v(not run: it needs 4 GPUs, and no module underkempnerforge/distributed/changed; the vote's real gloo path is covered by the two-rank unit test below)uv run pytest tests/e2e/ --e2e -v(not run: it needs GPUs; the change only adds a timer and a log call after the existing vote)New tests:
tests/unit/test_train_entry.py::TestShutdownVoteTimeruns the loop on a control group with a fake clock, where the k-th vote takes k ms and the shutdown handler's reinstall and check before each vote take 1 s each, which the vote's time must leave out. With a metrics interval of 3 and 7 steps, the backend gets the key at steps 1, 3 and 6 only, the steps that logtrain/loss, with 1.0, 2.5 and 5.0 ms. A shutdown asked at step 3 logs 2.5 ms there. A NaN-skipped step 2 logs nothing and its vote counts in step 3's mean. A second loop on the same session starts its own interval. A run without a control group logs no vote time.tests/unit/test_shutdown_agreement.py::TestShutdownVoteTimeruns the real loop on two gloo ranks, on the control group the loop makes: with a metrics interval of 3, both ranks log a positive mean at steps 1, 3 and 6.Failing first, against main 3899909 with only the two test files changed:
The last test keeps main's single-process behavior. Each of these changes to the code fails at least one of the tests: dropping the per-loop reset, dropping the control-group check, logging on every step, starting the clock before the handler's reinstall and check, or recording the vote only when no rank asked to stop. The last two passed the tests as they were before the slow handler and the stop-step test.
Commits after review, and their checks:
0857152cTest that the vote time leaves out the handler and covers a stop step:test_train_entry.pyandtest_shutdown_agreement.pyat this commit, 431 passed.9ce25befKeep a running sum and count of the vote times, not a list: the same two files at the head, 431 passed.db64875fSay that folding moves both of the vote's flags and saves only its latency: Sphinx-W --keep-goingbuilds clean at the head.codebase-map.jsonparses with only main's known count mismatches.Also checked: the new doc anchors resolve in the built HTML, and the branch merges cleanly with main and with every open PR (#648, #709, #770, #775, #776, #777, #781, #782, #783, #784, #787, #788), and the new tests pass on its merges with the three that share code or test files (#775, #776, #782).
Contribution terms
Part of #564. What remains: read
distributed/shutdown_vote_msagainsttrain/step_time_secfrom a run on 8 or more GPU nodes, then fold the vote intoNaNDetector.check_loss's all-reduce (or cast it withasync_op=True) only if it costs more than about 1% of a step, and otherwise close #564.