Skip to content

Add block-atomic DBuffer placement - #6978

Open
wujingyue wants to merge 1 commit into
NVIDIA:mainfrom
wujingyue:agent/mfsdp-block-atomic
Open

Add block-atomic DBuffer placement#6978
wujingyue wants to merge 1 commit into
NVIDIA:mainfrom
wujingyue:agent/mfsdp-block-atomic

Conversation

@wujingyue

@wujingyue wujingyue commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

What

  • Add BlockAtomic(block_size), a dim-0 DBuffer sharding placement that keeps row blocks on one rank.
  • Establish one block-aligned GlobalLayout per parameter group and share it across its weights, gradients, and temporary buffers.
  • Build Flat and BlockAtomic layouts with one packing rule; Flat is the block_size=1 case.

Why

BlockAtomic provides the layout guarantee needed by block-wise parameter formats. A group-owned layout keeps its buffers compatible even when their current placements differ.

Related to #5615.

Testing

  • /opt/venv/bin/python -m torch.distributed.run --nproc-per-node 2 -m pytest -q tests/unit_tests/distributed/mfsdp_v2/test_dbuffer.py tests/unit_tests/distributed/mfsdp_v2/test_fully_shard.py — 49 passed, 12 skipped
  • The 5-rank exact-layout case requires more GPUs than this host exposes.

@copy-pr-bot

copy-pr-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@wujingyue
wujingyue force-pushed the agent/mfsdp-block-atomic branch 14 times, most recently from bbae52d to 268638f Compare August 31, 2026 14:20
Comment thread megatron/core/distributed/fsdp/src/megatron_fsdp/experimental/dbuffer.py Outdated
Comment thread tests/unit_tests/distributed/mfsdp_v2/test_dbuffer.py
Comment thread tests/unit_tests/distributed/mfsdp_v2/test_dbuffer.py Outdated
Comment thread tests/unit_tests/distributed/mfsdp_v2/test_dbuffer.py Outdated
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
@wujingyue
wujingyue force-pushed the agent/mfsdp-block-atomic branch from 268638f to d866c63 Compare August 31, 2026 14:55
@wujingyue
wujingyue marked this pull request as ready for review August 31, 2026 14:56
@wujingyue
wujingyue requested a review from a team as a code owner August 31, 2026 14:56
f"Cannot compute a layout for zero-sized non-leading dims: {shape}."
)
chunk_size = math.lcm(chunk_size, row_size)
# Match Transformer Engine MXFP8's whole-block requirement:

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.

@NVIDIA/megatron-fsdp to double check. This appears to be an over constraint but happens to simplify the logic in this function.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant