Skip to content

Fix checkpoint layer partitioning for uneven pipeline stages - #8543

Open
aprylewu wants to merge 1 commit into
deepspeedai:masterfrom
aprylewu:codex/fix-3588-pipeline-layer-partition
Open

aprylewu wants to merge 1 commit into
deepspeedai:masterfrom
aprylewu:codex/fix-3588-pipeline-layer-partition

Conversation

@aprylewu

Copy link
Copy Markdown

Fixes #3588.

For 70 transformer layers and 12 pipeline stages, DeepSpeedCheckpoint currently exposes only 60 layers through get_pp_transformer_map, while its separate file mapping creates 14 stages. This can omit layers when callers iterate over the configured pipeline ranks. With fewer layers than stages, file mapping also divides by zero.

Partition all transformer layers into the requested number of contiguous, balanced stages, then use that single partition to build the checkpoint file map. Divisible layouts retain their existing assignment, and empty stages return an empty state list. Tensor-parallel shard partitioning and merging are unchanged.

Validation

Added a parametrized regression using small real checkpoint files and public checkpoint loading methods. It covers the reported 70-layer/12-stage layout, uneven pipeline reduction, divisible partitions, empty stages, zero transformer layers, a single stage, a custom final-norm position, and both retained and merged tensor-parallel shards.

  • Original production code with the new regression: 15 failed, 6 passed.
  • Patched checkpoint test module: 29 passed (21 new cases and 8 existing tests).
  • All applicable changed-file pre-commit hooks and git diff --check: passed.

Executed on macOS arm64 CPU with Python 3.10.18 and PyTorch 2.8.0:

PYTHONDONTWRITEBYTECODE=1 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
DS_ACCELERATOR=cpu OMP_NUM_THREADS=1 PYTHONPATH="$PWD:$PWD/tests" \
python -m pytest tests/unit/checkpoint/test_reshape_checkpoint.py \
  --torch_ver=2.8.0 -q --tb=short

No GPU training or compiled-op tests were run. The tests exercise checkpoint discovery, layer assignment and loading, rather than training convergence.

This contribution was prepared with AI assistance. The reported regression and formatting checks were executed locally.

Signed-off-by: Mingyang Wu <mingyangwu@cuhk.edu.hk>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 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 Completed 2026-09-16T14:46:05.766483Z f2ea14b PR opened
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2ea14b93d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

i: transformer_layers[i * layers_per_pp:(i + 1) * layers_per_pp]
for i in range(0, self.pp_degree)
}
layers_per_pp, remainder = divmod(len(transformer_layers), self.pp_degree)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the required DCO sign-off

This is a non-merge commit, but its message has no Signed-off-by trailer, so it violates the repository's commit requirements and may be rejected by the DCO/CI checks. Recreate the commit with --signoff using the configured Git identity.

AGENTS.md reference: AGENTS.md:L8-L8

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] deepspeed_checkpoint.get_transformer_state has more PP_degree than real PP_degree

1 participant