Skip to content

Send rank 0's error building the Hugging Face eval set to every rank - #792

Open
amazloumi wants to merge 3 commits into
mainfrom
fix/eval-set-rank0-error
Open

amazloumi wants to merge 3 commits into
mainfrom
fix/eval-set-rank0-error

Conversation

@amazloumi

@amazloumi amazloumi commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Summary

  • An error building the Hugging Face eval set on rank 0 now fails every rank at once, naming rank 0's error. With eval.hf_dataset_name set, build_eval_dataloader built the eval set on rank 0 alone, then every rank met in a broadcast of the number of packed sequences, and nothing told the other ranks when rank 0's build raised: a tokenizer, dataset, config or split that does not resolve, a Hub or network error, an eval set without the data.hf_dataset_text_field column, or a split too short to fill one sequence. Once NCCL had connected the ranks, as tensor parallelism does, they waited in that broadcast until distributed.nccl_timeout_sec (1800 s by default) and NCCL's watchdog ended them, or until the launcher killed them (about 30 s under torchrun and srun --kill-on-bad-exit=1), and where they failed sooner, as under data parallelism alone, their error did not name rank 0's. Rank 0 now catches its build error and broadcasts its outcome, the number of sequences or the error, before the sequences, as _newest_save in scripts/eval.py and CheckpointManager._broadcast_train_state already do. Rank 0 raises its own error; every other rank raises RuntimeError: Rank 0 could not build the eval set from <name> (<split>): <rank 0's error>. When rank 0's error cannot be formatted, as with a malformed SyntaxError, the others get its type's name alone (<unprintable SyntaxError>), so formatting it never keeps rank 0 out of the broadcast.
  • The outcome goes out with broadcast_object_list on the default process group, in place of the count's tensor broadcast. torch runs object collectives on the CPU over Gloo under the default distributed.backend (cpu:gloo,cuda:nccl), and on the current GPU when the backend is NCCL alone; the sequences still go out with the same dist.broadcast on the run's device. A healthy build gains one small collective (the object broadcast sends the payload's size, then the payload). Without a process group nothing changes: the process builds the set and raises its own error.
  • Rank 0 keeps its own error when the outcome cannot be sent. If the outcome's broadcast itself raises, as when another rank is gone or reaches it only after the group's timeout, rank 0 still raises its build error, with the broadcast's failure in a note; a rank without a build error, rank 0 after a good build included, raises the broadcast's failure with a note naming the eval set: Rank 0's outcome for the eval set from <name> (<split>) could not be broadcast.
  • scripts/eval.py builds its Hugging Face eval set through the same helper, broadcast_hf_eval_set in kempnerforge/training/data_pipeline.py, in place of its copy of the block, so an error there fails every rank the same way. The helper is public because a script imports it, and codebase-map.json lists it. Its docstring states the devices: the outcome on torch's object-collective device, the sequences on the given device, the result on the CPU. docs/data/huggingface.md says what a build error on rank 0 does.

Testing

Every tier below ran at the head, c8112fcc, which branches from main at bdaf4a4c. The two GPU runs of the eval-set build at the end ran at 9c546cf1, the commit before the head, whose changes leave both paths they take unchanged.

  • ruff check .: all checks passed; ruff format --check .: 353 files already formatted; pyright kempnerforge/: 0 errors
  • Docs: sphinx-build -W --keep-going -b html docs ...: build succeeded, with broadcast_hf_eval_set in the generated API reference
  • Unit, Python 3.12, under coverage as CI runs it (pytest tests/unit --timeout=60 --cov --cov-branch): 6700 passed, 14 skipped (13 need CUDA, 1 needs the network), and the cluster-only timeout of test_pipeline_checkpoint_layouts.py::TestAcrossRanks::test_the_stages_continue_a_run_saved_without_pp[muon-pp3], which ran past the 60 s limit and passed alone here, under coverage, at the 60 s limit and with a longer one.
  • Unit, Python 3.14: 6700 passed, 14 skipped (13 need CUDA, 1 needs the network), and the same [muon-pp3] timeout, which passed alone here with a longer limit, in 88 s.
  • Unit at the dependency floors (Python 3.12.16, torch 2.12.0, installed as CI's floors job installs them; scripts/check_dependency_floors.py --group video passes): 6699 passed, 15 skipped (13 need CUDA, 1 needs the network, 1 needs mlflow.telemetry, which the mlflow floor lacks), and the same [muon-pp3] timeout, which passed alone here, at the 60 s limit and with a longer one.
  • Examples, as ci-example.yml runs them, on Python 3.14 and 3.12: examples/vlm/tests (without eval/integration) 407 passed, examples/image_understanding/tests 1587 passed and examples/assembled_run/tests 9 passed, on each.
  • Integration (1 H200): pytest tests/integration: 157 passed
  • E2E (4 H200): pytest tests/e2e --e2e --slow: 54 passed
  • Distributed (4 H200): torchrun --nproc_per_node=4 -m pytest tests/distributed --slow: 213 passed on every rank
  • Smoke on 4 H200: the image-understanding example's VLM under FSDP2 over 4 ranks: train 200 steps and save, auto-resume ("Resumed from step 200, 13,107,200 tokens seen", the DataLoader position kept) to step 400 and save, with no logged step repeated; step 400 evaluated on 4 ranks and on 1 rank gives byte-identical predictions on all 765 rows. Training windows RealUtil 48.0%.
  • The new tests fail on bdaf4a4c with this head's test files and pass here:
    • TestHuggingFaceEvalSetAcrossRanks::test_an_error_building_it_on_rank_zero_raises_on_every_rank in tests/unit/test_train_entry.py (two gloo ranks run build_eval_dataloader; rank 0's HuggingFaceDataset cannot reach its eval set, and each rank catches what it raises and stays in the group, as a rank's NCCL peers keep waiting for it): there rank 1 is still in the build 30 s after both ranks entered it; here rank 0 raises its ConnectionError and rank 1 RuntimeError: Rank 0 could not build the eval set from no-such-org/no-such-eval-set (validation): ConnectionError: ... within that time.
    • TestEvalScriptHuggingFaceEvalSet::test_an_error_building_it_on_rank_zero_raises_on_every_rank in tests/unit/test_eval_script.py, the same through scripts/eval.py's main on two gloo ranks: there rank 1 is still in main 30 s after both ranks entered it; here both ranks raise as above.
    • TestEvalDataloaderBuilder::test_rank_zero_raises_its_own_build_error_when_it_cannot_send_it, test_a_rank_without_a_build_error_raises_a_failed_send_naming_the_eval_set (on rank 0 after a good build and on rank 1) and test_rank_zero_sends_a_build_error_it_cannot_format: there rank 0 sends no outcome at all. The last two also fail on 9c546cf1, the commit before the head: there a failed send reaches a rank without a build error with no note, and formatting the malformed SyntaxError raises before rank 0 enters the broadcast.
    • Also new, and passing on bdaf4a4c as here: test_every_rank_gets_the_rows_rank_zero_built (two gloo ranks get the same rows) and test_hf_eval_raises_its_build_error_when_not_distributed.
  • The issue's reproduction, run as its body shows it on 2 H200 with NCCL and tensor parallelism: on bdaf4a4c rank 1 of the two-process launch exits with status 134 about 110 s after rank 0 raises, and torchrun exits about 30 s after it; on 9c546cf1 both ranks of the two-process launch, and torchrun, exit with status 1 about 0 s after rank 0 raises, rank 1 with RuntimeError: Rank 0 could not build the eval set from no-such-org/no-such-eval-set (validation): ConnectionError: Couldn't reach 'no-such-org/no-such-eval-set' on the Hub (OfflineModeIsEnabled).
  • A Hugging Face eval set that builds, on 2 H200 with tensor parallelism (WikiText-2's validation split read from local files offline, with the GPT-2 tokenizer): scripts/train.py builds the same 486 sequences as on bdaf4a4c and logs the same eval/loss at steps 10 and 20, and scripts/eval.py reports the same eval/loss and perplexity as on bdaf4a4c for the same checkpoint.
  • Every added line and branch in kempnerforge/ is covered by tests/unit/test_train_entry.py, the gloo ranks it spawns included.

Closes #778

@amazloumi amazloumi added the core Affecting core label Dec 6, 2026
@codecov

codecov Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
kempnerforge/training/data_pipeline.py 98.52% <100.00%> (+4.65%) ⬆️

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…ublic

A rank without a build error notes the eval set and split on a failed
broadcast of rank 0's outcome, and rank 0 sends an error it cannot format by
its type's name. scripts/eval.py imports the helper as broadcast_hf_eval_set,
whose docstring states its devices; the codebase map and the Hugging Face data
page describe it.
@amazloumi
amazloumi marked this pull request as ready for review December 6, 2026 11:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Affecting core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An error building the Hugging Face eval set raises on rank 0 alone and leaves the other ranks waiting in its broadcast

1 participant