Skip to content

[checkpoint] Execute affine transfer plans with bounded peer staging - #8809

Open
0z5a wants to merge 1 commit into
deepspeedai:masterfrom
0z5a:codex/affine-checkpoint-pr-20261012
Open

0z5a wants to merge 1 commit into
deepspeedai:masterfrom
0z5a:codex/affine-checkpoint-pr-20261012

Conversation

@0z5a

@0z5a 0z5a commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

The merged #8623 planner describes affine shard copies. This PR executes those plans directly into existing frozen target shards with bounded peer staging, without reconstructing the full logical tensor.

Refs #8230, #8252 and 0z5a#1. This is the executor portion of that work; #8800 supplies live AutoEP metadata separately. The diff is limited to 3 files, 972 added lines: executor, contract tests and API documentation. Historical benchmark drivers and evidence remain in the fork and are linked below.

execute_transfer / execute_transfers accept explicit source and target rank bindings, preserve strided regions and storage offsets, and collectively reject invalid buffers, aliases or request-order disagreement before writes. Shared plans reuse their schedule within a call. CUDA handles drain every 32 rounds and before return; other work handles retain immediate waits.

Review fixes: CUDA tests check accelerator type and visible device count before worker launch; valid scalar plans now execute; the unrelated new_group(timeout=...) changes are removed, preserving the existing CCL interface.

Validation on this exact executor and test source:

Run Result
macOS arm64, Python 3.12.13, Torch 2.14.1, CPU executor contracts 38 passed, 10 CUDA cases skipped before launch
CPU planner and shard-map regression 178 passed
Linux, 2 H100, Python 3.12.1, Torch 2.12.1+cu130, CUDA 13.0, driver 595.91.07 47 passed, 1 eight-device case skipped before launch
Changed-file pre-commit All applicable hooks passed
DS_ACCELERATOR=cpu PYTHONPATH=tests python -m pytest tests/unit/checkpoint/test_affine_transfer_executor.py -q
DS_ACCELERATOR=cpu PYTHONPATH=tests python -m pytest tests/unit/checkpoint/test_affine_transfer_plan.py tests/unit/checkpoint/test_affine_shard_map.py -q
PYTHONPATH=tests python -m pytest --forked tests/unit/checkpoint/test_affine_transfer_executor.py -q
pre-commit run --files deepspeed/checkpoint/affine_transfer_executor.py tests/unit/checkpoint/test_affine_transfer_executor.py docs/code-docs/source/autoep.rst

On the same two H100s, restoring the original scalar predicate causes all four scalar regressions (single/batched, local/cross-process) to fail with the dimension-rejection defect. The fixed full file passes, including FP32/FP16/BF16 transfer, mixed storage windows, collective refusal, request ordering and a shared-plan batch spanning 48 rounds. The final pytest and Slurm step exit zero and the assigned GPU contexts are gone. Startup/resource failures are retained separately.

Historical eight-H100 non-scalar correctness evidence records 304 BF16/FP32 checks plus mixed-layout and shared-plan checks. Historical paired performance reports 1.289x geometric speedup, 95% CI [1.2703, 1.3080], for a 1-GiB synthetic frozen-weight handoff. These are prior non-scalar runs, not a new eight-GPU qualification of this rebased and reduced branch or a full-model performance claim.

Scope: scale-1 plans and frozen packed weights. No optimizer migration, live AutoEP swap, CPU/NVMe offload integration, training convergence/resumption, serving or non-CUDA vendor qualification. The staging budget applies per peer direction; a payload-time transport failure may partially modify targets. Maintenance contact: @0z5a.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 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-10-12T10:25:53.754720Z 35f904a 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.

@goransh-walia

Copy link
Copy Markdown

This looks like a solid, focused change.

@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: 35f904af97

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

local_rank = int(os.environ.get('LOCAL_RANK', dist.get_rank() if dist.is_initialized() else 0))
device = local_rank % max(get_accelerator().device_count(), 1)
get_accelerator().set_device(device)
return torch.device('cuda', device)

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 Skip CUDA-only transfer tests on CPU runners

When cpu-torch-latest runs this newly added file (the workflow invokes all of unit/ in .github/workflows/cpu-torch-latest.yml), DistributedTest initializes CPU/Gloo because CPU_Accelerator.is_available() is true, so these classes are not skipped; the first _full() then allocates on this unconditional CUDA device and fails with the CPU-only PyTorch build. Mark the distributed classes CUDA-only before launch while leaving the *CPU classes runnable.

Useful? React with 👍 / 👎.

Comment on lines +433 to +434
if get_accelerator().device_count() < self.world_size:
pytest.skip(f'needs {self.world_size} visible accelerators, found {get_accelerator().device_count()}')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip the eight-rank case before worker launch

On CUDA hosts exposing fewer than eight devices, this check runs too late to skip: DistributedTest first spawns world_size = 8, and DistributedTest._dist_run calls set_device(local_rank) before invoking the test method. Ranks beyond the available device count therefore fail during initialization, so ordinary 2/4-GPU full-suite runs fail or hang instead of reaching this pytest.skip; move the resource check to collection or launch time.

Useful? React with 👍 / 👎.

Comment thread deepspeed/comm/comm.py Outdated
return cdb.new_group(ranks)
if timeout is None:
return cdb.new_group(ranks)
return cdb.new_group(ranks, timeout=timeout)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Forward timeouts through the CCL new-group override

When oneCCL is available, init_distributed can install CCLBackend; calling the newly advertised dist.new_group(..., timeout=...) reaches this keyword call, but deepspeed/comm/ccl.py still defines new_group(self, ranks) only, so every timeout-bearing subgroup creation raises TypeError instead of creating a group. Extend that sibling override (and the base interface) or explicitly reject unsupported timeouts.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Comment on lines +185 to +186
if not segment.shape or len(segment.shape) != ndim:
raise AffineTransferExecutionError('segment dimensionality does not match its logical shape')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Accept scalar segments produced by the planner

When source and target maps describe a 0-D scalar (for example replicated_map((), 1)), plan_transfer legitimately emits a one-element TransferSegment whose shape is (), but this truthiness check rejects it before either a local or P2P copy. Consequently the generic executor cannot execute valid planner output for scalar parameters; validate dimensionality with len(segment.shape) != ndim without treating a zero-dimensional shape as an empty segment.

Useful? React with 👍 / 👎.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants