Skip to content

[Testcase Refactoring] Split Capability.distributed.fsdp into fsdp1/fsdp2, add sharded_tensor - #193778

Draft
shichuanliujie9527 wants to merge 9 commits into
pytorch:mainfrom
shichuanliujie9527:test/fsdp-variant-capability-registry
Draft

[Testcase Refactoring] Split Capability.distributed.fsdp into fsdp1/fsdp2, add sharded_tensor#193778
shichuanliujie9527 wants to merge 9 commits into
pytorch:mainfrom
shichuanliujie9527:test/fsdp-variant-capability-registry

Conversation

@shichuanliujie9527

Copy link
Copy Markdown

Summary

Adds three capability identifiers under Capability.distributed:

  • fsdp1torch.distributed.fsdp.FullyShardedDataParallel
  • fsdp2torch.distributed._composable.fsdp.fully_shard
  • sharded_tensortorch.distributed._shard.sharded_tensor.ShardedTensor

The existing fsdp identifier is left as-is; nothing here removes or
changes its meaning.

Motivation

Capability.distributed.fsdp doesn't distinguish FullyShardedDataParallel
(FSDP1) from fully_shard (FSDP2) — the two have materially different
internal requirements, so a single flag can't accurately gate either one.
Raised by @wjlFlyer on #192322 and #192323 (both test FullyShardedDataParallel
specifically). Separately, @wjlFlyer noted on #192320 that
_create_chunk_sharded_tensor coverage needs a ShardedTensor-specific
capability, which didn't exist at all.

Changes

  • torch/testing/_internal/common_device_type.py:
    • add fsdp1, fsdp2, sharded_tensor to Capability.distributed;
    • add corresponding entries to CPUTestBase/CUDATestBase/XPUTestBase
      _capabilities(), mirroring the existing fsdp entry's check in each
      (CPU: False; CUDA/XPU: _distributed_backend_available(cls.device_type)).

No behavior change for existing callers of Capability.distributed.fsdp.

Test Plan

Related

Depends on #191919 (introduces Capability.distributed). Part of #185590.
Unblocks #192320, #192322, #192323.

Notes

Stacked on #191919's exact head commit; will be rebased onto main once
#191919 merges. If danieldale2026 submits an equivalent addition first,
this PR is superseded in favor of that one.

orangeH25 and others added 9 commits August 12, 2026 03:21
Extend the device capability framework with distributed, safetensors, stream,
and non-blocking copy requirements. Run capability admission from the device
test setup so unsupported and undeclared requirements stop before template
setup or worker startup, while retaining the method wrapper as a fallback.

The OpenReg regression installs its capability map and setup hook on the
generated device class. This preserves the generated class MRO and verifies
that supported tests execute while unsupported and missing capabilities do not
reach template setup.

Test Plan:

```bash
PYTHONPATH=/tmp/pr191919-openreg-deps-20260813T081214Z TORCH_DEVICE_BACKEND_AUTOLOAD=0 /home/daniel/workspace/pytorch-dev/pytorch/.venv/bin/python test/run_test.py --openreg
PATH=/home/daniel/workspace/pytorch-dev/pytorch/.venv/bin:$PATH spin fixlint -- torch/testing/_internal/common_device_type.py test/cpp_extensions/open_registration_extension/torch_openreg/tests/test_testing.py
git diff --cached --check
```

OpenReg ran 259 tests: OK (skipped=21, expected failures=2).

Authored with assistance from Codex.

Signed-off-by: danieldale2026 <danieldale2026@gmail.com>
@pytorch-bot

pytorch-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/193778

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot

pytorch-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

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.

4 participants