N Neurarch Try it See it Changes Bot Pricing API Open app

Models / gpt2

gpt2: GPU memory to fine-tune

Fine-tuning gpt2 at batch 1 and 512 tokens takes about 2.57 GB of GPU memory for a full fine-tune (fits one T4 16 GB), and 0.48 GB with LoRA r=16 on a bf16 base (fits one T4 16 GB). Estimated from the model's structure, not measured. What fits on which card.

Reconstructed from its own config.json with no weights read. 14.6M downloads on Hugging Face.

Our count against the checkpoint

The left number comes from the graph. The right one is the number of scalars in the published weight files. Nothing on this page was tuned to make them agree.

Derived from structure
124M
124,438,272 parameters
In the published checkpoint
137M
137,022,720 scalars · safetensors.total, read 2026-09-06
Delta
-9.18%

What it costs to run

Cost is a roofline estimate on the priced GPU for 10 epochs at batch 32, 512 tokens over 50,000 samples (assumed; no dataset attached).

Layers
74
Will it forward-pass
Yes
Priced on
A10G (24GB)
Est. one run
$1.76

Memory: what fits on which card

Largest batch per card. Training is sized at 512 tokens per sample, serving at 512 tokens per sequence.

Full fine-tune, batch 1 at 512 tokens
2.57 GB
LoRA r=16, batch 1 at 512 tokens
0.48 GB
Serve: bf16 weights
0.25 GB
Serve: KV cache, 512 tokens
19 MB
CardFull fine-tuneLoRA r=16Serve bf16, 512 tokens
T4 16 GBbatch 64batch 75batch 723
L4 24 GBbatch 103batch 114batch 1092
A100 40 GBbatch 180batch 192batch 1829
A100 / H100 80 GBbatch 374batch 386batch 3672
H200 141 GBbatch 670batch 681batch 6482

Training: 512 tokens per sample (2048, or the model's context when shorter), AdamW with bf16 autocast, SDPA attention (no score matrix stored), 1.15x headroom on every card. Full fine-tune holds weights, gradients and optimizer state (1.2 x 16 bytes per parameter) plus activations. LoRA is r=16 on every linear layer but the head, base frozen in bf16 (2 bytes per parameter), adapters at full AdamW state, same activations. A two-card split is a contiguous layer cut (pipeline parallel), computed only where one card cannot hold batch 1. Serving: bf16 weights plus the KV cache of 512 tokens per sequence; prefill working set, CUDA context and framework reserve not counted.

These are estimates from the graph, not measurements. Against measured runs, held out by architecture, the estimate flagged 113 of the 131 jobs that did not fit their card and said "fits" on the other 18. Every measured run.

Structure

76 nodes. Output shapes are propagated from the input shape, batch dimension excluded, at 512 tokens: the config's maximum context.

LayerTypeOutput shape
1InputInput1 × 512
2EmbeddingEmbedding1 × 512 × 768
3Positional_EmbeddingLearned Pos Embed1 × 512 × 768
4LayerNorm_1_1LayerNorm1 × 512 × 768
5Attention_1Multi-Head Attention1 × 512 × 768
6Add_1_attnAdd1 × 512 × 768
7LayerNorm_1_2LayerNorm1 × 512 × 768
8FFN_1Feed Forward1 × 512 × 768
9Add_1_ffnAdd1 × 512 × 768
10LayerNorm_2_1LayerNorm1 × 512 × 768
11Attention_2Multi-Head Attention1 × 512 × 768
12Add_2_attnAdd1 × 512 × 768
13LayerNorm_2_2LayerNorm1 × 512 × 768
14FFN_2Feed Forward1 × 512 × 768
15Add_2_ffnAdd1 × 512 × 768
16LayerNorm_3_1LayerNorm1 × 512 × 768
17Attention_3Multi-Head Attention1 × 512 × 768
18Add_3_attnAdd1 × 512 × 768
19LayerNorm_3_2LayerNorm1 × 512 × 768
20FFN_3Feed Forward1 × 512 × 768
21Add_3_ffnAdd1 × 512 × 768
22LayerNorm_4_1LayerNorm1 × 512 × 768
23Attention_4Multi-Head Attention1 × 512 × 768
24Add_4_attnAdd1 × 512 × 768
25LayerNorm_4_2LayerNorm1 × 512 × 768
26FFN_4Feed Forward1 × 512 × 768
27Add_4_ffnAdd1 × 512 × 768
28LayerNorm_5_1LayerNorm1 × 512 × 768
29Attention_5Multi-Head Attention1 × 512 × 768
30Add_5_attnAdd1 × 512 × 768
31LayerNorm_5_2LayerNorm1 × 512 × 768
32FFN_5Feed Forward1 × 512 × 768
33Add_5_ffnAdd1 × 512 × 768
34LayerNorm_6_1LayerNorm1 × 512 × 768
35Attention_6Multi-Head Attention1 × 512 × 768
36Add_6_attnAdd1 × 512 × 768
37LayerNorm_6_2LayerNorm1 × 512 × 768
38FFN_6Feed Forward1 × 512 × 768
39Add_6_ffnAdd1 × 512 × 768
40LayerNorm_7_1LayerNorm1 × 512 × 768
41Attention_7Multi-Head Attention1 × 512 × 768
42Add_7_attnAdd1 × 512 × 768
43LayerNorm_7_2LayerNorm1 × 512 × 768
44FFN_7Feed Forward1 × 512 × 768
45Add_7_ffnAdd1 × 512 × 768
46LayerNorm_8_1LayerNorm1 × 512 × 768
47Attention_8Multi-Head Attention1 × 512 × 768
48Add_8_attnAdd1 × 512 × 768
49LayerNorm_8_2LayerNorm1 × 512 × 768
50FFN_8Feed Forward1 × 512 × 768
51Add_8_ffnAdd1 × 512 × 768
52LayerNorm_9_1LayerNorm1 × 512 × 768
53Attention_9Multi-Head Attention1 × 512 × 768
54Add_9_attnAdd1 × 512 × 768
55LayerNorm_9_2LayerNorm1 × 512 × 768
56FFN_9Feed Forward1 × 512 × 768
57Add_9_ffnAdd1 × 512 × 768
58LayerNorm_10_1LayerNorm1 × 512 × 768
59Attention_10Multi-Head Attention1 × 512 × 768
60Add_10_attnAdd1 × 512 × 768
61LayerNorm_10_2LayerNorm1 × 512 × 768
62FFN_10Feed Forward1 × 512 × 768
63Add_10_ffnAdd1 × 512 × 768
64LayerNorm_11_1LayerNorm1 × 512 × 768
65Attention_11Multi-Head Attention1 × 512 × 768
66Add_11_attnAdd1 × 512 × 768
67LayerNorm_11_2LayerNorm1 × 512 × 768
68FFN_11Feed Forward1 × 512 × 768
69Add_11_ffnAdd1 × 512 × 768
70LayerNorm_12_1LayerNorm1 × 512 × 768
71Attention_12Multi-Head Attention1 × 512 × 768
72Add_12_attnAdd1 × 512 × 768
73LayerNorm_12_2LayerNorm1 × 512 × 768
74FFN_12Feed Forward1 × 512 × 768
75Add_12_ffnAdd1 × 512 × 768
76OutputOutput1 × 512 × 768

What the verifier says

infoAt 12 stacked attention layers, residual-branch outputs add up; unscaled init lets activation variance grow with depth. GPT-2/LLaMA-family models scale the residual projections by depth (N(0, 0.02 / √(2L))). Fix: Scale residual output projections by depth: nn.init.normal_(w, std=0.02 / math.sqrt(2 * n_layers))
deep-attention-default-init

What changed upstream

The change tracker follows openai-community/gpt2: every revision it has read, what changed in the config, tokenizer, chat template or weights between them, and an OSV advisory per change.

Do this to your own model

Same numbers, on a model in your repo, in one command. No account.

pip install neurarch-trace
neurarch-trace openai-community/gpt2 --plan --share