Skip to content

Cover ZeRO-3 DP-resize rejection before serial checkpoint loading - #8897

Open
Levius-Fubuki wants to merge 2 commits into
deepspeedai:masterfrom
Levius-Fubuki:fix/zero3-serial-checkpoint-load
Open

Levius-Fubuki wants to merge 2 commits into
deepspeedai:masterfrom
Levius-Fubuki:fix/zero3-serial-checkpoint-load

Conversation

@Levius-Fubuki

@Levius-Fubuki Levius-Fubuki commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Add regression coverage for ZeRO-3 rejecting legacy checkpoints with a different data-parallel size before serial checkpoint synchronization. The production preflight is already in merged #8891; this follow-up retains that upstream engine implementation and makes this PR test-only against master 9148ab22.

The regression saves real optimizer state at DP=1 and loads at DP=2 with both load_optimizer_states flags, serial loading enabled/disabled, and FP32/FP16/BF16. Every rank must raise the existing topology error and reach a barrier. The valid serial round trip now covers full-state and module-only loading with torch Adam.

Local validation on 2026-10-30: Apple M3, macOS 15.1 ARM64, Python 3.12.13, torch 2.14.1, CPU/Gloo:

DS_ACCELERATOR=cpu CUDA_VISIBLE_DEVICES=0,1,2,3 LOCAL_SIZE=4 GLOO_SOCKET_IFNAME=lo0 OMP_NUM_THREADS=1 PYTHONPATH=.:tests python -m pytest --forked tests/unit/checkpoint/test_zero_optimizer.py::TestZeRO3CheckpointDPChange tests/unit/checkpoint/test_zero_optimizer.py::TestZeROCheckpoint::test_pipeline_checkpoint_loading --torch_ver=2.14.1 -q

Result: 10 passed, 4 skipped (FP16 unsupported). Changed-file pre-commit passes. No training arithmetic, checkpoint format, or runtime code changes relative to current master. #8898 separately fixes token handoff for successful serial loads. Historical GPU results in the previous description apply to the original implementation, not this test-only integration; no new CUDA/NCCL, offload or multi-node validation is claimed.

Negative control: restricting the current preflight to load_optimizer_states=True leaves the serial masters-only case hung until the external 180-second deadline (exit 124). This is a timeout observation, not a normal pytest assertion failure. The original engine was restored in finally; that exact selected case then passes again. The final engine is byte-for-byte current master.

AI assistance (OpenAI Codex) was used to prepare and execute this follow-up. Published follow-up: ae939211 integrates upstream master 9148ab22 in the existing PR branch. The submitting human confirmed reviewing the final diff and running the relevant tests, and authorized DCO sign-off and publication.

Copilot AI balanced review requested due to automatic review settings October 24, 2026 00:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-27T01:45:32.203667Z db3d4fc Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Contributor Author

@codex review

Comment thread deepspeed/runtime/engine.py Outdated

def _load_zero_checkpoint(self, load_dir, tag, load_optimizer_states=True):

# All ranks must validate the topology before waiting for the serial-load token.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align to #8891 because zero checkpoints can be loaded even if load_optimizer_states=False.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the merged #8891 implementation: ZeRO-3 still reads its saved FP32 partition when load_optimizer_states=False, so the preflight must cover that case as well. I have prepared a test-only follow-up against current master 3dd1293f, keeping #8891's engine implementation unchanged and parametrizing the DP=1→2 rejection over both optimizer-state flags, serial loading on/off, and FP32/FP16/BF16.

Local validation on Apple M3/macOS ARM64, Python 3.12.13, torch 2.14.1, CPU/Gloo: 10 passed and 4 skipped (FP16 unsupported), including valid serial round trips using torch Adam. A control restricted to the old optimizer-state-only preflight timed out for the serial masters-only case. Changed-file pre-commit passes. The follow-up is prepared locally and awaits the submitting human's diff review before a signed push; the published branch has not changed yet. No new CUDA/NCCL run is claimed.

@Levius-Fubuki Levius-Fubuki Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the guidance. Addressed in ae939211, which integrates master 9148ab22 and retains #8891's engine preflight unchanged. This PR is now test-only against that upstream baseline: both optimizer-state flags, serial loading on/off, FP32/FP16/BF16, and valid full-state/module-only serial round trips using torch Adam.

On Apple M3, macOS 15.1 ARM64, Python 3.12.13, torch 2.14.1, CPU/Gloo, the targeted selection reports 10 passed, 4 skipped (FP16 unsupported); changed-file pre-commit checks pass. Restricting the preflight to optimizer-state loads reproduces the serial masters-only hang (external 180-second deadline); restoring the upstream engine makes the selected case pass again.

The follow-up is now pushed and the PR description has been updated. No new CUDA/NCCL run is claimed. Thank you for helping align this with #8891.

@Levius-Fubuki Levius-Fubuki changed the title Validate ZeRO checkpoint DP size before serial-load synchronization Cover ZeRO-3 DP-resize rejection before serial checkpoint loading Oct 30, 2026
@auto-pr-labeler-with-jev auto-pr-labeler-with-jev Bot added the skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU. label Nov 14, 2026

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

skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants