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

Models / llama

llama2-embedding-1b-8k: GPU memory to fine-tune

Fine-tuning llama2-embedding-1b-8k at batch 1 and 2048 tokens takes about 22.3 GB of GPU memory for a full fine-tune (fits one A100 40 GB), and 3.92 GB with LoRA r=16 on a bf16 base (fits one T4 16 GB). Estimated from the model's structure, reading the config under transformers semantics, not measured. What fits on which card.

Reconstructed from its own config.json with no weights read. 216K 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
1.07B
1,071,713,536 parameters
In the published checkpoint
947M
946,902,528 scalars · safetensors.total, read 2023-10-10
Delta
+13.2%

custom-code This repository ships its own modeling code (`auto_map`, e.g. `modeling.py`), so `config.json` names a class in the repo rather than an architecture `transformers` defines. The graph below is what those config keys mean under `transformers` semantics, which is not necessarily what the repo's own file builds. A gap here is a statement about what we read, not about the checkpoint.

What it costs to run

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

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

Memory: what fits on which card

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

Full fine-tune, batch 1 at 2048 tokens
22.3 GB
LoRA r=16, batch 1 at 2048 tokens
3.92 GB
Serve: bf16 weights
2.14 GB
Serve: KV cache, 4096 tokens
0.27 GB
CardFull fine-tuneLoRA r=16Serve bf16, 4096 tokens
T4 16 GB2 cards at batch 1 (18 + 10 layers)batch 6batch 43
L4 24 GB2 cards at batch 1 (27 + 1 layers)batch 11batch 69
A100 40 GBbatch 8batch 19batch 121
A100 / H100 80 GBbatch 29batch 39batch 251
H200 141 GBbatch 60batch 71batch 448

Training: 2048 tokens per sample (2048, or the model's context when shorter; the structure table is at the config's maximum, 32768), 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 4096 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

30 nodes. Output shapes are propagated from the input shape, batch dimension excluded, at 32768 tokens: the config's maximum context, not the 2048 the memory above is sized at.

LayerTypeOutput shape
1InputInput1 × 32768
2EmbeddingEmbedding1 × 32768 × 4096
3RoPERoPE1 × 32768 × 4096
4RMSNorm_1_1RMSNorm1 × 32768 × 4096
5Attention_1Grouped Query Attn1 × 32768 × 4096
6Add_1_attnAdd1 × 32768 × 4096
7RMSNorm_1_2RMSNorm1 × 32768 × 4096
8FFN_1SwiGLU1 × 32768 × 4096
9Add_1_ffnAdd1 × 32768 × 4096
10RMSNorm_2_1RMSNorm1 × 32768 × 4096
11Attention_2Grouped Query Attn1 × 32768 × 4096
12Add_2_attnAdd1 × 32768 × 4096
13RMSNorm_2_2RMSNorm1 × 32768 × 4096
14FFN_2SwiGLU1 × 32768 × 4096
15Add_2_ffnAdd1 × 32768 × 4096
16RMSNorm_3_1RMSNorm1 × 32768 × 4096
17Attention_3Grouped Query Attn1 × 32768 × 4096
18Add_3_attnAdd1 × 32768 × 4096
19RMSNorm_3_2RMSNorm1 × 32768 × 4096
20FFN_3SwiGLU1 × 32768 × 4096
21Add_3_ffnAdd1 × 32768 × 4096
22RMSNorm_4_1RMSNorm1 × 32768 × 4096
23Attention_4Grouped Query Attn1 × 32768 × 4096
24Add_4_attnAdd1 × 32768 × 4096
25RMSNorm_4_2RMSNorm1 × 32768 × 4096
26FFN_4SwiGLU1 × 32768 × 4096
27Add_4_ffnAdd1 × 32768 × 4096
28Final_RMSNormRMSNorm1 × 32768 × 4096
29LM_HeadLinear1 × 32768 × 32000
30OutputOutput1 × 32768 × 32000

What the verifier says

No finding on the reconstructed graph. See the checks.

What changed upstream

The change tracker follows mesolitica/llama2-embedding-1b-8k: 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 mesolitica/llama2-embedding-1b-8k --plan --share

Other llama checkpoints

dolphin-2.9.1-yi-1.5-34b
34.39B derived · +0.00% against the checkpoint
Llama-3.1-8B-Instruct
8.03B derived · +0.00% against the checkpoint
Llama-3.2-1B-Instruct
1.24B derived · -0.00% against the checkpoint
Meta-Llama-3.1-8B-Instruct
8.03B derived · +0.00% against the checkpoint