What problem does it solve?
This Skill helps modernize PyTorch test files that are tied to specific hardware, making them reusable across CPU, CUDA, XPU, MPS, and other accelerator backends without changing their intended behavior.
Core Features & Use Cases
- Hardware Classification: Categorizes test classes as GENERIC, DEVICE_GENERIC, DEVICE_SPECIFIC, MULTI_DEVICE_GENERIC, or MULTI_DEVICE_SPECIFIC.
- Structural Refactoring: Splits mixed test classes, adds hw_classification attributes, and applies the appropriate PyTorch testing infrastructure.
- Device-Agnostic Conversion: Replaces hardcoded device references with self.device_type and preserves relevant decorators, fixtures, and test coverage.
- Verification Guidance: Provides syntax checks, test execution steps, classification coverage checks, and a ready-to-use pull request checklist.
- Use Case: Apply the Skill to a PyTorch test file containing CPU logic, CUDA-specific tests, and device-independent tensor operations to classify each group, split the classes correctly, and verify that no tests were lost.
Quick Start
Ask the test-refactor skill to refactor the attached PyTorch test file for device-agnostic execution and generate the corresponding verification plan.