Repository navigation
Conversation
…hase run_training passes each rank's data pipeline build and partition check to the checkpoint manager's rank agreement before it applies a saved data position. A build that raises on one rank now raises on every rank, the others with an error naming it, instead of leaving them in the training loop's first collective until the process-group timeout. The mixture builder re-raises the sampler's refusal of the weights a data phase at step 0 sets with the "Data phase at step 0: " prefix a later phase's refusal carries.
A builder that splits sources per rank can leave a source too small on some ranks only, so a later data phase's weights could be refused there and nowhere else, after the ranks had agreed on the build. check_phase_weights, the check build_phase_state ran first, is now public, and run_training runs it inside the ranks' agreement on the data build, so that refusal fails every rank too. build_phase_state still runs it.
build_data mirrors run_training's data phase, which passes each rank's data build and data-phase weight check to the checkpoint manager's rank agreement before it applies a saved data position. build_data now does the same with build_data_pipeline, check_phase_weights and CheckpointManager.agree, so a build that fails on one rank fails the run on every rank instead of leaving the others in a later collective. The partition check run_training applies to a data_fn stays out: the example calls build_data_pipeline, which shards by get_dp_info, and its docstring already states that contract for a builder of your own. build_data's docstring and the README's ordering constraints gain the step, and three tests cover a build error and a refused data phase reaching the agreement, and the agreement coming before apply_dataloader_state.
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
agree_across_ranks raised the all-reduce's error alone when the all-reduce itself failed, for example with a gloo timeout because a healthy rank's work ran past the group's timeout, so a rank whose own part had failed reported only the timeout. Such a rank now re-raises its own error with the all-reduce's failure in a note, its cause left as it was, and a rank whose part succeeded raises the all-reduce's error with a note naming what the ranks were agreeing on. Every caller gets it, such as the checkpoint manager's agree, which saves, loads, the directory claim, the MoT warm start and the data build use. The success path and the path without a process group are unchanged. The check_phase_weights test gains a refused data phase at step 0, the data-flow startup list gains the data-build agreement, and the DataFn docstring says its promise holds for a builder that runs no collective of its own that a failing rank never enters.
…rror agree_across_ranks caught only an Exception from its all-reduce, so a KeyboardInterrupt, or any other failure that is not an Exception, still dropped the error of a rank whose own part had failed. It now catches every failure. An Exception still gives way to the rank's own error, which notes it, while an interrupt propagates as itself, so it still stops the run as an interrupt, with the rank's error in a note.
A rank whose own part failed now raises that error whatever the all-reduce raised, an interrupt such as KeyboardInterrupt included, with the failure in a note and the error's cause left as it was, instead of letting the interrupt replace it. The note gives the failure as Python prints it, so an interrupt with no message reads "KeyboardInterrupt". A rank without an error still raises the all-reduce's failure, noting what the ranks were agreeing on.
The note on a failed rank's error took only the first line Python prints for the all-reduce's failure, which for a failure printed on several lines, such as a SyntaxError, is a location line without the type or the message. It now keeps every line.
5 of 7 tasks
This was referenced Dec 5, 2026
Merged
…ve fails Four steps of the checkpoint manager run a collective of their own on its gloo group: the agreement before a save's write, the save's gather of every rank's loader and RNG state, a load's agreement on whether any rank's DCP index holds optimizer state, and the load's model check. When that collective itself failed, for example with a gloo timeout because another rank reached it only after the group's timeout, a rank whose own part had failed raised the collective's error alone. Each step now runs its collective through run_keeping_own_error, which agree_across_ranks now uses too: such a rank re-raises its own error with the collective's failure in a note, its cause left as it was, and a rank whose part succeeded raises the collective's error with a note naming the step. Rank 0 keeps its refusal of a checkpoint that does not fit the model the same way, and a save keeps an error its write raised before the gather. The success paths and the paths without a process group are unchanged. Tests make each step's collective fail, and a two-rank gloo test lets the agreement before the write time out on a rank that cannot create the step directory. The wait for another rank's outcome moves into tests/gloo_ranks.py, and the save() excerpt in the train-state page passes the gather its new argument.
This was referenced Dec 5, 2026
amazloumi
marked this pull request as ready for review
December 6, 2026 00:34
5 of 7 tasks
5 of 7 tasks
Naeemkh
self-requested a review
December 6, 2026 06:58
14 tasks done
This branch has not been deployed
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.
Summary
run_trainingbuilt the pipeline (data_fnorbuild_data_pipeline) and checked itsdp_rank/dp_sizeon each rank, with nothing agreeing the outcome, so the ranks whose build succeeded went on and waited in the training loop's first collective until the process-group timeout (distributed.nccl_timeout_sec, 1800 s by default) or the launcher's kill. The new_agreed_data_pipelineinkempnerforge/training/entry.pyruns the build, the partition check and the data-phase weight check, then passes the outcome to the checkpoint manager'sagree(agree_across_rankson the manager's own gloo group, as the MoT warm start andclaim_diruse it) before the saved data position is applied. The rank that failed raises its own error; every other rank raisesRuntimeError: Data pipeline build failed on ranks [N]. It costs one all-reduce of a small CPU tensor at startup; without a process group the error is raised locally, as before.agree_across_ranksinkempnerforge/distributed/utils.py, the helper behind the checkpoint manager'sagree(which saves, loads,claim_dir, the MoT warm start and now the data build use), raised the all-reduce's error alone when the all-reduce itself failed. When a healthy rank's build ran past the group's timeout, the rank whosedata_fnhad raised printed only gloo'sTimed out waiting ...ms for send operation to complete. That rank now raises its own error whatever the all-reduce raised, a timeout or an interrupt such asKeyboardInterrupt, with its cause left as it was and a note such asData pipeline build could not be agreed across ranks: RuntimeError: ... Timed out waiting 5000ms for send operation to complete; a rank whose part succeeded raises the all-reduce's failure with the noteData pipeline build succeeded on this rank but could not be agreed across ranks. The success path and the path without a process group are unchanged.CheckpointManagerrun a collective of their own on the manager's gloo group: the agreement before a save's write (_agree_to_write), the save's gather of every rank's loader and RNG state (_gather_rank_states), a load's agreement on whether any rank's DCP index holds optimizer state (_optimizer_saved_on_any_rank), and the load's model check (_check_model_fits). When that collective itself failed, as when another rank reached it only after the group's timeout (distributed.nccl_timeout_sec), a rank whose part had failed, such as one that could not create the step directory on a full disk, printed only gloo'sTimed out waiting ...ms for recv operation to complete. Each step now runs its collective throughrun_keeping_own_errorinkempnerforge/distributed/utils.py, whichagree_across_ranksnow uses too: that rank raises its own error, its cause left as it was, with a note such asCheckpoint save could not be agreed across ranks: RuntimeError: ... Timed out waiting 5000ms for recv operation to complete. Rank 0 keeps its refusal of a checkpoint that does not fit the model the same way, and a save keeps an error its write raised before the gather. A rank whose part succeeded raises the collective's failure with the noteCheckpoint save succeeded on this rank but could not be agreed across ranks(Checkpoint loadon a load). The success paths and the paths without a process group are unchanged.check_phase_weightsinkempnerforge/training/data_pipeline.py, the checkbuild_phase_stateran first, is now public and runs with the build, so that refusal fails every rank too.build_phase_statestill runs it._build_mixture_pipelinebuildsMixtureSamplerwith the weights a data phase at step 0 sets, and the constructor's refusal (weights that sum to 0, or a positive weight on a source with fewer samples than data-parallel ranks) reached the user without theData phase at step N:prefix a later phase's refusal carries. The builder now re-raises it withData phase at step 0:, through the helper the phase check uses. Without a step-0 phase the sampler's own error is unchanged. Adata_fnthat constructs its ownMixtureSamplerwith the phase's weights still gets the sampler's error from its own code, whichrun_trainingcannot attribute to the phase; that error now fails every rank through the agreement.run_trainingdoes.build_datainexamples/assembled_run/train.pymirrorsrun_training's data phase and built with no agreement either. It now runsbuild_data_pipelineandcheck_phase_weights, then the checkpoint manager'sagree, before it applies a saved data position, with public pieces only. The partition check stays out: the example builds withbuild_data_pipeline, which shards byget_dp_info, andbuild_data's docstring already states that contract for a builder of your own.build_data's docstring and the README's ordering constraints gain the step.docs/training/training-loop.md(the startup order),docs/architecture/data-flow.md(the startup list) anddocs/data/sampler.mdsay the same, and the excerpt ofsave()indocs/checkpointing/train-state.mdpasses_gather_rank_statesits new argument. TheDataFndocstring says its promise holds for a builder that runs no collective of its own that a failing rank never enters.codebase-map.jsonlistscheck_phase_weights,_agreed_data_pipelineandagree_across_ranksand their new test classes, addsrun_keeping_own_error, says what the manager's four agreement steps do when their collective fails, and counts the new tests.Testing
Every tier below ran at the head,
7d61eb9e, which merges main atd4e9b7ceinto the branch.ruff check .: clean;ruff format --check .: 353 files formatted;pyright kempnerforge/: 0 errorssphinx-build -W --keep-going -b html docs ...: build succeededpytest tests/unit --timeout=60 --cov --cov-branch): 6780 passed, 14 skipped (13 need CUDA, 1 needs the network), and the cluster-only timeout oftest_pipeline_checkpoint_layouts.py::TestAcrossRanks::test_the_stages_continue_a_run_saved_without_pp[muon-pp3], which runs past the 60 s limit on a busy cluster CPU node and passed alone here in 91 s with a longer limit.test_pipeline_checkpoint_layouts.py::TestAcrossRanks::test_the_stages_continue_a_run_saved_without_pp[muon-pp3], which alone passed here in 84 s with a longer limit.scripts/check_dependency_floors.py --group videopasses): 6779 passed, 15 skipped (13 need CUDA, 1 needs the network, 1 needsmlflow.telemetry, which the mlflow floor lacks), and the same cluster-only timeout oftest_pipeline_checkpoint_layouts.py::TestAcrossRanks::test_the_stages_continue_a_run_saved_without_pp[muon-pp3], which alone passed here in 96 s with a longer limit.ci-example.ymlruns them, on Python 3.14 and 3.12:examples/vlm/tests(withouteval/integration) 407 passed,examples/image_understanding/tests1587 passed andexamples/assembled_run/tests12 passed, on eachpytest tests/integration: 157 passedpytest tests/e2e --e2e --slow: 54 passedtorchrun --nproc_per_node=4 -m pytest tests/distributed --slow: 213 passed on every rank648d9e20with the test file of the second commit,b39ecc27, and pass here:TestADataPipelineErrorFailsEveryRank(two gloo ranks, a 30 s process-group timeout, only the last rank's data failing: itsdata_fnraises, or its sampler refuses a later data phase): there rank 0 is still inside 15 s after both ranks entered the data build; here rank 0 raisesRuntimeError: Data pipeline build failed on ranks [1]and rank 1 its own error within that time.TestBuildDataPipeline::test_a_step_zero_phase_whose_weights_the_sampler_refuses_is_named(3 cases): there the error is the sampler's own, naming no phase.TestRunTraining's partition test (2 cases),test_the_ranks_agree_on_the_data_build_before_its_loader_state_is_appliedandtest_a_data_phase_the_built_sampler_refuses_fails_through_the_agreement, andtest_check_phase_weights_checks_every_phase_against_the_built_mixture: no agreement, and nocheck_phase_weights, there.examples/assembled_run/testsfail atb39ecc27with the third commit's test file and pass here: atb39ecc27the agreement never sees the failed build or the refused data phase, andapply_dataloader_stateruns with no agreement before it.a675888e, up tod3cfab3d, fail ata675888ewithd3cfab3d's test files and pass here:TestAgreeAcrossRanksintests/unit/test_distributed.py(an all-reduce that raises: on a rank with an error, on a rank without one, with an error that already has a cause, with aKeyboardInterrupt, and with a failure Python prints on several lines): ata675888ethe all-reduce's error replaces the rank's own, and no note names the agreement or the rank's error.TestADataPipelineErrorFailsEveryRank::test_the_failed_rank_raises_its_own_error_when_the_agreement_times_out(two gloo ranks, a 5 s timeout on the checkpoint manager's group; the last rank'sdata_fnraises at once, and the other rank enters the agreement only after the last rank's wait in it has timed out): ata675888ethe last rank raises only gloo'sTimed out waiting 5000ms for send operation to complete; here it raisesRuntimeError: data_fn failed on rank 1, with the agreement's failure in a note.test_check_phase_weights_checks_every_phase_against_the_built_mixtureholds ata675888etoo, and fails oncecheck_phase_weightsskips a phase at step 0, a change that every other test intests/unit/test_train_entry.pyandexamples/assembled_run/testspasses.d4e569bffail atf0b5d717withd4e569bf's test files and pass here:TestAFailedSaveFailsEveryRank::test_the_failed_rank_raises_its_own_error_when_the_agreement_times_outintests/unit/test_pipeline_checkpoint.py, When a checkpoint save's pre-write agreement fails, the rank whose save failed raises only the collective's error, not its own #780's reproduction as a test (two gloo ranks under FSDP2, a 5 s timeout on the checkpoint manager's group; the last rank cannot create the step directory, and rank 0 starts its save only once the last rank's wait in the agreement before the write has timed out): atf0b5d717the last rank raises only gloo'sTimed out waiting 5000ms for recv operation to complete; here it raisesOSError: [Errno 28] No space left on device, with the agreement's failure in a note.TestAFailedSaveCommitsNothing(the agreement before a save's write: a rank whose step directory or previous flush failed, and one whose part succeeded),TestAFailedCaptureFailsEveryRankintests/unit/test_checkpoint_per_rank.py(the save's gather: a rank whose loader state or shard write failed, and one whose part succeeded),TestWeightDecayScopeOnResume(the agreement on the DCP index: a rank whose read failed, and one whose read succeeded) andTestACollectiveOfTheModelCheckThatFailsintests/unit/test_checkpoint_load_checks.py(the model check's gather and broadcast: a rank that could not list its entries, rank 0's failed comparison and its refusal, and a check that found nothing amiss): atf0b5d717the collective's error replaces the rank's own, and no note names the step.f0b5d717the rank whose part failed raises only gloo's timeout; here it raises its own error, with the timeout in a note.torchrun(60 s and 30 s on648d9e20), withRuntimeError: Data pipeline build failed on ranks [1]; A data phase at step 0 whose weights the mixture sampler refuses stops the run without naming the phase #765's step-0 cases now start withData phase at step 0:; in When a checkpoint save's pre-write agreement fails, the rank whose save failed raises only the collective's error, not its own #780'slatecase rank 1 now raisesOSError: [Errno 28] No space left on devicewith the agreement's timeout in a note, wheref0b5d717printed the timeout alone.kempnerforge/is covered in one process, bytests/unit/test_train_entry.py,tests/unit/test_distributed.py,tests/unit/test_checkpoint.py,tests/unit/test_checkpoint_per_rank.pyandtests/unit/test_checkpoint_load_checks.py.Closes #749
Closes #765
Closes #780