[Testcase Refactoring] Split Capability.distributed.fsdp into fsdp1/fsdp2, add sharded_tensor - #193778
Draft
shichuanliujie9527 wants to merge 9 commits into
Draft
Conversation
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>
🔗 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. |
This PR needs a
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds three capability identifiers under
Capability.distributed:fsdp1—torch.distributed.fsdp.FullyShardedDataParallelfsdp2—torch.distributed._composable.fsdp.fully_shardsharded_tensor—torch.distributed._shard.sharded_tensor.ShardedTensorThe existing
fsdpidentifier is left as-is; nothing here removes orchanges its meaning.
Motivation
Capability.distributed.fsdpdoesn't distinguishFullyShardedDataParallel(FSDP1) from
fully_shard(FSDP2) — the two have materially differentinternal requirements, so a single flag can't accurately gate either one.
Raised by @wjlFlyer on #192322 and #192323 (both test
FullyShardedDataParallelspecifically). Separately, @wjlFlyer noted on #192320 that
_create_chunk_sharded_tensorcoverage needs aShardedTensor-specificcapability, which didn't exist at all.
Changes
torch/testing/_internal/common_device_type.py:fsdp1,fsdp2,sharded_tensortoCapability.distributed;CPUTestBase/CUDATestBase/XPUTestBase_capabilities(), mirroring the existingfsdpentry'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
ruff check/ruff format --checkclean.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
mainonce#191919 merges. If danieldale2026 submits an equivalent addition first,
this PR is superseded in favor of that one.