nanogpt-training

nanogpt-training is a skill for Claude Code, Codex from benchflow-ai/skillsbench. It costs 61 tokens per session (849 once invoked), scanned A, original, Apache-2.0.

A guide for training GPT-2-scale language models of about 124 million parameters on one GPU using tokenized text data and modern training methods.

In plain words
What is it for?
Use it to configure and run training with PyTorch, load data from local files or Hugging Face, choose optimizers, and experiment with residual designs.
Why use it?
It brings the model architecture, data loading, optimization, mixed-precision training, and loop details into one workflow.

Skill for Claude CodeCodex

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

Good fit Use it to configure and run training with PyTorch, load data from local files or Hugging Face, choose optimizers, and experiment with residual designs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/benchflow-ai/skillsbench/nanogpt-training
About the project

SkillsBench is a benchmark for measuring how effectively AI agents use modular skills—folders containing instructions, scripts, and resources—to complete specialized tasks. It helps researchers and developers evaluate both skill quality and agent behavior, including tasks that require combining multiple skills. The catalogue’s skills and instructions are evaluated as part of this workflow.

benchflow-ai/skillsbench · 1,760 stars · on GitHub · skillsbench.ai

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 benchflow-ai/skillsbench --skill nanogpt-training
Clone the repo
git clone --depth 1 https://github.com/benchflow-ai/skillsbench

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 nanogpt-training

README.md
[![agentmods](https://agentmods.dev/badge/skills/benchflow-ai/skillsbench/nanogpt-training/github.svg)](https://agentmods.dev/skills/benchflow-ai/skillsbench/nanogpt-training)
Your own site
<a href="https://agentmods.dev/skills/benchflow-ai/skillsbench/nanogpt-training"><img src="https://agentmods.dev/badge/skills/benchflow-ai/skillsbench/nanogpt-training/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 nanogpt-training

Your own site · 80×15
<a href="https://agentmods.dev/skills/benchflow-ai/skillsbench/nanogpt-training"><img src="https://agentmods.dev/badge/skills/benchflow-ai/skillsbench/nanogpt-training.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 849 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00061 $0.00849
Opus 5 $0.00030 $0.00425
Sonnet 5 $0.00012 $0.00170
Haiku 4.5 $0.00006 $0.00085

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

Security

Grade A, and why

nanogpt-training 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 11d 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.

tasks-extra/mhc-layer-impl/environment/skills/nanogpt-training/SKILL.md · 113 lines

How it starts

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

NanoGPT Training

Overview

Training GPT-2 scale models (~124M parameters) efficiently on a single GPU. It provides:

  • GPT-124M Architecture: Standard transformer with RoPE and modern optimizations
  • Tokenized Datasets: Loading pre-tokenized shards from HuggingFace Hub or local files
  • Modern Optimizers: Muon optimizer with Newton-Schulz orthogonalization
  • Mixed Precision: bfloat16 training on A100 for 2x speedup

Training options:

  • Baseline GPT: Standard residual connections
  • Experimental residual variants: Optional alternative residual schemes for stability/efficiency

Quick Reference

Topic Reference
Model Architecture GPT Architecture
Data Loading Tokenized Data
Optimizers Optimizers
Training Loop Training Loop
Hyperparameters Hyperparameters

Installation

pip install torch einops numpy huggingface_hub

Minimal Example

import modal

app = modal.App("gpt-training")

image = modal.Image.debian_slim(python_version="3.11").pip_install(
    "torch", "einops", "numpy", "huggingface_hub"
)

@app.function(gpu="A100", image=image, timeout=3600)
def train():
    import torch
    from dataclasses import dataclass

    @dataclass
    class GPTConfig:
        block_size: int = 1024
        vocab_size: int = 50257
        n_layer: int = 12
        n_head: int = 12
        n_embd: int = 768
        dropout: float = 0.0
        bias: bool = False

    # Download data, build model, train
    # ... (see references for full implementation)

    return {"final_loss": final_loss}

@app.local_entrypoint()
def main():
    results = train.remote()
    print(results)

Common Imports

import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.cuda.amp import autocast, GradScaler
from dataclasses import dataclass
from einops import rearrange, repeat, reduce
import numpy as np
import math

Read the full file on GitHub · 113 lines

Files

What ships with it

6 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 11d ago First seen · 113 lines · 61 tokens per session scan A c51a9d618912

Subscribe to this mod's changes

nanogpt-training is a skill published in the GitHub repository benchflow-ai/skillsbench (1,760 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 61 tokens to every session and 849 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.