neurarch 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,6 +15,10 @@ npx neurarch oom error.txt --model Qwen/Qwen3-8B --batch 8 # why it ran out of
15
15
  npx neurarch layout Qwen/Qwen3-8B --tp 4 --pp 4 --dp 8 --global-batch 512 --seq-len 4096 # is this parallel split legal and balanced
16
16
  npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 --gpus 4 -- vllm serve Qwen/Qwen3-8B -tp 4 --max-model-len 32768 # will this serving launch start
17
17
  npx neurarch Qwen/Qwen3-8B --inference --batch 4 --seq-len 4096 --gen 512 # weights + KV cache for a generation job
18
+ npx neurarch policy show # the repo's .neurarch.yml: severities, budget lines, waivers with owner and expiry
19
+ npx neurarch weights-diff ./base ./edited # which tensors differ, and the shape of each edit
20
+ npx neurarch pin-check . # Hugging Face downloads not pinned to a commit (Bandit B615), --sarif for code scanning
21
+ npx neurarch template-check zai-org/GLM-5.1 --engine vllm # does vLLM send the prompt the reference sends; --from <sha> for an upstream change
18
22
  npx neurarch bert-base-uncased --seq-len 1024 --tokenizer-size 30524 # does the data fit what the config accepts
19
23
  ```
20
24
 
@@ -180,7 +184,7 @@ npx neurarch rightsize jobs.csv --out report.md
180
184
  ```
181
185
 
182
186
  ```
183
- 6 jobs, 174 GPU-hours, $507.85 spent; a right-sized request would have saved $404.64 (80% of spend), claiming nothing on 1 row marked under or unknown.
187
+ 6 jobs, 174 GPU-hours, $507.85 spent; $328.53 of that was reserved capacity no job needed, claiming nothing on 1 row marked under or unknown.
184
188
  ```
185
189
 
186
190
  For each job in the CSV: what it requested (card x count), what it needed
@@ -284,14 +288,16 @@ job starts.
284
288
  block count; global batch = micro x grad-accum x dp; EP against the experts
285
289
  and dp x cp; CP against the sequence length; TP past one node.
286
290
  2. **Stage balance**: a predicted forward + backward time per microbatch for
287
- every stage, the sum of its layers: matmul FLOPs at 40% of the card's peak
288
- plus the bytes the memory-bound ops move (norms, elementwise, RoPE, the
289
- fp32 cross-entropy) at 80% of its bandwidth. Embedding on the first stage,
290
- LM head and loss on the last. The step is m x the slowest stage plus the
291
- fill and drain, (sum - slowest) / v, at your microbatch count, so it prints
292
- the predicted slowdown against a perfect split at that count, the
293
- asymptotic one next to it, and an optimal contiguous `--layers` split with
294
- the step speedup it predicts.
291
+ every stage, the sum of its layers: each matmul at up to 40% of the card's
292
+ peak, less when it is short (a per-card curve fitted to NeuSight's measured
293
+ kernels on H100, L4, A100, V100 and T4; flat 40% on other cards), plus the
294
+ bytes the memory-bound ops move (norms, elementwise, RoPE, the fp32
295
+ cross-entropy) at 80% of its bandwidth. Embedding on the first stage, LM
296
+ head and loss on the last. The step is the 1F1B or interleaved schedule
297
+ simulated op by op at your microbatch count (a port of Primus's schedule
298
+ simulator), so it prints the predicted slowdown against a perfect split at
299
+ that count, the asymptotic one next to it, and the contiguous `--layers`
300
+ split with the shortest simulated step.
295
301
  3. **Pipeline bubble**: (p-1)/v over (m + (p-1)/v), and the microbatch count
296
302
  that brings it under 15%.
297
303
  4. **Per-stage memory**: weights, gradients and Adam state for that stage's
@@ -313,27 +319,27 @@ Parallel layout check: Qwen/Qwen3-8B
313
319
  128 GPUs (h100-sxm, 80 GB), 36 blocks, schedule 1f1b, ZeRO 0, 64 microbatches/step, global batch 512
314
320
 
315
321
  stage blocks extra params FLOPs/tok ms/mb* mem-bound vs mean act/mb in-flight peak/GPU upper fits
316
- 0 1-9 (9) embedding 2.36B 11.33 GFLOP 35 16% 0.92x 1.4 GB 4 16.8 GB 24.1 GB fits
317
- 1 10-18 (9) - 1.74B 11.33 GFLOP 35 15% 0.92x 1.4 GB 3 12.4 GB 17.8 GB fits
318
- 2 19-27 (9) - 1.74B 11.33 GFLOP 35 15% 0.92x 1.4 GB 2 11.1 GB 15.8 GB fits
319
- 3 28-36 (9) head+loss 2.36B 15.06 GFLOP 47 17% 1.24x 1.6 GB 1 14.8 GB 21.2 GB fits
320
- * predicted fwd+bwd ms per microbatch per GPU: matmuls at 40% of peak FLOPs plus memory-bound bytes (the mem-bound share) at 80% of memory bandwidth. Not measured.
322
+ 0 1-9 (9) embedding 2.36B 11.33 GFLOP 50 11% 0.94x 1.4 GB 4 16.8 GB 24.1 GB fits
323
+ 1 10-18 (9) - 1.74B 11.33 GFLOP 50 10% 0.94x 1.4 GB 3 12.4 GB 17.8 GB fits
324
+ 2 19-27 (9) - 1.74B 11.33 GFLOP 50 10% 0.94x 1.4 GB 2 11.1 GB 15.8 GB fits
325
+ 3 28-36 (9) head+loss 2.36B 15.06 GFLOP 63 12% 1.18x 1.6 GB 1 14.8 GB 21.2 GB fits
326
+ * predicted fwd+bwd ms per microbatch per GPU: matmuls at up to 40% of peak FLOPs (less for short GEMMs, from a measured curve for this card) plus memory-bound bytes (the mem-bound share) at 80% of memory bandwidth. Not measured.
321
327
  Stage 3's peak includes 1.2 GB of fp32 logits and their gradient for the loss (--fused-ce if the loss is fused or chunked).
322
328
 
323
- Balance: slowest stage 3 at 1.24x the mean stage's predicted time.
324
- Predicted step at 64 microbatches (t = m x max + (sum - max)): 3094 ms vs 2522 ms balanced, 22.7% slower than a perfect split (24.1% as microbatches grow).
325
- Rebalanced split 10,10,10,6: 1.02x, predicted 20.0% faster per step at 64 microbatches (2579 ms); 21.2% as microbatches grow.
329
+ Balance: slowest stage 3 at 1.18x the mean stage's predicted time.
330
+ Predicted step at 64 microbatches (1F1B schedule simulated op by op, a port of Primus's simulator): 4171 ms vs 3580 ms balanced, 16.5% slower than a perfect split (17.5% as microbatches grow).
331
+ Rebalanced split 9,10,10,7: 1.05x, predicted 11.9% faster per step at 64 microbatches (3728 ms); 12.5% as microbatches grow.
326
332
  Bubble: 4.5% at 64 microbatches/step.
327
333
 
328
- warn Stage 3 has 24.1% more predicted time than the mean stage (it also carries the LM head and the loss)
329
- Per-stage predicted ms per microbatch: 34.7 | 34.6 | 34.6 | 46.7. Every microbatch waits on the slowest stage, so at 64 microbatches per step the predicted step is 22.7% longer than a perfectly balanced split (t = m x max + (sum - max), m = 64 (1F1B)). Predicted from the graph, not measured.
330
- fix: layersPerStage 10,10,10,6: predicted 20.0% faster steps at 64 microbatches (21.2% as microbatches grow).
334
+ warn Stage 3 has 17.5% more predicted time than the mean stage (it also carries the LM head and the loss)
335
+ Per-stage predicted ms per microbatch: 50.4 | 50.3 | 50.3 | 62.8. Every microbatch waits on the slowest stage, so at 64 microbatches per step the predicted step is 16.5% longer than a perfectly balanced split (1F1B schedule simulated op by op, a port of Primus's simulator, m = 64, forward a third of each stage). Predicted from the graph, not measured.
336
+ fix: layersPerStage 9,10,10,7: predicted 11.9% faster steps at 64 microbatches (12.5% as microbatches grow).
331
337
 
332
338
  checked: tp-heads, tp-kv-heads, tp-hidden, tp-ffn, tp-node, cp-seq, batch-arithmetic, pp-over-blocks, stage-balance, pipeline-bubble, stage-memory
333
339
  skipped world-size: numGpus not given; the product tp x pp x dp x cp is taken as the world size.
334
340
  skipped dp-seq-imbalance: no sequence-length histogram given (seqLenHistogram / --seq-hist); padded or packed fixed-length batches are assumed.
335
341
 
336
- Derived from the graph, not measured. A stage's time is the sum of its layers: matmul FLOPs at 40% of the card's peak, plus memory-bound bytes (norms, elementwise ops, RoPE, the fp32 loss) at 80% of its memory bandwidth. Step time uses the pipeline formula m x slowest + (sum - slowest) / v at this layout's microbatch count. On 2 and 4 L4 GPUs the predicted speedup of a split landed within 5.1 points of measured; on H100 this overprices the LM head. Memory uses the same per-layer terms and calibrated upper bound as the training-peak estimate, plus the fp32 logits on the stage with the loss. Nothing here was timed on a GPU.
342
+ Derived from the graph, not measured. A stage's time is the sum of its layers: each matmul at 40% of the card's peak when long and less when short (a per-card curve fitted to NeuSight's measured kernels on H100, L4, A100, V100 and T4; flat 40% on other cards), plus memory-bound bytes (norms, elementwise ops, RoPE, the fp32 loss) at 80% of its memory bandwidth. Step time comes from simulating the 1F1B or interleaved schedule at this layout's microbatch count. Predicted speedups of a split landed within 5.4 points of measured on 2 and 4 L4 and within 2.3 on 2 H100; absolute step time runs over, by up to 7% on L4 and 27% on H100. Memory uses the same per-layer terms and calibrated upper bound as the training-peak estimate, plus the fp32 logits on the stage with the loss. Nothing here was timed on a GPU.
337
343
  ```
338
344
 
339
345
  A Llama-3.1-8B layout (128,256-token vocabulary, the ungated
@@ -347,40 +353,41 @@ Parallel layout check: NousResearch/Meta-Llama-3.1-8B
347
353
  128 GPUs (h100-sxm, 80 GB), 32 blocks, schedule 1f1b, ZeRO 0, 8 microbatches/step, global batch 64
348
354
 
349
355
  stage blocks extra params FLOPs/tok ms/mb* mem-bound vs mean act/mb in-flight peak/GPU upper fits
350
- 0 1-8 (8) embedding 2.27B 11.28 GFLOP 34 15% 0.93x 1.4 GB 4 16.3 GB 23.4 GB fits
351
- 1 9-16 (8) - 1.74B 11.28 GFLOP 34 14% 0.93x 1.3 GB 3 12.4 GB 17.8 GB fits
352
- 2 17-24 (8) - 1.74B 11.28 GFLOP 34 14% 0.93x 1.3 GB 2 11.1 GB 15.8 GB fits
353
- 3 25-32 (8) head+loss 2.27B 14.43 GFLOP 44 16% 1.21x 1.6 GB 1 14.1 GB 20.1 GB fits
354
- * predicted fwd+bwd ms per microbatch per GPU: matmuls at 40% of peak FLOPs plus memory-bound bytes (the mem-bound share) at 80% of memory bandwidth. Not measured.
356
+ 0 1-8 (8) embedding 2.27B 11.28 GFLOP 48 10% 0.95x 1.4 GB 4 16.3 GB 23.4 GB fits
357
+ 1 9-16 (8) - 1.74B 11.28 GFLOP 48 10% 0.95x 1.3 GB 3 12.4 GB 17.8 GB fits
358
+ 2 17-24 (8) - 1.74B 11.28 GFLOP 48 10% 0.95x 1.3 GB 2 11.1 GB 15.8 GB fits
359
+ 3 25-32 (8) head+loss 2.27B 14.43 GFLOP 58 12% 1.16x 1.6 GB 1 14.1 GB 20.1 GB fits
360
+ * predicted fwd+bwd ms per microbatch per GPU: matmuls at up to 40% of peak FLOPs (less for short GEMMs, from a measured curve for this card) plus memory-bound bytes (the mem-bound share) at 80% of memory bandwidth. Not measured.
355
361
  Stage 3's peak includes 1.1 GB of fp32 logits and their gradient for the loss (--fused-ce if the loss is fused or chunked).
356
362
 
357
- Balance: slowest stage 3 at 1.21x the mean stage's predicted time.
358
- Predicted step at 8 microbatches (t = m x max + (sum - max)): 457 ms vs 403 ms balanced, 13.3% slower than a perfect split (21.0% as microbatches grow).
359
- Rebalanced split 8,9,9,6: 1.05x, predicted 10.2% faster per step at 8 microbatches (415 ms); 15.7% as microbatches grow.
363
+ Balance: slowest stage 3 at 1.16x the mean stage's predicted time.
364
+ Predicted step at 8 microbatches (1F1B schedule simulated op by op, a port of Primus's simulator): 611 ms vs 555 ms balanced, 10.0% slower than a perfect split (15.7% as microbatches grow).
365
+ Rebalanced split 9,9,8,6: 1.07x, predicted 8.0% faster per step at 8 microbatches (565 ms); 8.4% as microbatches grow.
360
366
  Bubble: 27.3% at 8 microbatches/step (17+ for under 15.0%).
361
367
  DP sequence imbalance: slowest rank 1.529x the mean; packed 1.016x (monte-carlo).
362
368
 
363
- warn Stage 3 has 21.0% more predicted time than the mean stage (it also carries the LM head and the loss)
364
- Per-stage predicted ms per microbatch: 34.1 | 34.0 | 34.0 | 44.3. Every microbatch waits on the slowest stage, so at 8 microbatches per step the predicted step is 13.3% longer than a perfectly balanced split (t = m x max + (sum - max), m = 8 (1F1B)). Predicted from the graph, not measured.
365
- fix: layersPerStage 8,9,9,6: predicted 10.2% faster steps at 8 microbatches (15.7% as microbatches grow).
366
369
  warn Pipeline bubble is 27.3% of each step
367
370
  1F1B with PP 4 and 8 microbatches per step: (p-1) / (m + (p-1)). Every GPU idles this share of the step.
368
371
  fix: Use at least 17 microbatches per step (raise grad-accum, lower micro-batch, or lower DP) to bring it under 15.0%; the interleaved schedule also divides it by its virtual stages.
369
372
  warn Uneven sequence lengths make the slowest of 8 DP ranks ~52.9% slower than the mean
370
373
  Each rank draws 8 sequences per step from your histogram; work per sequence is modelled as a*len + b*len^2 from this graph's FLOPs (attention is the len^2 term). Every rank waits for the slowest at the gradient all-reduce. Monte Carlo, fixed seed; derived, not measured.
371
374
  fix: Pack sequences to a fixed token budget per rank (with per-document attention masking), predicted 1.6%; or bucket by length so ranks in a step draw similar lengths.
375
+ info Stage 3 has 15.7% more predicted time than the mean stage (it also carries the LM head and the loss)
376
+ Per-stage predicted ms per microbatch: 47.9 | 47.8 | 47.8 | 58.4. Every microbatch waits on the slowest stage, so at 8 microbatches per step the predicted step is 10.0% longer than a perfectly balanced split (1F1B schedule simulated op by op, a port of Primus's simulator, m = 8, forward a third of each stage). Predicted from the graph, not measured.
377
+ fix: layersPerStage 9,9,8,6: predicted 8.0% faster steps at 8 microbatches (8.4% as microbatches grow).
372
378
 
373
379
  checked: tp-heads, tp-kv-heads, tp-hidden, tp-ffn, tp-node, cp-seq, batch-arithmetic, pp-over-blocks, stage-balance, pipeline-bubble, stage-memory, dp-seq-imbalance
374
380
  skipped world-size: numGpus not given; the product tp x pp x dp x cp is taken as the world size.
375
381
 
376
- Derived from the graph, not measured. A stage's time is the sum of its layers: matmul FLOPs at 40% of the card's peak, plus memory-bound bytes (norms, elementwise ops, RoPE, the fp32 loss) at 80% of its memory bandwidth. Step time uses the pipeline formula m x slowest + (sum - slowest) / v at this layout's microbatch count. On 2 and 4 L4 GPUs the predicted speedup of a split landed within 5.1 points of measured; on H100 this overprices the LM head. Memory uses the same per-layer terms and calibrated upper bound as the training-peak estimate, plus the fp32 logits on the stage with the loss. Nothing here was timed on a GPU.
382
+ Derived from the graph, not measured. A stage's time is the sum of its layers: each matmul at 40% of the card's peak when long and less when short (a per-card curve fitted to NeuSight's measured kernels on H100, L4, A100, V100 and T4; flat 40% on other cards), plus memory-bound bytes (norms, elementwise ops, RoPE, the fp32 loss) at 80% of its memory bandwidth. Step time comes from simulating the 1F1B or interleaved schedule at this layout's microbatch count. Predicted speedups of a split landed within 5.4 points of measured on 2 and 4 L4 and within 2.3 on 2 H100; absolute step time runs over, by up to 7% on L4 and 27% on H100. Memory uses the same per-layer terms and calibrated upper bound as the training-peak estimate, plus the fp32 logits on the stage with the loss. Nothing here was timed on a GPU.
377
383
  ```
378
384
 
379
385
  What it is not: a timing. Every ms and every percentage above is predicted
380
386
  from the graph and the card's datasheet numbers. It was checked against real
381
387
  runs in `scripts/layout-calibration/` of the main repo: Qwen3-0.6B trained
382
388
  with 1F1B on 2 and 4 L4s, where the predicted speedup of every split it was
383
- asked about landed within 5.1 points of measured. On that layout:
389
+ asked about landed within 5.4 points of measured, and Qwen3-4B on 2 H100s,
390
+ within 2.3. On the first layout:
384
391
 
385
392
  ```
386
393
  $ npx neurarch layout Qwen/Qwen3-0.6B --pp 4 --micro 1 --grad-accum 8 --seq-len 2048 --gpu l4
@@ -388,21 +395,21 @@ Parallel layout check: Qwen/Qwen3-0.6B
388
395
  4 GPUs (l4, 24 GB), 28 blocks, schedule 1f1b, ZeRO 0, 8 microbatches/step, global batch 8
389
396
 
390
397
  stage blocks extra params FLOPs/tok ms/mb* mem-bound vs mean act/mb in-flight peak/GPU upper fits
391
- 0 1-7 (7) embedding 266M 837.1 MFLOP 65 46% 0.75x 0.7 GB 4 7.8 GB 11.2 GB fits
392
- 1 8-14 (7) - 110M 837.1 MFLOP 64 44% 0.73x 0.7 GB 3 4.1 GB 5.9 GB fits
393
- 2 15-21 (7) - 110M 837.1 MFLOP 64 44% 0.73x 0.7 GB 2 3.5 GB 4.9 GB fits
394
- 3 22-28 (7) head+loss 266M 1.77 GFLOP 156 52% 1.79x 0.7 GB 1 9.5 GB 13.6 GB fits
395
- * predicted fwd+bwd ms per microbatch per GPU: matmuls at 40% of peak FLOPs plus memory-bound bytes (the mem-bound share) at 80% of memory bandwidth. Not measured.
398
+ 0 1-7 (7) embedding 266M 837.1 MFLOP 76 39% 0.77x 0.7 GB 4 7.8 GB 11.2 GB fits
399
+ 1 8-14 (7) - 110M 837.1 MFLOP 75 38% 0.76x 0.7 GB 3 4.1 GB 5.9 GB fits
400
+ 2 15-21 (7) - 110M 837.1 MFLOP 75 38% 0.76x 0.7 GB 2 3.5 GB 4.9 GB fits
401
+ 3 22-28 (7) head+loss 266M 1.77 GFLOP 168 48% 1.70x 0.7 GB 1 9.5 GB 13.6 GB fits
402
+ * predicted fwd+bwd ms per microbatch per GPU: matmuls at up to 40% of peak FLOPs (less for short GEMMs, from a measured curve for this card) plus memory-bound bytes (the mem-bound share) at 80% of memory bandwidth. Not measured.
396
403
  Stage 3's peak includes 2.5 GB of fp32 logits and their gradient for the loss (--fused-ce if the loss is fused or chunked).
397
404
 
398
- Balance: slowest stage 3 at 1.79x the mean stage's predicted time.
399
- Predicted step at 8 microbatches (t = m x max + (sum - max)): 1441 ms vs 959 ms balanced, 50.2% slower than a perfect split (78.9% as microbatches grow).
400
- Rebalanced split 9,9,9,1: 1.16x, predicted 36.2% faster per step at 8 microbatches (1058 ms); 54.0% as microbatches grow.
405
+ Balance: slowest stage 3 at 1.70x the mean stage's predicted time.
406
+ Predicted step at 8 microbatches (1F1B schedule simulated op by op, a port of Primus's simulator): 1566 ms vs 1082 ms balanced, 44.7% slower than a perfect split (70.3% as microbatches grow).
407
+ Rebalanced split 9,9,9,1: 1.05x, predicted 40.2% faster per step at 8 microbatches (1117 ms); 62.1% as microbatches grow.
401
408
  Bubble: 27.3% at 8 microbatches/step (17+ for under 15.0%).
402
409
 
403
- warn Stage 3 has 78.9% more predicted time than the mean stage (it also carries the LM head and the loss)
404
- Per-stage predicted ms per microbatch: 65.2 | 63.8 | 63.8 | 156.0. Every microbatch waits on the slowest stage, so at 8 microbatches per step the predicted step is 50.2% longer than a perfectly balanced split (t = m x max + (sum - max), m = 8 (1F1B)). Predicted from the graph, not measured.
405
- fix: layersPerStage 9,9,9,1: predicted 36.2% faster steps at 8 microbatches (54.0% as microbatches grow).
410
+ warn Stage 3 has 70.3% more predicted time than the mean stage (it also carries the LM head and the loss)
411
+ Per-stage predicted ms per microbatch: 76.2 | 74.8 | 74.8 | 167.5. Every microbatch waits on the slowest stage, so at 8 microbatches per step the predicted step is 44.7% longer than a perfectly balanced split (1F1B schedule simulated op by op, a port of Primus's simulator, m = 8, forward a third of each stage). Predicted from the graph, not measured.
412
+ fix: layersPerStage 9,9,9,1: predicted 40.2% faster steps at 8 microbatches (62.1% as microbatches grow).
406
413
  warn Pipeline bubble is 27.3% of each step
407
414
  1F1B with PP 4 and 8 microbatches per step: (p-1) / (m + (p-1)). Every GPU idles this share of the step.
408
415
  fix: Use at least 17 microbatches per step (raise grad-accum, lower micro-batch, or lower DP) to bring it under 15.0%; the interleaved schedule also divides it by its virtual stages.
@@ -414,18 +421,19 @@ Parallel layout check: Qwen/Qwen3-0.6B
414
421
  skipped world-size: numGpus not given; the product tp x pp x dp x cp is taken as the world size.
415
422
  skipped dp-seq-imbalance: no sequence-length histogram given (seqLenHistogram / --seq-hist); padded or packed fixed-length batches are assumed.
416
423
 
417
- Derived from the graph, not measured. A stage's time is the sum of its layers: matmul FLOPs at 40% of the card's peak, plus memory-bound bytes (norms, elementwise ops, RoPE, the fp32 loss) at 80% of its memory bandwidth. Step time uses the pipeline formula m x slowest + (sum - slowest) / v at this layout's microbatch count. On 2 and 4 L4 GPUs the predicted speedup of a split landed within 5.1 points of measured; on H100 this overprices the LM head. Memory uses the same per-layer terms and calibrated upper bound as the training-peak estimate, plus the fp32 logits on the stage with the loss. Nothing here was timed on a GPU.
424
+ Derived from the graph, not measured. A stage's time is the sum of its layers: each matmul at 40% of the card's peak when long and less when short (a per-card curve fitted to NeuSight's measured kernels on H100, L4, A100, V100 and T4; flat 40% on other cards), plus memory-bound bytes (norms, elementwise ops, RoPE, the fp32 loss) at 80% of its memory bandwidth. Step time comes from simulating the 1F1B or interleaved schedule at this layout's microbatch count. Predicted speedups of a split landed within 5.4 points of measured on 2 and 4 L4 and within 2.3 on 2 H100; absolute step time runs over, by up to 7% on L4 and 27% on H100. Memory uses the same per-layer terms and calibrated upper bound as the training-peak estimate, plus the fp32 logits on the stage with the loss. Nothing here was timed on a GPU.
418
425
  ```
419
426
 
420
427
  Measured on 4 L4s: the even split's step took 1478 and 1451 ms (two runs;
421
- predicted 1441), and 9,9,9,1 was 35.3% and 34.4% faster (predicted 36.2%).
428
+ predicted 1566), and 9,9,9,1 was 35.3% and 34.4% faster (predicted 40.2%).
422
429
  The last rank peaked at 9.7 GB on the even split and 7.3 GB on 9,9,9,1
423
430
  (predicted 9.5 and 7.1).
424
431
 
425
- Where it is off: on an H100, where the large head matmul runs well above the
426
- 40% MFU the model assumes, it overprices the LM head (head over one block
427
- measured at 0.54x and 0.86x the predicted ratio on two models), so there the
428
- last-stage gap and the speedup of a rebalance read high. The byte counts are
432
+ Where it is off: absolute step time runs over, by 2% to 7% on L4 and 23% to
433
+ 27% on H100, where long matmuls run well above the 40% the model assumes; it
434
+ still overprices the LM head there (head over one block measured at 0.69x and
435
+ 0.97x the predicted ratio on two models), so the last-stage gap reads a
436
+ little high. The byte counts are
429
437
  for the stock PyTorch / transformers kernels; a stack with fused norms and a
430
438
  fused loss moves fewer bytes. Calibrate against one short profiled run before
431
439
  trusting a percentage on a new card.
@@ -434,16 +442,41 @@ trusting a percentage on a new card.
434
442
 
435
443
  ```
436
444
  npx neurarch serve-check <hf-id | graph.json> --gpu h100 [--gpus 4] [--engine vllm|sglang|llamacpp] \
437
- [--against <old-hf-id>] [--sampler temperature=0.7,top_p=0.8] [--json] -- <launch command>
445
+ [--vllm-version 0.19.1 | --sglang-version 0.5.22] [--against <old-hf-id>] \
446
+ [--gpu-mem <GiB>] [--gpu-mem-used <GiB>]
447
+ [--sampler temperature=0.7,top_p=0.8] [--receipt <startup plan | dir | vLLM log>] [--json] -- <launch command>
438
448
  npx neurarch serve-check <hf-id> --gpu l4 --cmd "vllm serve Qwen/Qwen3-8B -tp 4 --max-model-len 32768"
439
449
  ```
440
450
 
451
+ Cards beyond the app's table: `a40`, `gh200-96g`, `gh200-144g`, `rtx-pro-6000`,
452
+ `ascend-910b` (memory only, no CUDA checks). `--gpu-mem <GiB>` sets the card's
453
+ total as torch reports it, on top of `--gpu` or alone for any other card;
454
+ `--gpu-mem-used <GiB>` is memory other processes already hold; vLLM's
455
+ `--kv-cache-memory-bytes` is read from the launch. When the repo publishes
456
+ `model.safetensors.index.json`, the weights read from config.json are compared
457
+ with its `total_size`, and past 10% apart the published size is used and the
458
+ report says so. Multimodal configs are checked on the language model's own
459
+ heads, widths and length, not the vision or audio tower's.
460
+
461
+ `--receipt` prints what vLLM measured next to the prediction. It reads a vLLM
462
+ startup plan (`VLLM_ENABLE_STARTUP_PLAN=1`, vLLM 0.26.0 and later, written to
463
+ `$VLLM_CACHE_ROOT/startup_plan/startup_plan_<fingerprint>.json`; give the file
464
+ or the directory and every rank is read) or a startup log ("Available KV cache
465
+ memory", "GPU KV cache size", "Estimated CUDA graph memory", ...). vLLM's own
466
+ stale-plan rules hold: a plan with another schema, a fingerprint that does not
467
+ match its file name, a non-positive size, or a free-memory baseline above this
468
+ card's memory is named and never quoted as a measurement. The fingerprint is a
469
+ hash of vLLM's internal config and cannot be recomputed outside vLLM, so the
470
+ receipt says it assumes the plan belongs to the launch you gave.
471
+
441
472
  The launch command is the one you would run (`vllm serve ...`,
442
473
  `python -m sglang.launch_server ...`, `llama-server -m x.gguf ...`). It reads
443
474
  that, the model's `config.json`, `tokenizer_config.json`, `chat_template.jinja`
444
475
  and `generation_config.json` from the Hub, and the card. For llama.cpp give the
445
476
  repo the GGUF was converted from, since a `.gguf` carries no `config.json`; the
446
- quant type is read from the file name (`Q4_K_M`, `Q8_0`, ...).
477
+ GGUF itself (`-m` a local file, or `-hf repo:QUANT` on the Hub, every shard of a
478
+ split file) is read by its header only, a few MB over HTTP range requests, so the
479
+ weights are the tensor table's real bytes, not a guess from the file name.
447
480
 
448
481
  Why: across 66,584 public issues in 17 training, fine-tuning and serving repos
449
482
  (2024 to 2026), the serving trackers grew 1.58x per month, and inside them the
@@ -469,14 +502,38 @@ What it checks (exit 1 on any `block`):
469
502
  `rope_scaling` the way vLLM scales it. vLLM and SGLang refuse to start past
470
503
  it, so that is a block; llama.cpp runs with a warning, so that is a warn; a
471
504
  learned position table is a block everywhere.
472
- 3. **Memory**: weights at the dtype or quant method per GPU after TP / PP (and
473
- EP for experts), KV per token at the cache dtype (`--kv-cache-dtype`,
474
- `-ctk` / `-ctv`), against card x `--gpu-memory-utilization` (default 0.9),
475
- x `--mem-fraction-static` (0.88 assumed when unset), or the whole card for
476
- llama.cpp, which allocates `-c` up front. Prints how many full-length
477
- sequences fit and compares that with `--max-num-seqs` /
478
- `--max-running-requests`.
479
- 4. **Quant and dtype vs the card**: from the table below.
505
+ 3. **Memory**, with each engine's own arithmetic, ported from its source and
506
+ cited by file and commit:
507
+ - **vLLM**: the KV cache spec per attention type (full, sliding window,
508
+ chunked local, MLA, Mamba / Gated DeltaNet / KDA state, cross attention),
509
+ KV heads replicated once TP passes them, the hybrid grouping and block
510
+ size (a Mamba state sets the attention block size), and the reserve taken
511
+ from total x `--gpu-memory-utilization` before the cache: weights,
512
+ activation peak, non-torch memory and, from 0.20.0, CUDA graphs. The last
513
+ three are measured by vLLM at startup and are estimates here, marked as
514
+ such. It predicts the two lines vLLM prints, "GPU KV cache size: N tokens"
515
+ and "Maximum concurrency for L tokens per request: Xx", and blocks where
516
+ vLLM refuses to start.
517
+ - **Version gates**: `gpu_memory_utilization` 0.9 before 0.20.0 and 0.92
518
+ from it, CUDA graph memory counted from 0.20.0 (both in the 0.20.0 tag,
519
+ though the log line says 0.21), sliding layers holding two batches in
520
+ flight from 0.26.0, the token line printed from concurrency from 0.21.0.
521
+ Without `--vllm-version` the newest release the tables were read from is
522
+ assumed, and the report lists every default it filled in.
523
+ - **SGLang**: its own `mem_fraction_static` formula (512 MB + 1.5 x chunked
524
+ prefill + parallel slack + CUDA graph reserve, 10 GiB floor above 60 GiB)
525
+ and tier defaults, a warn when `--mem-fraction-static` leaves less than
526
+ that, and the KV tokens it would allocate.
527
+ - **llama.cpp**: `-c` allocated up front, sliding-window layers sized the
528
+ way `llama-kv-cache-iswa.cpp` sizes them, weights from the GGUF header.
529
+ 4. **Quant and dtype vs the card**: each engine release's own
530
+ `get_min_capability()` per method and compressed-tensors scheme, generated
531
+ from vLLM (0.11.0, 0.19.1, 0.32.0) and SGLang (0.5.22) source by
532
+ `scripts/gen-serve-engine-tables.mjs`, with the line it came from; methods
533
+ vLLM moved to plugins (GGUF in 0.24.0, bitsandbytes in 0.28.0) name the
534
+ plugin. The **vLLM recipe** for the model, when one of the 215 exists: a
535
+ tool-call or reasoning parser that differs, a missing `--trust-remote-code`,
536
+ a release below `min_vllm_version`, a card marked unsupported.
480
537
  5. **Template and sampling**: a missing or overridden chat template; tool
481
538
  choice without a parser (vLLM refuses to start); a thinking template with
482
539
  no reasoning parser; sampler defaults the engine will apply against
@@ -495,24 +552,37 @@ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 --gpus 4 -- vllm serve Qwen/Qw
495
552
  Qwen/Qwen3-8B on vLLM
496
553
  TP 4 x PP 1 x DP 1, 4 x l4 (sm89), dtype bf16, weights unquantized, KV cache auto
497
554
  served length 65536 (--max-model-len 65536); the model's derived maximum 40960
498
-
499
- memory per GPU budget 21.6 GB, weights 4.10 GB, KV room 17.50 GB
500
- 36,864 KV bytes per token; one full-length sequence 2.42 GB
501
- at most 7 concurrent full-length sequences (474,841 tokens)
555
+ engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
556
+ default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
557
+ default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
558
+ default assumed: max_num_batched_tokens 2048 (vllm serve default on L4 (24 GB))
559
+
560
+ memory per GPU, predicted: 22.04 GiB x 0.92 = 20.28 GiB
561
+ - weights 3.81 GiB
562
+ - activation peak 0.58 GiB (estimate; vLLM measures this)
563
+ - non-torch (NCCL, CUDA) 0.27 GiB (estimate; vLLM measures this)
564
+ - CUDA graphs 1.04 GiB (estimate; vLLM measures this)
565
+ = KV cache 14.57 GiB: 26,529 blocks of 16 tokens (36 full)
566
+ 36,864 KV bytes per token over the full-length layers; one full-length request 2.25 GiB
567
+ vLLM would print: GPU KV cache size: 424,464 tokens; Maximum concurrency for 65,536 tokens per request: 6.47x
502
568
  weights: 2 bytes per parameter (16-bit)
569
+ card total: derived: nvidia-smi 23034 MiB less the 468 MiB gap measured on H100
503
570
 
504
571
  block Served length 65536 is past the model's 40960-token context
505
572
  The engine refuses to start ("User-specified max_model_len (65536) is greater than the derived max_model_len (40960)") unless VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 is set, and with it set, positions past the trained length are extrapolated.
506
573
  fix: Serve at most 40960, or add rope scaling where the model card supports it, with the card's own original length (e.g. --hf-overrides '{"rope_scaling":{"rope_type":"yarn","factor":F,"original_max_position_embeddings":N}}', with N x F >= 65536; N is the native length the card states, which can be below max_position_embeddings).
507
- warn --max-num-seqs 256, but at most 7 sequences fit at the full 65536 tokens
508
- KV capacity is at most 474,841 tokens per replica (each GPU holds its share of every token; 17.5 GB at 36,864 bytes per token, 16-bit). Shorter requests pack more, but once long ones arrive the engine preempts or queues past ~7; the batch size the flag promises is not there.
509
- fix: Set the flag to what fits (7), shorten the max length, use an fp8 KV cache, or add GPUs as DP replicas.
574
+ warn --max-num-seqs 256, but at most 6 requests fit at the full 65536 tokens
575
+ vLLM's pool would hold 26,529 blocks of 16 tokens; a full-length request takes 4,096. Shorter requests pack more, but once long ones arrive the scheduler preempts or queues past ~6.
576
+ fix: Set the flag to what fits (6), shorten the max length, use an fp8 KV cache, or add GPUs as DP replicas.
510
577
  info The template has a thinking block and no --reasoning-parser is set
511
578
  The reasoning text comes back inside message.content instead of reasoning_content, which breaks clients that hide or strip it.
512
- fix: Add --reasoning-parser qwen3.
513
- [...]
579
+ fix: Add --reasoning-parser qwen3 (the vLLM recipe for Qwen/Qwen3-8B).
580
+ source: github.com/vllm-project/recipes/blob/2338e9edec/models/Qwen/Qwen3-8B.yaml
581
+ info pad_token_id 151643 is also an EOS id
582
+ Serving engines do not pad, so generation is unaffected; a fine-tune on this tokenizer that masks pad tokens out of the loss also masks every EOS, and the tuned model stops learning to stop.
583
+ fix: For fine-tuning, set a distinct pad token.
514
584
 
515
- checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, context, quant-support, memory, memory-fit, chat-template, sampler
585
+ checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, context, quant-support, memory, memory-fit, chat-template, recipe, sampler
516
586
  ```
517
587
 
518
588
  The FP8 build of Qwen3-30B-A3B at TP 4: the experts are 768 wide, a quarter is
@@ -523,21 +593,41 @@ $ npx neurarch serve-check Qwen/Qwen3-30B-A3B-FP8 --gpu h100 --gpus 4 -- vllm se
523
593
  Qwen/Qwen3-30B-A3B-FP8 on vLLM
524
594
  TP 4 x PP 1 x DP 1, 4 x h100-sxm (sm90), dtype bf16, weights fp8, KV cache auto
525
595
  served length 32768 (--max-model-len 32768); the model's derived maximum 40960
526
-
527
- memory per GPU budget 72.0 GB, weights 7.79 GB, KV room 64.21 GB
528
- 24,576 KV bytes per token; one full-length sequence 0.81 GB
529
- at most 79 concurrent full-length sequences (2,612,765 tokens)
596
+ engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
597
+ default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
598
+ default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
599
+ default assumed: max_num_batched_tokens 8192 (vllm serve default on H100 SXM (80 GB))
600
+ default assumed: max_num_seqs 1024 (vllm serve default on H100 SXM (80 GB))
601
+
602
+ memory per GPU, predicted: 79.19 GiB x 0.92 = 72.85 GiB
603
+ - weights 7.25 GiB
604
+ - activation peak 2.32 GiB (estimate; vLLM measures this)
605
+ - non-torch (NCCL, CUDA) 2.10 GiB (estimate; vLLM measures this)
606
+ - CUDA graphs 1.04 GiB (estimate; vLLM measures this)
607
+ = KV cache 60.14 GiB: 164,229 blocks of 16 tokens (48 full)
608
+ 24,576 KV bytes per token over the full-length layers; one full-length request 0.75 GiB
609
+ vLLM would print: GPU KV cache size: 2,627,664 tokens; Maximum concurrency for 32,768 tokens per request: 80.18x
530
610
  weights: fp8 weights (1 byte) with the embedding and LM head kept 16-bit
611
+ card total: vLLM log, llm-d-planner accuracy report (H100-80GB "physical 79.19 GiB")
531
612
 
532
613
  block TP 4 leaves 192 columns of the expert FFN width per rank, not a multiple of the checkpoint's 128-wide quant block
533
614
  The checkpoint is block-quantized (weight_block_size [128, ...]); each rank's slice must hold whole blocks, and vLLM refuses at load ("... is not divisible by weight quantization block_n = 128").
534
615
  fix: Use a TP size where 768 / TP is a multiple of 128 (1, 2), or enable expert parallelism so experts stay whole.
616
+ source: Qwen deployment docs, vLLM FP8 troubleshooting: the same block_n = 128 error, fixed by lower TP or expert parallelism (qwen.readthedocs.io/en/latest/deployment/vllm.html)
535
617
  info MoE with 128 experts at TP 4 without expert parallelism
536
618
  Every expert is split 4 ways, so each rank multiplies 192-wide expert slices and all-reduces after every MoE layer. Expert parallelism keeps experts whole and sends tokens to them instead.
537
619
  fix: Try --enable-expert-parallel (EP = TP x DP) and compare throughput.
538
- [...]
620
+ info vLLM would log "GPU KV cache size: 2,627,664 tokens" and "Maximum concurrency for 32,768 tokens per request: 80.19x" (predicted)
621
+ Per GPU: budget 79.19 GiB x 0.92 = 72.85 GiB; weights 7.25 GiB + activation peak 2.32 GiB + non-torch (NCCL, CUDA) 2.10 GiB + CUDA graphs 1.04 GiB; KV 60.14 GiB (16-bit). Pool: 48 full layers in blocks of 16 tokens.
622
+ info The template has a thinking block and no --reasoning-parser is set
623
+ The reasoning text comes back inside message.content instead of reasoning_content, which breaks clients that hide or strip it.
624
+ fix: Add --reasoning-parser qwen3.
625
+ info pad_token_id 151643 is also an EOS id
626
+ Serving engines do not pad, so generation is unaffected; a fine-tune on this tokenizer that masks pad tokens out of the loss also masks every EOS, and the tuned model stops learning to stop.
627
+ fix: For fine-tuning, set a distinct pad token.
539
628
 
540
629
  checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, expert-parallel, context, quant-support, memory, memory-fit, chat-template, sampler
630
+ not checked: recipe: no vLLM recipe for "Qwen/Qwen3-30B-A3B-FP8" in the 215-recipe index (vllm-project/recipes@2338e9edec).
541
631
  ```
542
632
 
543
633
  The same MoE at TP 8, past its 4 KV heads:
@@ -547,11 +637,23 @@ $ npx neurarch serve-check Qwen/Qwen3-30B-A3B --gpu h100 --gpus 8 -- vllm serve
547
637
  Qwen/Qwen3-30B-A3B on vLLM
548
638
  TP 8 x PP 1 x DP 1, 8 x h100-sxm (sm90), dtype bf16, weights unquantized, KV cache auto
549
639
  served length 32768 (--max-model-len 32768); the model's derived maximum 40960
550
-
551
- memory per GPU budget 72.0 GB, weights 7.63 GB, KV room 64.37 GB
552
- 24,576 KV bytes per token; one full-length sequence 0.81 GB
553
- at most 79 concurrent full-length sequences (2,619,097 tokens)
640
+ engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
641
+ default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
642
+ default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
643
+ default assumed: max_num_batched_tokens 8192 (vllm serve default on H100 SXM (80 GB))
644
+ default assumed: max_num_seqs 1024 (vllm serve default on H100 SXM (80 GB))
645
+
646
+ memory per GPU, predicted: 79.19 GiB x 0.92 = 72.85 GiB
647
+ - weights 7.11 GiB
648
+ - activation peak 2.32 GiB (estimate; vLLM measures this)
649
+ - non-torch (NCCL, CUDA) 2.10 GiB (estimate; vLLM measures this)
650
+ - CUDA graphs 1.04 GiB (estimate; vLLM measures this)
651
+ = KV cache 60.29 GiB: 164,625 blocks of 16 tokens (48 full)
652
+ 24,576 KV bytes per token over the full-length layers; one full-length request 0.75 GiB
653
+ vLLM would print: GPU KV cache size: 2,634,000 tokens; Maximum concurrency for 32,768 tokens per request: 80.38x
554
654
  weights: 2 bytes per parameter (16-bit)
655
+ card total: vLLM log, llm-d-planner accuracy report (H100-80GB "physical 79.19 GiB")
656
+ TP 8 is past 4 KV heads: each rank holds 1 full KV head, so KV per GPU stops shrinking at TP 4 (vLLM max(1, kv_heads // tp); NVIDIA/TensorRT-LLM@8e4f13322e heuristics.py max(tp_size, num_key_value_heads))
555
657
 
556
658
  warn TP 8 is past 4 KV heads: each KV head is replicated 2x
557
659
  It starts, but every GPU stores a full KV head, so the KV cache per GPU stops shrinking at TP 4: the extra ranks hold copies, not more sequences.
@@ -559,9 +661,17 @@ $ npx neurarch serve-check Qwen/Qwen3-30B-A3B --gpu h100 --gpus 8 -- vllm serve
559
661
  info MoE with 128 experts at TP 8 without expert parallelism
560
662
  Every expert is split 8 ways, so each rank multiplies 96-wide expert slices and all-reduces after every MoE layer. Expert parallelism keeps experts whole and sends tokens to them instead.
561
663
  fix: Try --enable-expert-parallel (EP = TP x DP) and compare throughput.
562
- [...]
664
+ info vLLM would log "GPU KV cache size: 2,634,000 tokens" and "Maximum concurrency for 32,768 tokens per request: 80.38x" (predicted)
665
+ Per GPU: budget 79.19 GiB x 0.92 = 72.85 GiB; weights 7.11 GiB + activation peak 2.32 GiB + non-torch (NCCL, CUDA) 2.10 GiB + CUDA graphs 1.04 GiB; KV 60.29 GiB (16-bit, KV heads replicated past TP). Pool: 48 full layers in blocks of 16 tokens.
666
+ info The template has a thinking block and no --reasoning-parser is set
667
+ The reasoning text comes back inside message.content instead of reasoning_content, which breaks clients that hide or strip it.
668
+ fix: Add --reasoning-parser qwen3 (the vLLM recipe for Qwen/Qwen3-30B-A3B).
669
+ source: github.com/vllm-project/recipes/blob/2338e9edec/models/Qwen/Qwen3-30B-A3B.yaml
670
+ info pad_token_id 151643 is also an EOS id
671
+ Serving engines do not pad, so generation is unaffected; a fine-tune on this tokenizer that masks pad tokens out of the loss also masks every EOS, and the tuned model stops learning to stop.
672
+ fix: For fine-tuning, set a distinct pad token.
563
673
 
564
- checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, expert-parallel, context, quant-support, memory, memory-fit, chat-template, sampler
674
+ checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, expert-parallel, context, quant-support, memory, memory-fit, chat-template, recipe, sampler
565
675
  ```
566
676
 
567
677
  FP8 on an A100 (sm80): it loads, as weight-only:
@@ -571,19 +681,34 @@ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu a100-40g -- vllm serve Qwen/Qwen3
571
681
  Qwen/Qwen3-8B on vLLM
572
682
  TP 1 x PP 1 x DP 1, 1 x a100-40g (sm80), dtype bf16, weights fp8, KV cache auto
573
683
  served length 32768 (--max-model-len 32768); the model's derived maximum 40960
574
-
575
- memory per GPU budget 36.0 GB, weights 9.44 GB, KV room 26.56 GB
576
- 147,456 KV bytes per token; one full-length sequence 4.83 GB
577
- at most 5 concurrent full-length sequences (180,150 tokens)
684
+ engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
685
+ default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
686
+ default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
687
+ default assumed: max_num_batched_tokens 2048 (vllm serve default on A100 (40 GB))
688
+ default assumed: max_num_seqs 256 (vllm serve default on A100 (40 GB))
689
+
690
+ memory per GPU, predicted: 39.54 GiB x 0.92 = 36.38 GiB
691
+ - weights 8.79 GiB
692
+ - activation peak 0.58 GiB (estimate; vLLM measures this)
693
+ - non-torch (NCCL, CUDA) 0.27 GiB (estimate; vLLM measures this)
694
+ - CUDA graphs 1.04 GiB (estimate; vLLM measures this)
695
+ = KV cache 25.70 GiB: 11,696 blocks of 16 tokens (36 full)
696
+ 147,456 KV bytes per token over the full-length layers; one full-length request 4.50 GiB
697
+ vLLM would print: GPU KV cache size: 187,136 tokens; Maximum concurrency for 32,768 tokens per request: 5.71x
578
698
  weights: fp8 weights (1 byte) with the embedding and LM head kept 16-bit
699
+ card total: derived: nvidia-smi 40960 MiB less the 468 MiB gap measured on H100
579
700
 
580
701
  warn fp8 on A100 (40 GB) (sm80) is not native: it runs on a fallback kernel
581
- Native fp8 kernels need sm89+. On this card it runs as weight-only W8A16 through the FP8 Marlin kernel: weights are stored in fp8, the matmuls run in 16 bits, so the memory saving is there and the FP8 compute speedup is not.
702
+ vLLM v0.32.0 accepts it here (minimum sm75), but native fp8 kernels need sm89+. On this card it runs as weight-only W8A16 through the FP8 Marlin kernel: weights are stored in fp8, the matmuls run in 16 bits, so the memory saving is there and the FP8 compute speedup is not.
582
703
  fix: Expect the memory saving and not the speedup; for native fp8 use an sm89+ card.
583
704
  source: vLLM docs, FP8 W8A8: "FP8 computation is supported on NVIDIA GPUs with compute capability >= 8.9"; "FP8 models will run on compute capability >= 7.5 (Turing) as weight-only W8A16, utilizing FP8 Marlin" (docs.vllm.ai/en/latest/features/quantization/llm_compressor/fp8/)
584
- [...]
705
+ info vLLM would log "GPU KV cache size: 187,136 tokens" and "Maximum concurrency for 32,768 tokens per request: 5.71x" (predicted)
706
+ Per GPU: budget 39.54 GiB x 0.92 = 36.38 GiB; weights 8.79 GiB + activation peak 0.58 GiB + non-torch (NCCL, CUDA) 0.27 GiB + CUDA graphs 1.04 GiB; KV 25.70 GiB (16-bit). Pool: 36 full layers in blocks of 16 tokens.
707
+ info pad_token_id 151643 is also an EOS id
708
+ Serving engines do not pad, so generation is unaffected; a fine-tune on this tokenizer that masks pad tokens out of the loss also masks every EOS, and the tuned model stops learning to stop.
709
+ fix: For fine-tuning, set a distinct pad token.
585
710
 
586
- checked: gpu-count, tp-heads, tp-kv-heads, context, quant-support, memory, memory-fit, chat-template, sampler
711
+ checked: gpu-count, tp-heads, tp-kv-heads, context, quant-support, memory, memory-fit, chat-template, recipe, sampler
587
712
  ```
588
713
 
589
714
  gpt-oss-20b (MXFP4 experts) on an A100. Current vLLM runs it there through the
@@ -594,40 +719,53 @@ $ npx neurarch serve-check openai/gpt-oss-20b --gpu a100-80g -- vllm serve opena
594
719
  openai/gpt-oss-20b on vLLM
595
720
  TP 1 x PP 1 x DP 1, 1 x a100-80g (sm80), dtype bf16, weights mxfp4, KV cache auto
596
721
  served length 131072 (not set: the engine derives it from the config); the model's derived maximum 131072
597
-
598
- memory per GPU budget 72.0 GB, weights 13.74 GB, KV room 58.26 GB
599
- 24,600 KV bytes per token; one full-length sequence 3.22 GB
600
- at most 18 concurrent full-length sequences (2,368,099 tokens)
722
+ engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
723
+ default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
724
+ default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
725
+ default assumed: max_num_batched_tokens 2048 (vllm serve default on A100 (80 GB))
726
+
727
+ memory per GPU, predicted: 79.15 GiB x 0.92 = 72.82 GiB
728
+ - weights 12.80 GiB
729
+ - activation peak 0.19 GiB (estimate; vLLM measures this)
730
+ - non-torch (NCCL, CUDA) 0.27 GiB (estimate; vLLM measures this)
731
+ - CUDA graphs 1.04 GiB (estimate; vLLM measures this)
732
+ = KV cache 58.52 GiB: 159,786 blocks of 16 tokens (12 sliding, 12 full)
733
+ 49,152 KV bytes per token over the full-length layers; one full-length request 3.10 GiB
734
+ vLLM would print: GPU KV cache size: 2,476,465 tokens; Maximum concurrency for 131,072 tokens per request: 18.89x
601
735
  weights: MXFP4 experts at 4.25 bits (4-bit values plus a shared 8-bit scale per 32) and everything else 16-bit, as gpt-oss's modules_to_not_convert lists
736
+ card total: vLLM log "total_gpu_memory (79.15GiB)" on A100-SXM4-80GB (github.com/vllm-project/vllm/issues/18446)
737
+ 12 sliding-window layers (window 128): each holds at most the window plus the tokens in flight, not the whole sequence (vllm-project/vllm@83c9a547bf SlidingWindowSpec)
602
738
 
603
739
  warn mxfp4 on A100 (80 GB) (sm80) is not native: it runs on a fallback kernel
604
- Native mxfp4 kernels need sm90+. On this card it runs on Ampere and Ada through the Marlin MXFP4 MoE kernel (weight-only), not the Hopper / Blackwell MXFP4 path.
740
+ vLLM v0.32.0 accepts it here (minimum sm80), but native mxfp4 kernels need sm90+. On this card it runs on Ampere and Ada through the Marlin MXFP4 MoE kernel (weight-only), not the Hopper / Blackwell MXFP4 path.
605
741
  fix: Expect the memory saving and not the speedup; for native mxfp4 use an sm90+ card.
606
742
  source: vLLM gpt-oss recipe: "GPT-OSS works on Ampere devices by default, using the TRITON_ATTN attention backend and Marlin MXFP4 MoE"; the quantization table footnote: "Turing does not support Marlin MXFP4" (docs.vllm.ai/projects/recipes/en/latest/OpenAI/GPT-OSS.html)
607
- warn --max-num-seqs 64, but at most 18 sequences fit at the full 131072 tokens
608
- KV capacity is at most 2,368,099 tokens per replica (each GPU holds its share of every token; 58.3 GB at 24,600 bytes per token, 16-bit). Shorter requests pack more, but once long ones arrive the engine preempts or queues past ~18; the batch size the flag promises is not there.
743
+ warn --max-num-seqs 64, but at most 18 requests fit at the full 131072 tokens
744
+ vLLM's pool would hold 159,786 blocks of 16 tokens; a full-length request takes 8,457. Shorter requests pack more, but once long ones arrive the scheduler preempts or queues past ~18.
609
745
  fix: Set the flag to what fits (18), shorten the max length, use an fp8 KV cache, or add GPUs as DP replicas.
610
746
  info gpt-oss: the Jinja chat template in the repo was reported to diverge from the harmony training format (not vLLM)
611
747
  Same weights, same payload, same harness: 0.400 on vllm-mlx against 0.650 on Ollama on a 20-task agentic benchmark. The bundled template differs from harmony in developer-block order, tool-call header placement and tool-result wrapping. An engine that renders the Jinja template inherits that; vLLM renders gpt-oss through openai-harmony instead.
612
748
  fix: No change needed on this engine; keep it in mind if the deployment moves.
613
749
  source: github.com/waybarrios/vllm-mlx/issues/568; vLLM gpt-oss recipe (openai-harmony rendering)
614
- [...]
750
+ info pad_token_id 199999 is also an EOS id
751
+ Serving engines do not pad, so generation is unaffected; a fine-tune on this tokenizer that masks pad tokens out of the loss also masks every EOS, and the tuned model stops learning to stop.
752
+ fix: For fine-tuning, set a distinct pad token.
615
753
 
616
- checked: gpu-count, tp-heads, tp-kv-heads, expert-parallel, context, quant-support, memory, memory-fit, chat-template, known:gpt-oss-jinja-vs-harmony, sampler
754
+ checked: gpu-count, tp-heads, tp-kv-heads, expert-parallel, context, quant-support, memory, memory-fit, chat-template, recipe, known:gpt-oss-jinja-vs-harmony, sampler
617
755
  ```
618
756
 
619
757
  llama.cpp with `-c` past the model's context, and llama.cpp's own sampling
620
758
  defaults against the model's:
621
759
 
622
760
  ```
623
- $ npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 -- llama-server -m Qwen3-8B-Q4_K_M.gguf -c 65536 -ngl 99 -ctk q8_0 -ctv q8_0
761
+ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 -- llama-server -hf unsloth/Qwen3-8B-GGUF:Q4_K_M -c 65536 -ngl 99 -ctk q8_0 -ctv q8_0
624
762
  Qwen/Qwen3-8B on llama.cpp
625
763
  1 x l4 (sm89), weights Q4_K_M, KV cache q8_0/q8_0
626
764
  served length 65536 (-c 65536 (one unified KV buffer, so one sequence may use all of it)); the model's derived maximum 40960
627
765
 
628
- memory per GPU card 24.0 GB, weights 5.01 GB, KV for 65,536 tokens 5.13 GB (allocated up front), total 10.15 GB
766
+ memory per GPU, predicted: card 24.0 GB, weights 5.02 GB, KV for 65,536 tokens 5.13 GB (allocated up front), total 10.16 GB
629
767
  78,336 KV bytes per token; one full-length sequence 5.13 GB
630
- weights: Q4_K_M at 4.8944 bits per weight (llama.cpp tools/quantize/README.md, bits/weight measured on meta-llama/Llama-3.1-8B); mixed per-tensor types make this approximate
768
+ weights: 399 tensors in the GGUF header, mostly Q4_K (file type Q4_K_M), summed at ggml's block sizes (ggml-org/llama.cpp@547208dca ggml-common.h); read from huggingface.co/unsloth/Qwen3-8B-GGUF/Qwen3-8B-Q4_K_M.gguf
631
769
 
632
770
  warn Served length 65536 is past the model's 40960-token context
633
771
  llama.cpp runs past n_ctx_train with a warning; rotary positions keep computing, and quality past the trained length is not something the config vouches for.
@@ -636,9 +774,11 @@ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 -- llama-server -m Qwen3-8B-Q4
636
774
  temperature 0.8 (recommended 0.6, from llama.cpp default); top_k 40 (recommended 20, from llama.cpp default). Applies to every request that does not send its own value. Model makers have traced host-to-host quality gaps to exactly this (Moonshot: "a significant portion" of discrepancies came from decoding-parameter misuse).
637
775
  fix: Pass --temp 0.6 --top-p 0.95 --top-k 20 (llama.cpp does not read generation_config.json).
638
776
  source: kimi.com/blog/kimi-vendor-verifier
639
- [...]
777
+ info pad_token_id 151643 is also an EOS id
778
+ Serving engines do not pad, so generation is unaffected; a fine-tune on this tokenizer that masks pad tokens out of the loss also masks every EOS, and the tuned model stops learning to stop.
779
+ fix: For fine-tuning, set a distinct pad token.
640
780
 
641
- checked: context, memory, memory-fit, chat-template, sampler
781
+ checked: context, gguf-header, memory, memory-fit, chat-template, sampler
642
782
  not checked: parallel: llama.cpp splits whole layers (and their KV) across GPUs by default (--split-mode layer), so no head or width divisibility applies.
643
783
  not checked: quant-support: llama.cpp's CUDA backend runs every GGUF type on these cards; support is not a per-architecture table.
644
784
  ```
@@ -650,74 +790,411 @@ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu h100 --against Qwen/Qwen2.5-7B-In
650
790
  Qwen/Qwen3-8B on vLLM
651
791
  TP 1 x PP 1 x DP 1, 1 x h100-sxm (sm90), dtype bf16, weights unquantized, KV cache auto
652
792
  served length 32768 (--max-model-len 32768); the model's derived maximum 40960
653
-
654
- memory per GPU budget 72.0 GB, weights 16.38 GB, KV room 55.62 GB
655
- 147,456 KV bytes per token; one full-length sequence 4.83 GB
656
- at most 11 concurrent full-length sequences (377,185 tokens)
793
+ engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
794
+ default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
795
+ default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
796
+ default assumed: max_num_batched_tokens 8192 (vllm serve default on H100 SXM (80 GB))
797
+ default assumed: max_num_seqs 1024 (vllm serve default on H100 SXM (80 GB))
798
+
799
+ memory per GPU, predicted: 79.19 GiB x 0.92 = 72.85 GiB
800
+ - weights 15.26 GiB
801
+ - activation peak 2.32 GiB (estimate; vLLM measures this)
802
+ - non-torch (NCCL, CUDA) 0.27 GiB (estimate; vLLM measures this)
803
+ - CUDA graphs 1.04 GiB (estimate; vLLM measures this)
804
+ = KV cache 53.97 GiB: 24,562 blocks of 16 tokens (36 full)
805
+ 147,456 KV bytes per token over the full-length layers; one full-length request 4.50 GiB
806
+ vLLM would print: GPU KV cache size: 392,992 tokens; Maximum concurrency for 32,768 tokens per request: 11.99x
657
807
  weights: 2 bytes per parameter (16-bit)
808
+ card total: vLLM log, llm-d-planner accuracy report (H100-80GB "physical 79.19 GiB")
658
809
 
659
- [...]
810
+ info vLLM would log "GPU KV cache size: 392,992 tokens" and "Maximum concurrency for 32,768 tokens per request: 11.99x" (predicted)
811
+ Per GPU: budget 79.19 GiB x 0.92 = 72.85 GiB; weights 15.26 GiB + activation peak 2.32 GiB + non-torch (NCCL, CUDA) 0.27 GiB + CUDA graphs 1.04 GiB; KV 53.97 GiB (16-bit). Pool: 36 full layers in blocks of 16 tokens.
812
+ info pad_token_id 151643 is also an EOS id
813
+ Serving engines do not pad, so generation is unaffected; a fine-tune on this tokenizer that masks pad tokens out of the loss also masks every EOS, and the tuned model stops learning to stop.
814
+ fix: For fine-tuning, set a distinct pad token.
660
815
  info model_type: qwen2 -> qwen3
661
816
  A different architecture family: the engine loads a different model class, and every family-specific flag (tool-call parser, reasoning parser, chat template) must be re-chosen.
662
817
  info num_hidden_layers: 28 -> 36
663
818
  Layer count changes weights and KV per token; PP stage splits must be redone.
664
- [...]
819
+ info hidden_size: 3584 -> 4096
820
+ Width changes weights, the TP divisibility of every linear, and activation memory.
821
+ info num_attention_heads: 28 -> 32
822
+ Head count changes which TP sizes are legal.
665
823
  info num_key_value_heads: 4 -> 8
666
824
  KV heads change KV bytes per token and where TP starts replicating KV.
667
- [...]
825
+ info head_dim: (absent) -> 128
826
+ Head dimension changes KV bytes per token and the attention kernels that apply.
827
+ info intermediate_size: 18944 -> 12288
828
+ FFN width changes weights and which TP sizes divide it.
668
829
  info vocab_size: 152064 -> 151936
669
830
  Vocabulary changes the embedding and LM head; the tokenizer changes with it, so token budgets and stop ids measured on the old model no longer apply.
670
831
  info max_position_embeddings: 32768 -> 40960
671
832
  The longest servable length changes; --max-model-len / --context-length may now be past it or leave length unused.
672
- [...]
833
+ info sliding_window: 131072 -> null
834
+ Sliding window changes KV per token at long lengths and which attention backends apply.
673
835
  info chat_template: hash 6aca5d55 -> hash 1bae85c9
674
836
  Every chat request renders differently: re-render a reference conversation (with tool calls) and re-run the evals that depend on format.
675
837
  info generation_config.temperature: 0.7 -> 0.6
676
838
  The recommended sampling changes; a gateway that pins the old value now overrides the new model's recommendation.
677
- [...]
839
+ info generation_config.top_p: 0.8 -> 0.95
840
+ The recommended sampling changes; a gateway that pins the old value now overrides the new model's recommendation.
841
+ info generation_config.repetition_penalty: 1.05 -> (absent)
842
+ The recommended sampling changes; a gateway that pins the old value now overrides the new model's recommendation.
843
+ info weights per GPU: 15.2 GB -> 16.4 GB
844
+ Same engine flags and card, computed for both models.
678
845
  info KV bytes per token per GPU: 57,344 -> 147,456
679
846
  Same engine flags and card, computed for both models.
680
- info concurrent full-length sequences (upper bound): 30 -> 11
847
+ info concurrent full-length sequences (upper bound): 31 -> 11
848
+ Same engine flags and card, computed for both models.
849
+ info derived maximum length: 32768 -> 40960
681
850
  Same engine flags and card, computed for both models.
682
- [...]
683
-
684
- checked: gpu-count, tp-heads, tp-kv-heads, context, quant-support, memory, memory-fit, chat-template, sampler, change
685
- ```
686
-
687
- (`[...]` marks findings left out here for length; the command prints them all.
688
- Every run ends with the line: "Derived from config.json, the engine flags and
689
- the card, not measured. ...")
690
-
691
- The quant support table, and where each row comes from:
692
-
693
- | method | native from | still runs from (how) | source |
694
- | --- | --- | --- | --- |
695
- | fp8 | sm89 (Ada, Hopper, Blackwell) | sm75, weight-only W8A16 via FP8 Marlin | [vLLM FP8 W8A8](https://docs.vllm.ai/en/latest/features/quantization/llm_compressor/fp8/) |
696
- | mxfp4 (gpt-oss) | sm90 (Hopper, Blackwell) | sm80, Marlin MXFP4 MoE; not Turing | [vLLM gpt-oss recipe](https://docs.vllm.ai/projects/recipes/en/latest/OpenAI/GPT-OSS.html), [quantization table](https://docs.vllm.ai/en/latest/features/quantization/) |
697
- | nvfp4 | sm100 (Blackwell FP4 tensor cores) | sm75, weight-only via Marlin FP4 | [quantization table](https://docs.vllm.ai/en/latest/features/quantization/) |
698
- | awq | sm75 | | [quantization table](https://docs.vllm.ai/en/latest/features/quantization/) |
699
- | gptq | sm70 | | same |
700
- | awq_marlin / gptq_marlin | sm75 | | same |
701
- | int8 (W8A8) | sm75 | | same |
702
- | bitsandbytes | sm70 | | same |
703
- | gguf (in vLLM) | sm70 | | same |
704
- | bf16 dtype | sm80 | auto dtype casts to fp16 below it | vLLM's own error: "Bfloat16 is only supported on GPUs with compute capability of at least 8.0" |
705
-
706
- GGUF bits per weight come from llama.cpp's
707
- [quantize README](https://github.com/ggml-org/llama.cpp/blob/master/tools/quantize/README.md)
708
- (measured on Llama-3.1-8B), and llama.cpp's sampler defaults from its
709
- [server README](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md).
710
- SGLang shares most kernels with vLLM but publishes no such table, so its quant
711
- findings use vLLM's.
712
-
713
- What it is not: a launch. Every number is derived from files; the engine's own
714
- reserve (activation profiling, CUDA graphs, communication buffers) is not
715
- counted, so every capacity is an upper bound. Template checks read files and
716
- do not render a conversation, so "no template finding" does not prove two
717
- stacks produce the same prompt. Not covered: attention-backend and kernel
718
- numerics, fp8 KV cache support per backend, LoRA adapters, speculative
719
- decoding, prefix caching, chunked prefill and disaggregated prefill / decode,
720
- and anything about throughput or latency.
851
+
852
+ checked: gpu-count, tp-heads, tp-kv-heads, context, quant-support, memory, memory-fit, chat-template, recipe, sampler, change
853
+ ```
854
+
855
+ Every run ends with the basis paragraph, left out above: what is predicted,
856
+ what is estimated, and the accuracy below.
857
+
858
+ How close the prediction is to what vLLM logged, by llm-d-planner's method
859
+ (percent error against the engine's own "Available KV cache memory" and "GPU
860
+ KV cache size" lines), on public data only and no GPU time
861
+ (`npx vite-node --script scripts/serve-check-validation.ts`):
862
+
863
+ | set | what goes in | quantity | n | mean abs error | median abs error |
864
+ | --- | --- | --- | ---: | ---: | ---: |
865
+ | A. llm-d-planner's vLLM 0.19.0 runs, H100 | card, flags, config | KV GiB | 16 | 0.33% | 0.13% |
866
+ | A | | KV tokens | 6 | 0.12% | 0.13% |
867
+ | B. public GitHub issue logs | the KV memory vLLM logged | KV tokens | 21 | 1.07% | 0.01% |
868
+ | B | | max concurrency | 21 | 3.95% | 0.02% |
869
+ | C. the same logs, end to end | card, flags, config | KV GiB | 9 | 85.89% | 7.63% |
870
+ | C | | KV tokens | 11 | 76.20% | 8.69% |
871
+
872
+ Set A is in-sample for the one fitted constant (16 bytes per sampler logit in
873
+ the activation estimate). Set B is out of sample and isolates the ported KV
874
+ arithmetic: full attention, sliding window (gemma-2, gemma-3, gpt-oss),
875
+ chunked local (Llama 4), Mamba-2 (Nemotron-H), Gated DeltaNet (Qwen3-Next,
876
+ Qwen3.5), KDA (Kimi Linear) and Whisper's cross attention all land within
877
+ 0.6% on tokens; the misses are a gemma-3 run whose scheduler token budget the
878
+ flags do not show (concurrency +60%) and two Gated DeltaNet dev builds (+8% and
879
+ +13%). Set C is where the estimates show: the median run is within 8%, and the
880
+ mean is carried by runs whose startup the flags do not describe (a gpt-oss-120b
881
+ run whose CUDA graphs took 9.79 GiB, a Kimi Linear run at 64,000 batched
882
+ tokens, a gemma-3 run whose vision encoder is profiled too). For reference,
883
+ llm-d-planner reports 7.82% mean absolute error on KV memory and 16.65% on
884
+ concurrency for its own planner on vLLM 0.19 / H100.
885
+
886
+ The quant tables are generated, not kept by hand: `get_min_capability()` per
887
+ method and compressed-tensors scheme from vLLM 0.11.0, 0.19.1 and 0.32.0 and
888
+ SGLang 0.5.22, each with its commit (`src/utils/serveEngineTables.generated.ts`,
889
+ regenerated by `node scripts/gen-serve-engine-tables.mjs --vllm <clone>
890
+ --sglang <clone> --recipes <clone>`). Where the two engines disagree on the
891
+ same card (SGLang wants sm80 for fp8 and AWQ-Marlin, vLLM sm75) the finding
892
+ says so. Whether a method runs natively or on a fallback kernel (fp8 on sm80
893
+ runs weight-only through FP8 Marlin, MXFP4 on sm80 through Marlin, NVFP4 below
894
+ sm100 weight-only) is from vLLM's docs, which the registry does not encode.
895
+ GGUF tensor bytes use ggml's block sizes; llama.cpp's sampler defaults come
896
+ from its [server README](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md).
897
+
898
+ What it is not: a launch. vLLM measures its activation peak, non-torch memory
899
+ and CUDA graph pool at startup; here they are estimates, labelled in the
900
+ output. A card's usable total is a logged value for H100 and A100-80GB and is
901
+ derived from nvidia-smi for the rest. Template checks read files and do not
902
+ render a conversation, so "no template finding" does not prove two stacks
903
+ produce the same prompt. Not covered: TensorRT-LLM (whose
904
+ `free_gpu_memory_fraction` is a share of free memory after weights, not of the
905
+ card), SGLang's separate sliding-window and Mamba pools, sparse-attention
906
+ indexer caches (DeepSeek V3.2 / V4), multimodal encoder profiling,
907
+ attention-backend numerics, LoRA adapters, speculative decoding, disaggregated
908
+ prefill / decode, and anything about throughput or latency.
909
+
910
+ ## A policy the repo checks in: `.neurarch.yml`, waivers, baselines, SARIF
911
+
912
+ Every check above prints what it computed. A `.neurarch.yml` at the repository
913
+ root says what this repository does about it: which findings block, which are
914
+ accepted until a date by a named owner, which were already there before
915
+ anyone looked, and what budget a run may not cross. The same file is read by
916
+ the CLI, by the SkyPilot admin policy and by the SLURM helper, through one
917
+ engine (`src/utils/policy/`), so a CI check and an admission decision over the
918
+ same file cannot disagree. With no policy file, no baseline and no policy
919
+ flag, nothing here runs and the CLI behaves exactly as before.
920
+
921
+ ```yaml
922
+ # yaml-language-server: $schema=https://neurarch.com/schema/neurarch-policy-v1.json
923
+ version: 1
924
+ extends: [neurarch>recommended] # neurarch>strict | neurarch>advisory | local>path | github>org/repo//path.yml#tag
925
+ defaults:
926
+ gpu: h100 # used when the command names no --gpu
927
+ seq_len: 4096 # used when the command names no --seq-len
928
+ budget:
929
+ cards_allowed: [h100, h200] # also max_params: 70B, max_cost_per_run_usd: 2000
930
+ rules:
931
+ layout/pipeline-bubble: block # off | info | warn | block; "memory/*" and "*" re-level warnings and blocks
932
+ waivers:
933
+ - rule: layout/stage-imbalance
934
+ owner: "@li"
935
+ reason: "LM head stage measured at 1.17x on the cluster; rebalance lands with the v2 recipe"
936
+ expires: 2026-12-15
937
+ - rule: serve/context-over-derived
938
+ model: "Qwen/*" # scope: model, path and cluster globs
939
+ owner: "@ana"
940
+ reason: "YaRN x4 validated to 131k on our eval set"
941
+ ```
942
+
943
+ The schema is published at
944
+ [neurarch.com/schema/neurarch-policy-v1.json](https://neurarch.com/schema/neurarch-policy-v1.json)
945
+ (`npx neurarch policy schema` prints it); `examples/.neurarch.yml` has every
946
+ field. `npx neurarch policy show` is the effective policy after presets, with
947
+ each waiver's dates and where they came from:
948
+
949
+ ```
950
+ $ npx neurarch policy show
951
+ .neurarch.yml extends neurarch>recommended
952
+ defaults gpu=h100 seq_len=4096
953
+ budget cards_allowed=h100,h200
954
+ rule layout/pipeline-bubble: block
955
+ waiver layout/stage-imbalance owner=@li created 2026-10-14 (git-blame) in force until 2026-12-15
956
+ waiver serve/context-over-derived model=Qwen/* owner=@ana created 2026-10-18 (git-blame) in force until 2026-11-17 (defaulted: created + 30 days)
957
+ info policy/waiver-expiry-defaulted: Waiver for serve/context-over-derived has no expiry: it applies until 2026-11-17 (created + 30 days)
958
+ ```
959
+
960
+ A check run under it prints its own report unchanged, then what the policy
961
+ decided and why the exit code is what it is:
962
+
963
+ ```
964
+ $ npx neurarch layout Qwen/Qwen3-8B --tp 4 --pp 8 --dp 4 --micro 1 --global-batch 512 --source train.sh
965
+ policy default: --gpu h100 (from .neurarch.yml)
966
+ policy default: --seq-len 4096 (from .neurarch.yml)
967
+ Parallel layout check: Qwen/Qwen3-8B
968
+ ...
969
+ policy policy .neurarch.yml (extends neurarch>recommended)
970
+ warn layout/uneven-default-split: 36 layers do not divide evenly into PP 8
971
+ warn layout/stage-imbalance: Stage 7 has 46.2% more predicted time than the mean stage (it also carries the LM head and the loss) [waived by @li until 2026-12-15]
972
+ reason: LM head stage measured at 1.17x on the cluster; rebalance lands with the v2 recipe
973
+ info policy/waiver-expiry-defaulted: Waiver for serve/context-over-derived has no expiry: it applies until 2026-11-17 (created + 30 days)
974
+ nothing blocks, 1 waived: exit 0
975
+ ```
976
+
977
+ **Waivers never last forever.** Trivy and Snyk both treat a waiver with no
978
+ expiry as permanent. Here a missing or unreadable `expires` is `created + 30
979
+ days`, and an info finding says the default was taken. A missing `created` is
980
+ the git blame date of the waiver's line, else the date the first run saw it
981
+ (recorded in `.neurarch/waivers-seen.json`, so it does not move; commit it),
982
+ never "now", which would renew the waiver on every run. A waiver with no
983
+ `owner` or no `reason` does not apply, and says so. An expired waiver brings
984
+ its finding back and is a finding itself (`policy/waiver-expired`, a block
985
+ under `neurarch>strict`). A waiver is in force through its expiry day (UTC).
986
+ Findings about the policy file cannot themselves be waived.
987
+
988
+ **Inline waivers** go in the file the run was checked from (`--source`): a
989
+ launch script, an sbatch file, a recipe. Same fields, same engine, dated by git
990
+ blame of the comment's line, scoped to that file:
991
+
992
+ ```bash
993
+ # neurarch-ignore: serve/context-over-derived reason="YaRN validated to 64k" owner=@ana expires=2026-12-01
994
+ vllm serve Qwen/Qwen3-8B -tp 4 --max-model-len 65536 # neurarch-ignore: serve/rope-static,serve/kv-under-one-sequence owner=ops reason='canary only'
995
+ ```
996
+
997
+ **Baselines** judge only what is new. `npx neurarch baseline <check ...>` runs
998
+ the check and writes what it found to `.neurarch/baseline.json` (rule id plus a
999
+ fingerprint over the checker, rule, model, source file and the finding's title
1000
+ with numbers removed, so a re-estimate of a known problem is not "new"). Later
1001
+ runs report and fail on new findings only; `--all` shows the rest:
1002
+
1003
+ ```
1004
+ $ npx neurarch baseline layout Qwen/Qwen3-8B --tp 4 --pp 8 --dp 4 --micro 1 --global-batch 512 --source train.sh
1005
+ baseline 2 findings from this run written to .neurarch/baseline.json (2 in the file). Later runs fail only on new ones; --all shows every one.
1006
+
1007
+ $ npx neurarch layout Qwen/Qwen3-8B --tp 3 --pp 8 --dp 4 --micro 1 --global-batch 512 --source train.sh
1008
+ ...
1009
+ policy policy .neurarch.yml (extends neurarch>recommended), baseline .neurarch/baseline.json
1010
+ block layout/tp-heads: TP 3 does not divide 32 attention heads
1011
+ block layout/tp-kv-heads: TP 3 neither divides nor is a multiple of 8 KV heads
1012
+ block layout/tp-hidden: TP 3 does not divide hidden size 4096
1013
+ 3 blocking, 1 waived, 2 in baseline (2 not shown; --all to show): exit 1
1014
+ ```
1015
+
1016
+ **SARIF 2.1.0** for every check (`layout`, `serve-check`, the main check's data
1017
+ fit, memory plan, lint and change gate, the budget lines and the policy's own
1018
+ findings): `--sarif out.sarif`. Each rule carries full metadata; each result
1019
+ carries `partialFingerprints.primaryLocationLineHash`, computed with GitHub's
1020
+ own algorithm (ported from codeql-action, MIT), so an API upload deduplicates
1021
+ like an Action upload, plus `neurarchFinding/v1`. A waived finding stays in the
1022
+ file with a `suppressions` entry (owner, reason, expiry). GitHub shows a pull
1023
+ request alert only on a line the pull request changed, and these findings are
1024
+ about a whole launch, so results anchor to a changed line in `--source` when
1025
+ `--changed-lines` is given (a `git diff -U0` file, or `path:3-5,9`), preferring
1026
+ one that names the flag (`--tp`, `--max-model-len`, the model id), and
1027
+ otherwise to the line that names the flag or the model.
1028
+ `examples/github-precheck.yml` is a complete workflow with
1029
+ `github/codeql-action/upload-sarif`:
1030
+
1031
+ ```yaml
1032
+ - run: git diff -U0 "origin/${{ github.base_ref }}...HEAD" > changes.diff
1033
+ - run: |
1034
+ mkdir -p sarif
1035
+ npx --yes neurarch layout Qwen/Qwen3-8B --tp 4 --pp 4 --dp 8 --micro 1 --global-batch 512 \
1036
+ --source recipes/qwen3/train.sh --changed-lines changes.diff --sarif sarif/layout.sarif
1037
+ - uses: github/codeql-action/upload-sarif@v3
1038
+ if: always()
1039
+ with:
1040
+ sarif_file: sarif
1041
+ ```
1042
+
1043
+ Flags on every check: `--policy <file>` (default: the nearest `.neurarch.yml`
1044
+ up to the repo root, or `NEURARCH_POLICY`), `--no-policy`, `--sarif <file>`,
1045
+ `--source <file>`, `--changed-lines <diff | spec>`, `--cluster <name>` (or
1046
+ `NEURARCH_CLUSTER`, `SLURM_CLUSTER_NAME`), `--baseline <file>`, `--all`. A
1047
+ policy file that cannot be read stops the run with exit 2 and the reasons: a
1048
+ policy read halfway is one nobody wrote. `npx neurarch policy validate` checks
1049
+ it alone. Presets are fetched only for `github>` references (raw.githubusercontent.com,
1050
+ `GITHUB_TOKEN` when set); `neurarch>` presets are built in.
1051
+
1052
+ ## A record someone else can verify: `--attest`, `--cyclonedx`
1053
+
1054
+ ```
1055
+ npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 --gpus 4 \
1056
+ --attest precheck.intoto.json --cyclonedx precheck.cdx.json \
1057
+ -- vllm serve Qwen/Qwen3-8B -tp 4 --max-model-len 32768
1058
+ npx neurarch layout ./graph.json --tp 4 --pp 2 --dp 8 --attest r.json --model-dir ./checkpoint
1059
+ npx neurarch policy apply --json --attest r.json --model-dir ./checkpoint < findings.json
1060
+ ```
1061
+
1062
+ `--attest` (on the main check, `layout`, `serve-check` and `policy apply`)
1063
+ writes an [in-toto Statement v1](https://github.com/in-toto/attestation/blob/main/spec/v1/statement.md)
1064
+ with in-toto's own [test-result](https://github.com/in-toto/attestation/blob/main/spec/predicates/test-result.md)
1065
+ predicate: `result` (`PASSED`, `WARNED`, `FAILED`; `FAILED` whenever the run
1066
+ exits non-zero), `passedTests` / `warnedTests` / `failedTests` by rule id, and
1067
+ in `configuration` the CLI version and the sha256 of every file whose code or
1068
+ tables decided the verdict (the bundles, the repo's `.neurarch.yml`, the
1069
+ `--source` file). The verdicts, findings and the command line sit in one
1070
+ extension field, `neurarchPrecheck`, described by
1071
+ <https://neurarch.com/schema/precheck-attestation-v1.json>.
1072
+
1073
+ The subjects are the model's files, hashed and named the way OpenSSF
1074
+ [model-transparency](https://github.com/sigstore/model-transparency)
1075
+ (`model_signing`) does it, and the first subject is the root digest
1076
+ `model_signing sign` signs, so a model signature and a pre-check record point
1077
+ at the same bytes. `--model-dir` hashes a local copy; without it a Hub id is
1078
+ read at the commit `main` points to (LFS files by their recorded sha256, small
1079
+ files downloaded and hashed), and a graph file is its own subject.
1080
+
1081
+ The output is deterministic: keys sorted, no clock. A time appears only with
1082
+ `--attest-time <RFC 3339>`, a URL only with `--attest-url`, so two runs over
1083
+ the same inputs write the same bytes and a record can be diffed and signed.
1084
+ `examples/github-attest.yml` signs it with `actions/attest`, after which
1085
+ `gh attestation verify <model file> -R <owner>/<repo> --predicate-type https://in-toto.io/attestation/test-result/v0.1`
1086
+ finds it.
1087
+
1088
+ `--cyclonedx` writes a CycloneDX 1.6 BOM with one `machine-learning-model`
1089
+ component (its files as `file` components with SHA-256 hashes) carrying the
1090
+ verdicts as `neurarch:` properties: `neurarch:training:peak_gb`,
1091
+ `neurarch:training:smallest_card`, `neurarch:serve:verdict`,
1092
+ `neurarch:layout:verdict` and the rest listed in
1093
+ `src/utils/attestation/index.ts`. A fragment to merge into the BOM your SBOM
1094
+ tool already writes; valid against the official 1.6 schema on its own.
1095
+
1096
+ ## weights-diff: what differs between two local checkpoints
1097
+
1098
+ ```
1099
+ npx neurarch weights-diff <a> <b> [--json] [--max-tensors N]
1100
+ ```
1101
+
1102
+ `<a>` and `<b>` are `.safetensors` files or directories of them. It hashes every tensor and, for each
1103
+ changed 2-D tensor, reads both sides' values to say how many columns and rows moved, how large the
1104
+ change is against the tensor's norm, and how much of it one rank-1 component explains. Everything is
1105
+ read on your machine. Exit code is 0 when the weights match and 1 when they differ, so it can gate a
1106
+ promotion.
1107
+
1108
+ Each checkpoint also gets a digest that survives re-sharding. Post it as `weights_digest` to the
1109
+ self-hosted `POST /v1/outcome` and the ledger can say when one model name ran as two sets of bytes.
1110
+
1111
+ It reports which values differ. It says nothing about what the difference does to behaviour.
1112
+
1113
+ ## scan: a dependency scan for the models your code pulls
1114
+
1115
+ ```bash
1116
+ npx neurarch scan [paths...] [--json] [--no-template] [--fix] [--cyclonedx out.cdx.json]
1117
+ ```
1118
+
1119
+ Reads the same files `pin-check` reads and keeps every model download, pinned or not. For each model it reads the Hub API at your pinned commit and at `main`, the recorded change history at [neurarch.com/changes](https://www.neurarch.com/changes/), and, when the pin has moved, renders the chat template at both commits. Findings come in three lanes, and the lanes are never mixed:
1120
+
1121
+ - **security**: Python the loader runs from the repository (`auto_map` with `trust_remote_code`) that is unpinned, changed since your pin, or lives in another repository; weights available only in pickle formats.
1122
+ - **behavior**: upstream changes since your pin to the template, tokenizer, EOS or generation defaults. Not vulnerabilities: what the model receives changed.
1123
+ - **hygiene**: downloads not pinned to a commit.
1124
+
1125
+ Output on a four-line sample (2026-11-17, live Hub and the published feed, trimmed):
1126
+
1127
+ ```
1128
+ nomic-ai/nomic-embed-text-v1.5 @ 91d2d6bfdddf
1129
+ high security Its auto_map imports code from nomic-ai/nomic-bert-2048. Loaded with trust_remote_code=True,
1130
+ transformers pins that code only with code_revision=; revision= alone pins
1131
+ nomic-ai/nomic-embed-text-v1.5 and still loads the other repository's main.
1132
+ Qwen/Qwen3-8B @ e8bbd8252970
1133
+ high behavior Qwen3-8B: the chat template changed and renders differently (tool-call-parts) ... (2025-05-19).
1134
+ ```
1135
+
1136
+ The cross-repository rule is transformers' own code: `dynamic_module_utils.get_class_from_dynamic_module` fills `code_revision` from `revision` only when the code sits in the same repository ([v4.57.1, lines 595 to 602](https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/dynamic_module_utils.py#L595-L602)). On 2026-11-17, 150 of the 608 models we track ran code from their repository; 17 of the 150 tracked models that run code from their repository load it from another one.
1137
+
1138
+ Where the model id or commit lives elsewhere, it is still read: module constants (`MODEL_ID = "..."` then `from_pretrained(MODEL_ID, revision=REV)`), metadata records with a Hub id and a commit (MTEB's `ModelMeta(name=..., revision=...)`), and serving env vars in Kubernetes manifests, compose files and Dockerfiles (`MODEL_ID`, `REVISION`, as TGI and TEI read them). An env-only reference gets no remote-code finding unless the file sets `TRUST_REMOTE_CODE`, because those images run their own implementation, not the repository's Python. A `config.json` that names a Hub repository as its attention implementation (`_attn_implementation_internal`) is a security finding: transformers before 5.3.0 downloads and runs that repository's code (CVE-2026-4372).
1139
+
1140
+ `--fix` holds the code you run today. Where a model imports code from another repository it adds `code_revision=` at that repository's current commit (for sentence-transformers, inside `model_kwargs` and `config_kwargs`, merged into a literal dict if one is there), and where a remote-code load is not pinned it adds `revision=` at the model's current commit. Nothing you run changes on the day; it stops changing underneath you. Python calls and `vllm serve` lines are edited in place; a `**kwargs` call, a dict built elsewhere, a notebook, a metadata record or an env var is listed with the exact value to add, never guessed. Review with `git diff`; in CI, hand the working tree to a pull-request action.
1141
+
1142
+ `--cyclonedx out.cdx.json` writes a CycloneDX 1.6 BOM (validated against the 1.6 JSON schema): one `machine-learning-model` component per model with a `pkg:huggingface/<id>@<commit>` purl, each cross-repository code repository as a dependency, and each finding as a vulnerability entry carrying its lane and the recommendation it is evidence for: NIST SP 800-218A PW.4.4 (verify acquired AI models, including configuration parameters, and scan them before use), PS.3.1 / PS.3.2 (inventory and provenance), and NIST AI 600-1 GV-1.6-003 (record versions of underlying models). These are recommendations; the BOM says so, and is evidence toward them, not a certification.
1143
+
1144
+ Exit 1 when any finding is high. Network: huggingface.co and www.neurarch.com; only public model ids are requested, nothing from the scanned repository is sent. Set `HF_TOKEN` for gated repos.
1145
+
1146
+ ## Which Hugging Face downloads are not pinned to a commit
1147
+
1148
+ ```
1149
+ npx neurarch pin-check [paths...] [--resolve] [--json] [--sarif pins.sarif]
1150
+ ```
1151
+
1152
+ A model id with no revision loads whatever `main` points at on the day the job
1153
+ runs: weights, tokenizer, chat template and config can all move under the same
1154
+ name. `pin-check` reads `.py`, `.ipynb`, YAML, shell scripts and Dockerfiles for
1155
+ `from_pretrained`, `load_dataset`, `hf_hub_download`, `snapshot_download`,
1156
+ `pipeline(model=...)`, `vllm serve`, `python -m sglang.launch_server`, the vLLM
1157
+ API server module, `huggingface-cli download` / `hf download`, and YAML model
1158
+ keys (`base_model`, `model_name_or_path`, `model`, ...) without a revision.
1159
+
1160
+ | Rule | Code | Default | What it means |
1161
+ |---|---|---|---|
1162
+ | `pin/hf-unpinned` | NX-PIN-001 | warn | a repo id and no revision |
1163
+ | `pin/hf-floating-revision` | NX-PIN-002 | warn | the revision is `main`, a tag or `refs/pr/N`, which can move |
1164
+ | `pin/hf-unpinned-dynamic` | NX-PIN-003 | info | the repo id is a variable and there is no revision |
1165
+
1166
+ It follows Bandit's B615 (`huggingface_unsafe_download`): a revision of at least
1167
+ 7 hex characters is a commit; a revision written as an expression is given the
1168
+ benefit of the doubt; `./`, `/` and `../` are local; `# nosec` and
1169
+ `# nosec B615` are honoured. On Bandit's own example file it flags the same 15
1170
+ lines Bandit 1.9.4 flags and none of the safe ones (a test). Where it differs:
1171
+ it also reads serving launches, CLI downloads, YAML recipes and notebooks; a
1172
+ repo id in a variable is `info`, not a warning, because that variable is a
1173
+ local checkpoint about as often as a Hub id; `**kwargs`, `local_files_only=True`,
1174
+ `load_dataset("json", ...)`-style local builders and paths like `os.path.join(...)`
1175
+ or `output_dir` are not reported.
1176
+
1177
+ `--resolve` asks the Hub for the commit `main` points at now and writes it into
1178
+ the fix (`revision="<sha>"`, `--revision <sha>` or `model_revision: <sha>`,
1179
+ whichever the file uses). It is the only network call, and it is off by
1180
+ default. Once a model is pinned, extend the Renovate preset at
1181
+ <https://www.neurarch.com/changes-feeds/renovate/preset.json> and Renovate opens
1182
+ a PR when a tracked model moves, linking what changed key by key.
1183
+
1184
+ Severity, waivers (`# neurarch-ignore: pin/hf-unpinned owner=... reason=...`
1185
+ in the file), the baseline and `--sarif` all come from the policy layer below;
1186
+ `rules: { pin/*: block }` in `.neurarch.yml` makes it a gate.
1187
+
1188
+ Measured on public files, judged by hand line by line (2026-10-18):
1189
+
1190
+ | Sample | Files | Findings | Wrong | Missed (in scope) |
1191
+ |---|---|---|---|---|
1192
+ | Tuning set (the rules above were adjusted on it) | 25 from 25 repos | 42 | 0 (4 before tuning) | 0 (5 before tuning) |
1193
+ | Held out (read once, nothing changed after) | 18 from 18 repos | 18 | 2, both `info`: a variable naming a directory the script had just downloaded into | 0 |
1194
+
1195
+ Calls outside the list (`SentenceTransformer("...")`, `vllm.LLM(model=...)`, a
1196
+ `--tokenizer` flag, Kubernetes `args:` lists) are not read, so "missed" counts
1197
+ only the forms above.
721
1198
 
722
1199
  ## What it refuses to do
723
1200
 
@@ -758,3 +1235,36 @@ Set `HF_TOKEN` to read a gated repo. The token is sent only to
758
1235
  your own
759
1236
  - [`neurarch-lint`](https://www.npmjs.com/package/neurarch-lint): the same
760
1237
  checks against PyTorch source
1238
+
1239
+ ## template-check: the prompt vLLM sends, against the reference
1240
+
1241
+ ```
1242
+ npx neurarch template-check <hf-id> [--at <rev>] [--tool-parts] [--json]
1243
+ npx neurarch template-check <hf-id> --from <rev> [--to <rev>] [--tool-parts] [--json]
1244
+ ```
1245
+
1246
+ A chat template is code shipped in the model repository, and two things change
1247
+ what it produces without anyone touching your deployment: the engine, and an
1248
+ upstream commit. vLLM's default `--chat-template-content-format auto` hands a
1249
+ template that reads content parts its system, user and assistant messages as a
1250
+ list of text parts; transformers' `apply_chat_template` is usually called with
1251
+ strings. `template-check` renders the template both ways on a system+user turn,
1252
+ a multi-turn chat and a tool call, and prints the first place the prompts
1253
+ diverge. Exit 1 on a difference, so it can gate CI.
1254
+
1255
+ How vLLM hands tool results was measured on vLLM 0.33.0 (2026-11-13, through
1256
+ its own `parse_chat_messages`): a string tool result stays a string. Older
1257
+ stacks passed tool results as parts, which is what broke GLM-5.1's tool calls
1258
+ until its 2026-04-16 template fix; `--tool-parts` renders that case:
1259
+
1260
+ ```
1261
+ npx neurarch template-check zai-org/GLM-5.1 --at f5ed80ea7943de93bdb66223a637d7c3af6d8fe4 --tool-parts
1262
+ DIFFERENT prompt: reference (string content) vs vllm (parts content)
1263
+ same system+user
1264
+ same multi-turn
1265
+ different tool-call at char 811
1266
+ ```
1267
+
1268
+ On vLLM 0.33.0 itself, `google/gemma-4-31B-it` differs on the system turn (one
1269
+ extra space). Rendered with @huggingface/jinja; `same` holds for these
1270
+ conversations, not every input. SGLang and llama.cpp are not modelled.