Pytorch Patterns
PyTorch training, architecture, and data loading patterns covering device handling, reproducibility, and efficient pipelines.
- CCM score
- 71 of 100
- skills.sh installs
- 12.3K
- GitHub stars
- 312.6K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers device-agnostic code, seed control, shape annotations, module structure, weight initialization, training and validation loops, datasets, DataLoader tuning, and checkpointing
- Includes annotated Good and Bad code pairs for each pattern, such as hardcoded
.cuda()calls versustorch.deviceselection - Enforces
model.train()andmodel.eval()mode switching,set_to_none=Truegradient zeroing, and gradient clipping at a max norm of 1.0 - Designed for writing or reviewing training scripts, or debugging runs that will not reproduce
Install
$ npx -y skills add affaan-m/ecc --skill pytorch-patterns -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
PyTorch Development Patterns
Idiomatic PyTorch patterns and best practices for building robust, efficient, and reproducible deep learning applications.
When to Activate
- 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
Core Principles
1. Device-Agnostic Code
Always write code that works on both CPU and GPU without hardcoding devices.
# Good: Device-agnostic
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = MyModel().to(device)
data = data.to(device)
# Bad: Hardcoded device
model = MyModel().cuda() # Crashes if no GPU
data = data.cuda()
2. Reproducibility First
Set all random seeds for reproducible results.
# Good: Full reproducibility setup
def set_seed(seed: int = 42) -> None:
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
Details
- Repository
- github.com/affaan-m/ecc
- Categories
- Data Science & Analytics, AI Agents & LLM Apps, Python
- First seen
- Jul 14, 2026
Questions
What is the pytorch-patterns skill for?
The pytorch-patterns skill gives the agent PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading. It covers device-agnostic code, seed setup for reproducible runs, shape management, nn.Module structure, training and validation loops, custom datasets, DataLoader configuration, and checkpointing.
When should I use the pytorch-patterns skill?
Use it when writing or reviewing PyTorch training loops, model architectures, or data loading. It also applies when a training run will not reproduce, or when you want to optimize GPU memory use or training speed.
How do I install the pytorch-patterns skill?
Run npx -y skills add affaan-m/ecc --skill pytorch-patterns -y in your project. After that, the agent can write and review PyTorch code using the skill's device handling, seeding, mixed precision training, and checkpoint patterns.
Where does pytorch-patterns rank in its category?
It is in the Data Science & Analytics category and ranks in the top 25 on that category page. Other skills in the category that lead it include azure-kusto, analyze-project, run-train, explore-run, and python-executor, while this skill focuses on PyTorch deep learning code specifically.
More from affaan-m/ecc
All 257- Bun Runtime12.3K
- Ai First Engineering12.3K
- Flutter Dart Code Review12.2K
- Perl Security12.2K
- Regex Vs Llm Structured Text12.2K
- Compose Multiplatform Patterns12.2K
- Continuous Agent Loop12.2K
- Content Hash Cache Pattern12.1K
- Kotlin Testing12.1K
- Ai Regression Testing12.1K
- Browser Qa12.1K
- Design System12.1K
- Jira Integration12K
- Investor Outreach12K
- Documentation Lookup12K
- Remotion Video Creation12K
- Swift Actor Persistence12K
- Swift Protocol Di Testing12K
- Blueprint12K
- Git Workflow11.9K
- Foundation Models On Device11.9K
- Exa Search11.9K
- Swift Concurrency 6 211.9K
- Nestjs Patterns11.9K
Similar to Pytorch Patterns
More Data Science & Analyticsdeep-learningmindrally/skills995 installsPractical guidelines for neural network design, training, multi-GPU scaling, and memory optimization in PyTorch-style workflows.
pytorchmindrally/skills884 installsDeep learning guidance for PyTorch models covering transformers, diffusion pipelines, and GPU training optimization.
pytorch-lightningorchestra-research/ai-research-skills1.1K installsHigh-level PyTorch training framework that removes boilerplate while scaling from one GPU to multi-node distributed runs.
ml-training-recipesorchestra-research/ai-research-skills1.1K installsBattle-tested PyTorch training recipes spanning LLMs, vision, diffusion, and biomedical domains with debugging guidance.
pytorch-fsdpdavila7/claude-code-templates395 installsExpert guidance for PyTorch FSDP training covering parameter sharding, mixed precision, CPU offloading, and FSDP2.
torchcode-pytorch-interview-practicereason-machines/trending-skills753 installsLeetCode-style PyTorch interview practice with auto-grading for implementing operators and transformer components from scratch.