[Test][Refactor] Decouple test_dataloader according to the accelerator relevance. (#189250)
## Summary - Refactored `test/test_dataloader.py` following the S1/S2/S3 decoupling strategy: ### test_dataloader.py - **S1 (accelerator-unrelated)**: `TestDataLoader` — 66 tests using no device APIs. - **S2 (accelerator-agnostic)**: `TestDataLoaderDevice` (renamed from `TestDataLoaderDeviceType`) — pin_memory tests using `instantiate_device_type_tests`. `TestDictDataLoaderDevice` — pin_memory tests with accelerator-generic guards. - **S3 (accelerator-specific)**: `TestDataLoaderCUDA` and `TestDataLoaderCUDAPersistentWorkers` - Renamed `TestDataLoaderDeviceType` → `TestDataLoaderDevice` per S2 convention. ### No test logic changed Only tests were split/moved between classes. No new tests added, none removed. ## Test evidence Test count preserved: ``` test/test_dataloader.py: 126 → 126 ✓ ``` Evidence commands: ```bash $ grep -c 'def test_' test/test_dataloader.py 126 ``` ## Refactoring strategy Per the refactor-test-decoupling methodology: - S3 > S2 > S1 classification hierarchy strictly followed. - Whitelist decorators (`@onlyCUDA`, `@unittest.skipIf(not TEST_CUDA, ...)`) enlarged to `@onlyAccelerator` / S3 class extraction. - Blacklist decorators (`@skipIfXpu`, `@skipIfRocm`, `@onlyNativeDeviceTypesAnd`) preserved as-is. - Category C APIs (CUDA IPC) are the only patterns that make a test S3. - `instantiate_device_type_tests` used for S2 classes. Authored with an AI assistant. Pull Request resolved: https://github.com/pytorch/pytorch/pull/189250 Approved by: https://github.com/guangyey, https://github.com/fffrog, https://github.com/Niran814804102, https://github.com/jansel
D
daisyden committed
8a531fc14a529e3e8f8edc92e2ef55ee98070cd3
Parent: 3574fb4
Committed by PyTorch MergeBot <pytorchmergebot@users.noreply.github.com>
on 8/24/2026, 3:56:22 AM