torchscan

torchscan is a skill for Claude Code, Codex from frgfm/torch-scan. It costs 56 tokens per session (556 once invoked), scanned A, original, Apache-2.0.

A tool for inspecting PyTorch models and measuring their operators, computation, and peak memory use. PyTorch is a Python framework for building and running machine-learning models.

In plain words
What is it for?
Use it to inspect model structure, count parameters, measure FLOPs and memory for a workload, compare model versions, and find unsupported operations.
Why use it?
It provides reports and comparisons while showing when measurements are incomplete or unavailable, so results are not mistaken for exact totals.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/frgfm/torch-scan/torchscan
Any agent
npx skills add frgfm/torch-scan --skill torchscan
Clone the repo
git clone --depth 1 https://github.com/frgfm/torch-scan

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 torchscan

README.md
[![agentmods](https://agentmods.dev/badge/skills/frgfm/torch-scan/torchscan.svg)](https://agentmods.dev/skills/frgfm/torch-scan/torchscan)
Your own site
<a href="https://agentmods.dev/skills/frgfm/torch-scan/torchscan"><img src="https://agentmods.dev/badge/skills/frgfm/torch-scan/torchscan.svg" alt="Measured on agentmods" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 556 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found 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.00056 $0.00556
Opus 5 $0.00028 $0.00278
Sonnet 5 $0.00011 $0.00111
Haiku 4.5 $0.00006 $0.00056

Measured 5d ago against content hash bfbfdb6b2916, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

torchscan 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 5d 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.

.agents/skills/torchscan/SKILL.md · 48 lines

What it actually says

TorchScan

Use the smallest API that answers the request:

  • crawl_module(...): JSON-serializable module report.
  • summary(...): printed table plus the same report.
  • measure_flops(workload): operator FLOPs for one zero-argument workload call.
  • measure_peak_memory(workload, device=...): backend-specific PyTorch peak memory.
  • compare_reports(before, after): pure same-schema comparison.

Workflow

  1. Reuse the project's model and representative inputs. Do not download weights without permission.
  2. Prefer args and kwargs for real calls; use input_shape only for simple synthetic tensors.
  3. Use strict=True when incomplete module metrics must stop automation.
  4. Serialize the report directly. Never parse the summary table.
  5. Check every metric's status and preserve diagnostics.
  6. Ask the owner for thresholds. TorchScan measures; it does not decide whether a model fits.

Truth rules

  • complete: use value with its method, unit, scope, and context.
  • partial: known_value is only a lower bound; do not extrapolate.
  • unavailable: report that no measurement was produced.
  • Zero is valid only with status == "complete".
  • Keep module FLOPs and operator FLOPs separate.
  • Peak PyTorch memory is not process RSS or total device memory.
  • Mocked or skipped CUDA/MPS checks are not hardware evidence.

For an uncounted operator, preserve the partial result. Rerun the equivalent workload with measure_flops(..., custom_mapping=...) only when the owner can justify that operator's counting convention; crawl_module does not accept custom mappings. Do not create a global registry, baseline store, wrapper service, or automatic budget policy.

In a repository checkout, read ../../../docs/docs/agent-quickstart.md for the full workflow and ../../../docs/docs/report-schema.md for the report contract. Outside a checkout, use the published documentation at https://frgfm.github.io/torch-scan/.

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. 5d ago First seen · 48 lines · 56 tokens per session scan A bfbfdb6b2916

Subscribe to this mod's changes

torchscan is a skill published in the GitHub repository frgfm/torch-scan (222 stars, last pushed 5d ago), licensed Apache-2.0. It adds 56 tokens to every session and 556 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

model-integration

Use when adding a new model or pipeline to diffusers, setting up file structure for a new model, converting a pipeline to modular format, or converting weights for a new version of an already-supported model.

huggingface/diffusers · 45 tokens

custom-blocks

Use when the user has written (or wants to write) a ModularPipelineBlocks subclass in a local Python file and needs to package it into a Hub-uploadable directory. Covers the workflow from a single block.py file to a published custom-block repo that consumers can load via ModularPipeline.frompretrained( …

huggingface/diffusers · 79 tokens

physicsnemo-shard-tensor

Official NVIDIA-authored guidance for PhysicsNeMo ShardTensor domain parallelism — integrate domain parallelism into training/inference scripts (new or existing) with DDP or FSDP2, write and register shard patches to enable new layers/ops, and bootstrap multi-GPU correctness tests. Use when working with ShardTensor…

NVIDIA/physicsnemo · 152 tokens

physicsnemo-discover

Official NVIDIA-authored guidance for navigating PhysicsNeMo — pick the model, datapipe, or example for a SciML/AI4Science task (surrogates, forecasting, downscaling, physics-informed, inverse, generative). Points at existing files via live repo search; never writes code. Do NOT use for installation or environment…

NVIDIA/physicsnemo · 124 tokens

perforatedai

Expert in PerforatedAI library for adding artificial dendrites to PyTorch neural networks. Triggers: 'Perforate my model' (start interactive setup), 'debug my perforated model' (debug/optimize existing integration), 'load my perforated model for inference' (deploy trained models). Also use when: debugging dendrite…

PerforatedAI/PerforatedAI · 115 tokens

trl

Reference for the TRL (Transformer Reinforcement Learning) library codebase. Use proactively before reading or editing any file under trl/ so you have the intended contracts and invariants in mind, not just what the current code says. Covers trainer hierarchy (SFT, DPO, GRPO, KTO), shared utility functions…

benchflow-ai/skillsbench · 100 tokens