pytorch-patterns

Provide best-practice patterns for building reliable PyTorch training pipelines and models.

1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/riftzen-bit/gemini-setup --skill pytorch-patterns-riftzen-bit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytorch-patterns
Source: https://github.com/riftzen-bit/gemini-setup/tree/main/skills/pytorch-patterns
Command: npx skills add https://github.com/riftzen-bit/gemini-setup --skill pytorch-patterns-riftzen-bit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill captures idiomatic PyTorch patterns and best practices to reduce bugs, training instability, and wasted GPU time when building models, training loops, data pipelines, and checkpointing strategies.

Core Features & Use Cases

  • Device-agnostic code: guidance to write models and data handling that run on CPU or GPU without modifications.
  • Reproducible experiments: seed management, deterministic CuDNN settings, and checkpointing for resumable training.
  • Robust training & validation loops: patterns for mixed precision, gradient clipping, proper mode switching, and efficient DataLoader settings.
  • Performance & scalability: recommendations for torch.compile, AMP, gradient checkpointing, and optimized data loading for large-scale training.
  • Use Case: Harden a research training script to run reliably on a GPU cluster and reproduce results across runs.

Quick Start

Use the pytorch-patterns skill to review and improve my PyTorch training loop for device-agnostic, reproducible GPU training.

Frequently Asked Questions about pytorch-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make my PyTorch training pipeline reproducible across multiple GPU runs?

Reproducible PyTorch pipelines require seed management, deterministic CuDNN settings, and checkpointing for resumable training to ensure consistent results across different GPU cluster runs.

What is the best way to write device-agnostic PyTorch models?

Device-agnostic PyTorch models use specific patterns to run on CPU or GPU without code modifications by properly handling device assignment for tensors and model parameters during training.

How do I optimize PyTorch data loading for large-scale deep learning training?

Optimize PyTorch data loading by configuring efficient DataLoader settings and applying techniques like mixed precision, gradient checkpointing, and torch.compile to improve performance and scalability for large-scale training.

Can I use mixed precision and gradient clipping in a PyTorch training loop?

Yes, robust PyTorch training loops support mixed precision (AMP) and gradient clipping. These patterns help stabilize training, prevent exploding gradients, and reduce wasted GPU time.

Does this PyTorch training skill support checkpointing for resumable workflows?

Yes, the skill provides checkpoint management patterns for resumable training workflows. This allows you to save and restore model states, ensuring research and production training continuity.

Why does my PyTorch training loop suffer from instability and wasted GPU time?

PyTorch training instability and wasted GPU time often stem from not using idiomatic patterns for mixed precision, gradient clipping, proper mode switching, or efficient DataLoader settings.