Models / gemma2
gemma-2-9b-it: GPU memory to fine-tune
Fine-tuning gemma-2-9b-it at batch 1 and 2048 tokens takes about 192 GB of GPU memory for a full fine-tune (2 x H200 141 GB, split by layer), and 33.9 GB with LoRA r=16 on a bf16 base (borderline on one A100 40 GB). Estimated from the model's structure, not measured. What fits on which card.
Reconstructed from its own config.json
with no weights read. 711K 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.
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).
Memory: what fits on which card
Largest batch per card. Training is sized at 2048 tokens per sample, serving at 4096 tokens per sequence.
| Card | Full fine-tune | LoRA r=16 | Serve bf16, 4096 tokens |
|---|---|---|---|
| T4 16 GB | does not fit at batch 1 | does not fit at batch 1 | does not fit at batch 1 |
| L4 24 GB | does not fit at batch 1 | does not fit at batch 1 | batch 1 |
| A100 40 GB | does not fit at batch 1 | batch 1, borderline | batch 11 |
| A100 / H100 80 GB | does not fit at batch 1 | batch 3 | batch 36 |
| H200 141 GB | 2 cards at batch 1 (156 + 98 layers) | batch 7 | batch 73 |
Training: 2048 tokens per sample (2048, or the model's context when shorter; the structure table is at the config's maximum, 8192), 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. "Borderline" means the card holds batch 1 on the estimate but not on the conservative peak (the estimate x 1.43, at or above the measured peak on 95% of held-out runs): measure one step before reserving it. 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
256 nodes. Output shapes are propagated from the input shape, batch dimension excluded, at 8192 tokens: the config's maximum context, not the 2048 the memory above is sized at.
| Layer | Type | Output shape | |
|---|---|---|---|
| 1 | Input | Input | 1 × 8192 |
| 2 | Embedding | Embedding | 1 × 8192 × 3584 |
| 3 | RoPE | RoPE | 1 × 8192 × 3584 |
| 4 | RMSNorm_1_1 | RMSNorm | 1 × 8192 × 3584 |
| 5 | Attention_1 | Local Attention | 1 × 8192 × 3584 |
| 6 | Add_1_attn | Add | 1 × 8192 × 3584 |
| 7 | RMSNorm_1_2 | RMSNorm | 1 × 8192 × 3584 |
| 8 | FFN_1 | SwiGLU | 1 × 8192 × 3584 |
| 9 | Add_1_ffn | Add | 1 × 8192 × 3584 |
| 10 | RMSNorm_2_1 | RMSNorm | 1 × 8192 × 3584 |
| 11 | Attention_2 | Grouped Query Attn | 1 × 8192 × 3584 |
| 12 | Add_2_attn | Add | 1 × 8192 × 3584 |
| 13 | RMSNorm_2_2 | RMSNorm | 1 × 8192 × 3584 |
| 14 | FFN_2 | SwiGLU | 1 × 8192 × 3584 |
| 15 | Add_2_ffn | Add | 1 × 8192 × 3584 |
| 16 | RMSNorm_3_1 | RMSNorm | 1 × 8192 × 3584 |
| 17 | Attention_3 | Local Attention | 1 × 8192 × 3584 |
| 18 | Add_3_attn | Add | 1 × 8192 × 3584 |
| 19 | RMSNorm_3_2 | RMSNorm | 1 × 8192 × 3584 |
| 20 | FFN_3 | SwiGLU | 1 × 8192 × 3584 |
| 21 | Add_3_ffn | Add | 1 × 8192 × 3584 |
| 22 | RMSNorm_4_1 | RMSNorm | 1 × 8192 × 3584 |
| 23 | Attention_4 | Grouped Query Attn | 1 × 8192 × 3584 |
| 24 | Add_4_attn | Add | 1 × 8192 × 3584 |
| 25 | RMSNorm_4_2 | RMSNorm | 1 × 8192 × 3584 |
| 26 | FFN_4 | SwiGLU | 1 × 8192 × 3584 |
| 27 | Add_4_ffn | Add | 1 × 8192 × 3584 |
| 28 | RMSNorm_5_1 | RMSNorm | 1 × 8192 × 3584 |
| 29 | Attention_5 | Local Attention | 1 × 8192 × 3584 |
| 30 | Add_5_attn | Add | 1 × 8192 × 3584 |
| 31 | RMSNorm_5_2 | RMSNorm | 1 × 8192 × 3584 |
| 32 | FFN_5 | SwiGLU | 1 × 8192 × 3584 |
| 33 | Add_5_ffn | Add | 1 × 8192 × 3584 |
| 34 | RMSNorm_6_1 | RMSNorm | 1 × 8192 × 3584 |
| 35 | Attention_6 | Grouped Query Attn | 1 × 8192 × 3584 |
| 36 | Add_6_attn | Add | 1 × 8192 × 3584 |
| 37 | RMSNorm_6_2 | RMSNorm | 1 × 8192 × 3584 |
| 38 | FFN_6 | SwiGLU | 1 × 8192 × 3584 |
| 39 | Add_6_ffn | Add | 1 × 8192 × 3584 |
| 40 | RMSNorm_7_1 | RMSNorm | 1 × 8192 × 3584 |
| 41 | Attention_7 | Local Attention | 1 × 8192 × 3584 |
| 42 | Add_7_attn | Add | 1 × 8192 × 3584 |
| 43 | RMSNorm_7_2 | RMSNorm | 1 × 8192 × 3584 |
| 44 | FFN_7 | SwiGLU | 1 × 8192 × 3584 |
| 45 | Add_7_ffn | Add | 1 × 8192 × 3584 |
| 46 | RMSNorm_8_1 | RMSNorm | 1 × 8192 × 3584 |
| 47 | Attention_8 | Grouped Query Attn | 1 × 8192 × 3584 |
| 48 | Add_8_attn | Add | 1 × 8192 × 3584 |
| 49 | RMSNorm_8_2 | RMSNorm | 1 × 8192 × 3584 |
| 50 | FFN_8 | SwiGLU | 1 × 8192 × 3584 |
| 51 | Add_8_ffn | Add | 1 × 8192 × 3584 |
| 52 | RMSNorm_9_1 | RMSNorm | 1 × 8192 × 3584 |
| 53 | Attention_9 | Local Attention | 1 × 8192 × 3584 |
| 54 | Add_9_attn | Add | 1 × 8192 × 3584 |
| 55 | RMSNorm_9_2 | RMSNorm | 1 × 8192 × 3584 |
| 56 | FFN_9 | SwiGLU | 1 × 8192 × 3584 |
| 57 | Add_9_ffn | Add | 1 × 8192 × 3584 |
| 58 | RMSNorm_10_1 | RMSNorm | 1 × 8192 × 3584 |
| 59 | Attention_10 | Grouped Query Attn | 1 × 8192 × 3584 |
| 60 | Add_10_attn | Add | 1 × 8192 × 3584 |
| 61 | RMSNorm_10_2 | RMSNorm | 1 × 8192 × 3584 |
| 62 | FFN_10 | SwiGLU | 1 × 8192 × 3584 |
| 63 | Add_10_ffn | Add | 1 × 8192 × 3584 |
| 64 | RMSNorm_11_1 | RMSNorm | 1 × 8192 × 3584 |
| 65 | Attention_11 | Local Attention | 1 × 8192 × 3584 |
| 66 | Add_11_attn | Add | 1 × 8192 × 3584 |
| 67 | RMSNorm_11_2 | RMSNorm | 1 × 8192 × 3584 |
| 68 | FFN_11 | SwiGLU | 1 × 8192 × 3584 |
| 69 | Add_11_ffn | Add | 1 × 8192 × 3584 |
| 70 | RMSNorm_12_1 | RMSNorm | 1 × 8192 × 3584 |
| 71 | Attention_12 | Grouped Query Attn | 1 × 8192 × 3584 |
| 72 | Add_12_attn | Add | 1 × 8192 × 3584 |
| 73 | RMSNorm_12_2 | RMSNorm | 1 × 8192 × 3584 |
| 74 | FFN_12 | SwiGLU | 1 × 8192 × 3584 |
| 75 | Add_12_ffn | Add | 1 × 8192 × 3584 |
| 76 | RMSNorm_13_1 | RMSNorm | 1 × 8192 × 3584 |
| 77 | Attention_13 | Local Attention | 1 × 8192 × 3584 |
| 78 | Add_13_attn | Add | 1 × 8192 × 3584 |
| 79 | RMSNorm_13_2 | RMSNorm | 1 × 8192 × 3584 |
| 80 | FFN_13 | SwiGLU | 1 × 8192 × 3584 |
| 81 | Add_13_ffn | Add | 1 × 8192 × 3584 |
| 82 | RMSNorm_14_1 | RMSNorm | 1 × 8192 × 3584 |
| 83 | Attention_14 | Grouped Query Attn | 1 × 8192 × 3584 |
| 84 | Add_14_attn | Add | 1 × 8192 × 3584 |
| 85 | RMSNorm_14_2 | RMSNorm | 1 × 8192 × 3584 |
| 86 | FFN_14 | SwiGLU | 1 × 8192 × 3584 |
| 87 | Add_14_ffn | Add | 1 × 8192 × 3584 |
| 88 | RMSNorm_15_1 | RMSNorm | 1 × 8192 × 3584 |
| 89 | Attention_15 | Local Attention | 1 × 8192 × 3584 |
| 90 | Add_15_attn | Add | 1 × 8192 × 3584 |
| 91 | RMSNorm_15_2 | RMSNorm | 1 × 8192 × 3584 |
| 92 | FFN_15 | SwiGLU | 1 × 8192 × 3584 |
| 93 | Add_15_ffn | Add | 1 × 8192 × 3584 |
| 94 | RMSNorm_16_1 | RMSNorm | 1 × 8192 × 3584 |
| 95 | Attention_16 | Grouped Query Attn | 1 × 8192 × 3584 |
| 96 | Add_16_attn | Add | 1 × 8192 × 3584 |
| 97 | RMSNorm_16_2 | RMSNorm | 1 × 8192 × 3584 |
| 98 | FFN_16 | SwiGLU | 1 × 8192 × 3584 |
| 99 | Add_16_ffn | Add | 1 × 8192 × 3584 |
| 100 | RMSNorm_17_1 | RMSNorm | 1 × 8192 × 3584 |
| 101 | Attention_17 | Local Attention | 1 × 8192 × 3584 |
| 102 | Add_17_attn | Add | 1 × 8192 × 3584 |
| 103 | RMSNorm_17_2 | RMSNorm | 1 × 8192 × 3584 |
| 104 | FFN_17 | SwiGLU | 1 × 8192 × 3584 |
| 105 | Add_17_ffn | Add | 1 × 8192 × 3584 |
| 106 | RMSNorm_18_1 | RMSNorm | 1 × 8192 × 3584 |
| 107 | Attention_18 | Grouped Query Attn | 1 × 8192 × 3584 |
| 108 | Add_18_attn | Add | 1 × 8192 × 3584 |
| 109 | RMSNorm_18_2 | RMSNorm | 1 × 8192 × 3584 |
| 110 | FFN_18 | SwiGLU | 1 × 8192 × 3584 |
| 111 | Add_18_ffn | Add | 1 × 8192 × 3584 |
| 112 | RMSNorm_19_1 | RMSNorm | 1 × 8192 × 3584 |
| 113 | Attention_19 | Local Attention | 1 × 8192 × 3584 |
| 114 | Add_19_attn | Add | 1 × 8192 × 3584 |
| 115 | RMSNorm_19_2 | RMSNorm | 1 × 8192 × 3584 |
| 116 | FFN_19 | SwiGLU | 1 × 8192 × 3584 |
| 117 | Add_19_ffn | Add | 1 × 8192 × 3584 |
| 118 | RMSNorm_20_1 | RMSNorm | 1 × 8192 × 3584 |
| 119 | Attention_20 | Grouped Query Attn | 1 × 8192 × 3584 |
| 120 | Add_20_attn | Add | 1 × 8192 × 3584 |
| 121 | RMSNorm_20_2 | RMSNorm | 1 × 8192 × 3584 |
| 122 | FFN_20 | SwiGLU | 1 × 8192 × 3584 |
| 123 | Add_20_ffn | Add | 1 × 8192 × 3584 |
| 124 | RMSNorm_21_1 | RMSNorm | 1 × 8192 × 3584 |
| 125 | Attention_21 | Local Attention | 1 × 8192 × 3584 |
| 126 | Add_21_attn | Add | 1 × 8192 × 3584 |
| 127 | RMSNorm_21_2 | RMSNorm | 1 × 8192 × 3584 |
| 128 | FFN_21 | SwiGLU | 1 × 8192 × 3584 |
| 129 | Add_21_ffn | Add | 1 × 8192 × 3584 |
| 130 | RMSNorm_22_1 | RMSNorm | 1 × 8192 × 3584 |
| 131 | Attention_22 | Grouped Query Attn | 1 × 8192 × 3584 |
| 132 | Add_22_attn | Add | 1 × 8192 × 3584 |
| 133 | RMSNorm_22_2 | RMSNorm | 1 × 8192 × 3584 |
| 134 | FFN_22 | SwiGLU | 1 × 8192 × 3584 |
| 135 | Add_22_ffn | Add | 1 × 8192 × 3584 |
| 136 | RMSNorm_23_1 | RMSNorm | 1 × 8192 × 3584 |
| 137 | Attention_23 | Local Attention | 1 × 8192 × 3584 |
| 138 | Add_23_attn | Add | 1 × 8192 × 3584 |
| 139 | RMSNorm_23_2 | RMSNorm | 1 × 8192 × 3584 |
| 140 | FFN_23 | SwiGLU | 1 × 8192 × 3584 |
| 141 | Add_23_ffn | Add | 1 × 8192 × 3584 |
| 142 | RMSNorm_24_1 | RMSNorm | 1 × 8192 × 3584 |
| 143 | Attention_24 | Grouped Query Attn | 1 × 8192 × 3584 |
| 144 | Add_24_attn | Add | 1 × 8192 × 3584 |
| 145 | RMSNorm_24_2 | RMSNorm | 1 × 8192 × 3584 |
| 146 | FFN_24 | SwiGLU | 1 × 8192 × 3584 |
| 147 | Add_24_ffn | Add | 1 × 8192 × 3584 |
| 148 | RMSNorm_25_1 | RMSNorm | 1 × 8192 × 3584 |
| 149 | Attention_25 | Local Attention | 1 × 8192 × 3584 |
| 150 | Add_25_attn | Add | 1 × 8192 × 3584 |
| 151 | RMSNorm_25_2 | RMSNorm | 1 × 8192 × 3584 |
| 152 | FFN_25 | SwiGLU | 1 × 8192 × 3584 |
| 153 | Add_25_ffn | Add | 1 × 8192 × 3584 |
| 154 | RMSNorm_26_1 | RMSNorm | 1 × 8192 × 3584 |
| 155 | Attention_26 | Grouped Query Attn | 1 × 8192 × 3584 |
| 156 | Add_26_attn | Add | 1 × 8192 × 3584 |
| 157 | RMSNorm_26_2 | RMSNorm | 1 × 8192 × 3584 |
| 158 | FFN_26 | SwiGLU | 1 × 8192 × 3584 |
| 159 | Add_26_ffn | Add | 1 × 8192 × 3584 |
| 160 | RMSNorm_27_1 | RMSNorm | 1 × 8192 × 3584 |
| 161 | Attention_27 | Local Attention | 1 × 8192 × 3584 |
| 162 | Add_27_attn | Add | 1 × 8192 × 3584 |
| 163 | RMSNorm_27_2 | RMSNorm | 1 × 8192 × 3584 |
| 164 | FFN_27 | SwiGLU | 1 × 8192 × 3584 |
| 165 | Add_27_ffn | Add | 1 × 8192 × 3584 |
| 166 | RMSNorm_28_1 | RMSNorm | 1 × 8192 × 3584 |
| 167 | Attention_28 | Grouped Query Attn | 1 × 8192 × 3584 |
| 168 | Add_28_attn | Add | 1 × 8192 × 3584 |
| 169 | RMSNorm_28_2 | RMSNorm | 1 × 8192 × 3584 |
| 170 | FFN_28 | SwiGLU | 1 × 8192 × 3584 |
| 171 | Add_28_ffn | Add | 1 × 8192 × 3584 |
| 172 | RMSNorm_29_1 | RMSNorm | 1 × 8192 × 3584 |
| 173 | Attention_29 | Local Attention | 1 × 8192 × 3584 |
| 174 | Add_29_attn | Add | 1 × 8192 × 3584 |
| 175 | RMSNorm_29_2 | RMSNorm | 1 × 8192 × 3584 |
| 176 | FFN_29 | SwiGLU | 1 × 8192 × 3584 |
| 177 | Add_29_ffn | Add | 1 × 8192 × 3584 |
| 178 | RMSNorm_30_1 | RMSNorm | 1 × 8192 × 3584 |
| 179 | Attention_30 | Grouped Query Attn | 1 × 8192 × 3584 |
| 180 | Add_30_attn | Add | 1 × 8192 × 3584 |
| 181 | RMSNorm_30_2 | RMSNorm | 1 × 8192 × 3584 |
| 182 | FFN_30 | SwiGLU | 1 × 8192 × 3584 |
| 183 | Add_30_ffn | Add | 1 × 8192 × 3584 |
| 184 | RMSNorm_31_1 | RMSNorm | 1 × 8192 × 3584 |
| 185 | Attention_31 | Local Attention | 1 × 8192 × 3584 |
| 186 | Add_31_attn | Add | 1 × 8192 × 3584 |
| 187 | RMSNorm_31_2 | RMSNorm | 1 × 8192 × 3584 |
| 188 | FFN_31 | SwiGLU | 1 × 8192 × 3584 |
| 189 | Add_31_ffn | Add | 1 × 8192 × 3584 |
| 190 | RMSNorm_32_1 | RMSNorm | 1 × 8192 × 3584 |
| 191 | Attention_32 | Grouped Query Attn | 1 × 8192 × 3584 |
| 192 | Add_32_attn | Add | 1 × 8192 × 3584 |
| 193 | RMSNorm_32_2 | RMSNorm | 1 × 8192 × 3584 |
| 194 | FFN_32 | SwiGLU | 1 × 8192 × 3584 |
| 195 | Add_32_ffn | Add | 1 × 8192 × 3584 |
| 196 | RMSNorm_33_1 | RMSNorm | 1 × 8192 × 3584 |
| 197 | Attention_33 | Local Attention | 1 × 8192 × 3584 |
| 198 | Add_33_attn | Add | 1 × 8192 × 3584 |
| 199 | RMSNorm_33_2 | RMSNorm | 1 × 8192 × 3584 |
| 200 | FFN_33 | SwiGLU | 1 × 8192 × 3584 |
| 201 | Add_33_ffn | Add | 1 × 8192 × 3584 |
| 202 | RMSNorm_34_1 | RMSNorm | 1 × 8192 × 3584 |
| 203 | Attention_34 | Grouped Query Attn | 1 × 8192 × 3584 |
| 204 | Add_34_attn | Add | 1 × 8192 × 3584 |
| 205 | RMSNorm_34_2 | RMSNorm | 1 × 8192 × 3584 |
| 206 | FFN_34 | SwiGLU | 1 × 8192 × 3584 |
| 207 | Add_34_ffn | Add | 1 × 8192 × 3584 |
| 208 | RMSNorm_35_1 | RMSNorm | 1 × 8192 × 3584 |
| 209 | Attention_35 | Local Attention | 1 × 8192 × 3584 |
| 210 | Add_35_attn | Add | 1 × 8192 × 3584 |
| 211 | RMSNorm_35_2 | RMSNorm | 1 × 8192 × 3584 |
| 212 | FFN_35 | SwiGLU | 1 × 8192 × 3584 |
| 213 | Add_35_ffn | Add | 1 × 8192 × 3584 |
| 214 | RMSNorm_36_1 | RMSNorm | 1 × 8192 × 3584 |
| 215 | Attention_36 | Grouped Query Attn | 1 × 8192 × 3584 |
| 216 | Add_36_attn | Add | 1 × 8192 × 3584 |
| 217 | RMSNorm_36_2 | RMSNorm | 1 × 8192 × 3584 |
| 218 | FFN_36 | SwiGLU | 1 × 8192 × 3584 |
| 219 | Add_36_ffn | Add | 1 × 8192 × 3584 |
| 220 | RMSNorm_37_1 | RMSNorm | 1 × 8192 × 3584 |
| 221 | Attention_37 | Local Attention | 1 × 8192 × 3584 |
| 222 | Add_37_attn | Add | 1 × 8192 × 3584 |
| 223 | RMSNorm_37_2 | RMSNorm | 1 × 8192 × 3584 |
| 224 | FFN_37 | SwiGLU | 1 × 8192 × 3584 |
| 225 | Add_37_ffn | Add | 1 × 8192 × 3584 |
| 226 | RMSNorm_38_1 | RMSNorm | 1 × 8192 × 3584 |
| 227 | Attention_38 | Grouped Query Attn | 1 × 8192 × 3584 |
| 228 | Add_38_attn | Add | 1 × 8192 × 3584 |
| 229 | RMSNorm_38_2 | RMSNorm | 1 × 8192 × 3584 |
| 230 | FFN_38 | SwiGLU | 1 × 8192 × 3584 |
| 231 | Add_38_ffn | Add | 1 × 8192 × 3584 |
| 232 | RMSNorm_39_1 | RMSNorm | 1 × 8192 × 3584 |
| 233 | Attention_39 | Local Attention | 1 × 8192 × 3584 |
| 234 | Add_39_attn | Add | 1 × 8192 × 3584 |
| 235 | RMSNorm_39_2 | RMSNorm | 1 × 8192 × 3584 |
| 236 | FFN_39 | SwiGLU | 1 × 8192 × 3584 |
| 237 | Add_39_ffn | Add | 1 × 8192 × 3584 |
| 238 | RMSNorm_40_1 | RMSNorm | 1 × 8192 × 3584 |
| 239 | Attention_40 | Grouped Query Attn | 1 × 8192 × 3584 |
| 240 | Add_40_attn | Add | 1 × 8192 × 3584 |
| 241 | RMSNorm_40_2 | RMSNorm | 1 × 8192 × 3584 |
| 242 | FFN_40 | SwiGLU | 1 × 8192 × 3584 |
| 243 | Add_40_ffn | Add | 1 × 8192 × 3584 |
| 244 | RMSNorm_41_1 | RMSNorm | 1 × 8192 × 3584 |
| 245 | Attention_41 | Local Attention | 1 × 8192 × 3584 |
| 246 | Add_41_attn | Add | 1 × 8192 × 3584 |
| 247 | RMSNorm_41_2 | RMSNorm | 1 × 8192 × 3584 |
| 248 | FFN_41 | SwiGLU | 1 × 8192 × 3584 |
| 249 | Add_41_ffn | Add | 1 × 8192 × 3584 |
| 250 | RMSNorm_42_1 | RMSNorm | 1 × 8192 × 3584 |
| 251 | Attention_42 | Grouped Query Attn | 1 × 8192 × 3584 |
| 252 | Add_42_attn | Add | 1 × 8192 × 3584 |
| 253 | RMSNorm_42_2 | RMSNorm | 1 × 8192 × 3584 |
| 254 | FFN_42 | SwiGLU | 1 × 8192 × 3584 |
| 255 | Add_42_ffn | Add | 1 × 8192 × 3584 |
| 256 | Output | Output | 1 × 8192 × 3584 |
What the verifier says
deep-attention-default-init
What changed upstream
The change tracker follows google/gemma-2-9b-it: 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 google/gemma-2-9b-it --plan --share