pytorch-patterns
PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading. Use when writing or reviewing PyTorch training loops, model architectures, or data loading, or when a run will not reproduce.
Target: Target not categorized. Automatically collected · unverified.
Excerpt from the author’s documentation
Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.
Read the original English text
Topics in the source
- PyTorch Development Patterns
- When to Activate
- Core Principles
- 1. Device-Agnostic Code
- 2. Reproducibility First
- 3. Explicit Shape Management
- Model Architecture Patterns
- Clean nn.Module Structure
Idiomatic PyTorch patterns and best practices for building robust, efficient, and reproducible deep learning applications. Writing new PyTorch models or training scripts Reviewing deep learning code Debugging training loops or data pipelines Optimizing GPU memory usage or training speed Setting up reproducible experiments Always write code that works on both CPU and GPU without hardcoding devices. Set all random seeds for reproducible results. Always document and verify tensor shapes. | Idiom | Description | |-------|-------------| | model.train() / model.eval() | Always set mode before train/eval | | torch.nograd() | Disable gradients for inference | | optimizer.zerograd(settonone=True) | More efficient gradient clearing | | .to(device) | Device-agnostic tensor/model placement | | torch.amp.autocast | Mixed precision for 2x speed | | pinmemory=True | Faster CPU→GPU data transfer | | torch.compile | JIT compilation for speed (2.0+) | | weightsonly=True | Secure model loading | | torch.manualseed | Reproducible experiments | | gradientcheckpointing | Trade compute for memory | Remember: PyTorch code should be device-agnostic, reproducible, and memory-conscious. When in doubt, profil
This is an excerpt. Refer to the complete source and its current requirements.
- Source repository
- affaan-m/ECC
- Source file
- pi/core/skills/pytorch-patterns/SKILL.md
- Fixed revision
- d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Sources and evidence
This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.
Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T15:01:43.204Z.
Categories are inferred from names, descriptions and paths. They do not establish compatibility.
License and attribution
MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.
Original license ↗Synchronization, copying and user-reported success do not mark a resource as runtime-tested.
Limitations and notes
- Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.