pytorch-patterns

pytorch-patterns is a skill for Claude Code, Codex from sjarmak/coding-agent-workflows. It costs 32 tokens per session (2,889 once invoked), scanned A, a copy of pytorch-patterns, MIT.

A guide to PyTorch, a Python library for building and training machine-learning models, with advice on models, data loading, devices, and reproducibility.

In plain words
What is it for?
Use it when writing or reviewing models and training scripts, debugging data pipelines, improving GPU use, or setting up repeatable experiments.
Why use it?
It helps avoid training code that only works on one type of hardware or produces results that cannot be reproduced.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing or reviewing models and training scripts, debugging data pipelines, improving GPU use, or setting up repeatable experiments.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sjarmak/coding-agent-workflows/pytorch-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add sjarmak/coding-agent-workflows --skill pytorch-patterns
Clone the repo
git clone --depth 1 https://github.com/sjarmak/coding-agent-workflows

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pytorch-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/sjarmak/coding-agent-workflows/pytorch-patterns/github.svg)](https://agentmods.dev/skills/sjarmak/coding-agent-workflows/pytorch-patterns)
Your own site
<a href="https://agentmods.dev/skills/sjarmak/coding-agent-workflows/pytorch-patterns"><img src="https://agentmods.dev/badge/skills/sjarmak/coding-agent-workflows/pytorch-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pytorch-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/sjarmak/coding-agent-workflows/pytorch-patterns"><img src="https://agentmods.dev/badge/skills/sjarmak/coding-agent-workflows/pytorch-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,889 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 83% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00032 $0.02889
Opus 5.5 $0.00013 $0.01156
Sonnet 5.5 $0.00006 $0.00578
Haiku 4.5 $0.00003 $0.00289

Measured 18d ago against content hash dead3d8fb7cc, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pytorch-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 18d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

83% identical to pytorch-patterns — 7 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

source/skills/pytorch-patterns/SKILL.md · 402 lines

How it starts

The opening of the file, as written. The whole thing — 402 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PyTorch Development Patterns

Use the project's installed version and conventions. Verify version-sensitive APIs, security settings, and deployment support with documentation-lookup before applying examples; these patterns are reference guidance, not a tested guarantee for every current release. Do not replace an existing toolchain solely to match an example.

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

# Bad: No seed control
model = MyModel()  # Different weights every run

3. Explicit Shape Management

Always document and verify tensor shapes.

# Good: Shape-annotated forward pass
def forward(self, x: torch.Tensor) -> torch.Tensor:
    # x: (batch_size, channels, height, width)
    x = self.conv1(x)    # -> (batch_size, 32, H, W)
    x = self.pool(x)     # -> (batch_size, 32, H//2, W//2)
    x = x.view(x.size(0), -1)  # -> (batch_size, 32*H//2*W//2)
    return self.fc(x)    # -> (batch_size, num_classes)

# Bad: No shape tracking
def forward(self, x):
    x = self.conv1(x)
    x = self.pool(x)
    x = x.view(x.size(0), -1)  # What size is this?
    return self.fc(x)           # Will this even work?

Read the full file on GitHub · 402 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 18d ago First seen · 402 lines · 32 tokens per session scan A dead3d8fb7cc

Subscribe to this mod's changes

pytorch-patterns is a skill published in the GitHub repository sjarmak/coding-agent-workflows (6 stars, last pushed 18d ago), licensed MIT. It adds 32 tokens to every session and 2,889 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 83% identical to pytorch-patterns, differing in 7 lines, and is treated as a copy.

Related

Other skills, from other repositories

agent-platform-endpoint-management

Manages Agent Platform serving endpoints. Use when you need to create, list, describe, update, or delete serving endpoints for model deployment on Agent Platform. Also use when troubleshooting endpoint permission, quota, or resource busy errors. Don't use for deploying models to endpoints or for running model…

google/skills · 64 tokens

gpt-image-2

A skill for generating or editing images with GPT Image 2 across local, host-provided, or advisory setups.

ConardLi/garden-skills · 177 tokens

ml-kit-genai-prompt-api

Analyzes Android codebases to implement ML Kit GenAI Prompt API. Use this skill to send natural language requests on-device to Gemini Nano, use structured output with Prompt API, implement prefix caching, optimize the current prompt, or apply best practices.".

android/skills · 57 tokens

LQF_Machine_Learning_Expert_Guide

LQF Machine Learning Expert Guide - Routed skill for ML/Statistical Modeling with Critical Discussion Mode. Triggers on: machine learning, modeling, prediction, training, classification, regression, clustering, deep learning, neural network, model evaluation, feature engineering, hyperparameter tuning, overfitting…

foryourhealth111-pixel/Vibe-Skills · 152 tokens

nowait-reasoning-optimizer

Implements the NOWAIT technique for efficient reasoning in R1-style LLMs. Use when optimizing inference of reasoning models (QwQ, DeepSeek-R1, Phi4-Reasoning, Qwen3, Kimi-VL, QvQ), reducing chain-of-thought token usage by 27-51% while preserving accuracy. Triggers on "optimize reasoning", "reduce thinking tokens"…

foryourhealth111-pixel/Vibe-Skills · 110 tokens

vss-benchmark-vlm-qa

Benchmark video Q&A accuracy and latency of a deployed RT-VLM (Cosmos Reason 3) via vss vlm run, using questions and videos from the DSS vss-devx-base dataset. Replaces the deprecated nat eval / vss-agent QA path. Not for tool-calling or trajectory evaluation, and not for LVS summarization throughput.

NVIDIA-AI-Blueprints/video-search-and-summarization · 80 tokens