neurarch 0.2.0 → 0.3.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/NOTICE +507 -0
- package/README.md +577 -152
- package/attest.bundle.mjs +343 -0
- package/bin/attest.mjs +188 -0
- package/bin/neurarch.mjs +94 -22
- package/bin/pinCheck.mjs +138 -0
- package/bin/policy.mjs +320 -0
- package/engine.bundle.mjs +3553 -131
- package/examples/.neurarch.yml +44 -0
- package/examples/github-attest.yml +69 -0
- package/examples/github-precheck.yml +40 -0
- package/package.json +5 -2
- package/policy.bundle.mjs +7958 -0
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@ 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 pin-check . # Hugging Face downloads not pinned to a commit (Bandit B615), --sarif for code scanning
|
|
18
20
|
npx neurarch bert-base-uncased --seq-len 1024 --tokenizer-size 30524 # does the data fit what the config accepts
|
|
19
21
|
```
|
|
20
22
|
|
|
@@ -180,7 +182,7 @@ npx neurarch rightsize jobs.csv --out report.md
|
|
|
180
182
|
```
|
|
181
183
|
|
|
182
184
|
```
|
|
183
|
-
6 jobs, 174 GPU-hours, $507.85 spent;
|
|
185
|
+
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
186
|
```
|
|
185
187
|
|
|
186
188
|
For each job in the CSV: what it requested (card x count), what it needed
|
|
@@ -284,14 +286,16 @@ job starts.
|
|
|
284
286
|
block count; global batch = micro x grad-accum x dp; EP against the experts
|
|
285
287
|
and dp x cp; CP against the sequence length; TP past one node.
|
|
286
288
|
2. **Stage balance**: a predicted forward + backward time per microbatch for
|
|
287
|
-
every stage, the sum of its layers: matmul
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
the
|
|
293
|
-
|
|
294
|
-
the
|
|
289
|
+
every stage, the sum of its layers: each matmul at up to 40% of the card's
|
|
290
|
+
peak, less when it is short (a per-card curve fitted to NeuSight's measured
|
|
291
|
+
kernels on H100, L4, A100, V100 and T4; flat 40% on other cards), plus the
|
|
292
|
+
bytes the memory-bound ops move (norms, elementwise, RoPE, the fp32
|
|
293
|
+
cross-entropy) at 80% of its bandwidth. Embedding on the first stage, LM
|
|
294
|
+
head and loss on the last. The step is the 1F1B or interleaved schedule
|
|
295
|
+
simulated op by op at your microbatch count (a port of Primus's schedule
|
|
296
|
+
simulator), so it prints the predicted slowdown against a perfect split at
|
|
297
|
+
that count, the asymptotic one next to it, and the contiguous `--layers`
|
|
298
|
+
split with the shortest simulated step.
|
|
295
299
|
3. **Pipeline bubble**: (p-1)/v over (m + (p-1)/v), and the microbatch count
|
|
296
300
|
that brings it under 15%.
|
|
297
301
|
4. **Per-stage memory**: weights, gradients and Adam state for that stage's
|
|
@@ -313,27 +317,27 @@ Parallel layout check: Qwen/Qwen3-8B
|
|
|
313
317
|
128 GPUs (h100-sxm, 80 GB), 36 blocks, schedule 1f1b, ZeRO 0, 64 microbatches/step, global batch 512
|
|
314
318
|
|
|
315
319
|
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
|
|
317
|
-
1 10-18 (9) - 1.74B 11.33 GFLOP
|
|
318
|
-
2 19-27 (9) - 1.74B 11.33 GFLOP
|
|
319
|
-
3 28-36 (9) head+loss 2.36B 15.06 GFLOP
|
|
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.
|
|
320
|
+
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
|
|
321
|
+
1 10-18 (9) - 1.74B 11.33 GFLOP 50 10% 0.94x 1.4 GB 3 12.4 GB 17.8 GB fits
|
|
322
|
+
2 19-27 (9) - 1.74B 11.33 GFLOP 50 10% 0.94x 1.4 GB 2 11.1 GB 15.8 GB fits
|
|
323
|
+
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
|
|
324
|
+
* 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
325
|
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
326
|
|
|
323
|
-
Balance: slowest stage 3 at 1.
|
|
324
|
-
Predicted step at 64 microbatches (
|
|
325
|
-
Rebalanced split
|
|
327
|
+
Balance: slowest stage 3 at 1.18x the mean stage's predicted time.
|
|
328
|
+
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).
|
|
329
|
+
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
330
|
Bubble: 4.5% at 64 microbatches/step.
|
|
327
331
|
|
|
328
|
-
warn Stage 3 has
|
|
329
|
-
Per-stage predicted ms per microbatch:
|
|
330
|
-
fix: layersPerStage
|
|
332
|
+
warn Stage 3 has 17.5% more predicted time than the mean stage (it also carries the LM head and the loss)
|
|
333
|
+
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.
|
|
334
|
+
fix: layersPerStage 9,10,10,7: predicted 11.9% faster steps at 64 microbatches (12.5% as microbatches grow).
|
|
331
335
|
|
|
332
336
|
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
337
|
skipped world-size: numGpus not given; the product tp x pp x dp x cp is taken as the world size.
|
|
334
338
|
skipped dp-seq-imbalance: no sequence-length histogram given (seqLenHistogram / --seq-hist); padded or packed fixed-length batches are assumed.
|
|
335
339
|
|
|
336
|
-
Derived from the graph, not measured. A stage's time is the sum of its layers: matmul
|
|
340
|
+
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
341
|
```
|
|
338
342
|
|
|
339
343
|
A Llama-3.1-8B layout (128,256-token vocabulary, the ungated
|
|
@@ -347,40 +351,41 @@ Parallel layout check: NousResearch/Meta-Llama-3.1-8B
|
|
|
347
351
|
128 GPUs (h100-sxm, 80 GB), 32 blocks, schedule 1f1b, ZeRO 0, 8 microbatches/step, global batch 64
|
|
348
352
|
|
|
349
353
|
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
|
|
351
|
-
1 9-16 (8) - 1.74B 11.28 GFLOP
|
|
352
|
-
2 17-24 (8) - 1.74B 11.28 GFLOP
|
|
353
|
-
3 25-32 (8) head+loss 2.27B 14.43 GFLOP
|
|
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.
|
|
354
|
+
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
|
|
355
|
+
1 9-16 (8) - 1.74B 11.28 GFLOP 48 10% 0.95x 1.3 GB 3 12.4 GB 17.8 GB fits
|
|
356
|
+
2 17-24 (8) - 1.74B 11.28 GFLOP 48 10% 0.95x 1.3 GB 2 11.1 GB 15.8 GB fits
|
|
357
|
+
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
|
|
358
|
+
* 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
359
|
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
360
|
|
|
357
|
-
Balance: slowest stage 3 at 1.
|
|
358
|
-
Predicted step at 8 microbatches (
|
|
359
|
-
Rebalanced split
|
|
361
|
+
Balance: slowest stage 3 at 1.16x the mean stage's predicted time.
|
|
362
|
+
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).
|
|
363
|
+
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
364
|
Bubble: 27.3% at 8 microbatches/step (17+ for under 15.0%).
|
|
361
365
|
DP sequence imbalance: slowest rank 1.529x the mean; packed 1.016x (monte-carlo).
|
|
362
366
|
|
|
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
367
|
warn Pipeline bubble is 27.3% of each step
|
|
367
368
|
1F1B with PP 4 and 8 microbatches per step: (p-1) / (m + (p-1)). Every GPU idles this share of the step.
|
|
368
369
|
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
370
|
warn Uneven sequence lengths make the slowest of 8 DP ranks ~52.9% slower than the mean
|
|
370
371
|
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
372
|
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.
|
|
373
|
+
info Stage 3 has 15.7% more predicted time than the mean stage (it also carries the LM head and the loss)
|
|
374
|
+
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.
|
|
375
|
+
fix: layersPerStage 9,9,8,6: predicted 8.0% faster steps at 8 microbatches (8.4% as microbatches grow).
|
|
372
376
|
|
|
373
377
|
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
378
|
skipped world-size: numGpus not given; the product tp x pp x dp x cp is taken as the world size.
|
|
375
379
|
|
|
376
|
-
Derived from the graph, not measured. A stage's time is the sum of its layers: matmul
|
|
380
|
+
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
381
|
```
|
|
378
382
|
|
|
379
383
|
What it is not: a timing. Every ms and every percentage above is predicted
|
|
380
384
|
from the graph and the card's datasheet numbers. It was checked against real
|
|
381
385
|
runs in `scripts/layout-calibration/` of the main repo: Qwen3-0.6B trained
|
|
382
386
|
with 1F1B on 2 and 4 L4s, where the predicted speedup of every split it was
|
|
383
|
-
asked about landed within 5.
|
|
387
|
+
asked about landed within 5.4 points of measured, and Qwen3-4B on 2 H100s,
|
|
388
|
+
within 2.3. On the first layout:
|
|
384
389
|
|
|
385
390
|
```
|
|
386
391
|
$ npx neurarch layout Qwen/Qwen3-0.6B --pp 4 --micro 1 --grad-accum 8 --seq-len 2048 --gpu l4
|
|
@@ -388,21 +393,21 @@ Parallel layout check: Qwen/Qwen3-0.6B
|
|
|
388
393
|
4 GPUs (l4, 24 GB), 28 blocks, schedule 1f1b, ZeRO 0, 8 microbatches/step, global batch 8
|
|
389
394
|
|
|
390
395
|
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
|
|
392
|
-
1 8-14 (7) - 110M 837.1 MFLOP
|
|
393
|
-
2 15-21 (7) - 110M 837.1 MFLOP
|
|
394
|
-
3 22-28 (7) head+loss 266M 1.77 GFLOP
|
|
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.
|
|
396
|
+
0 1-7 (7) embedding 266M 837.1 MFLOP 76 39% 0.77x 0.7 GB 4 7.8 GB 11.2 GB fits
|
|
397
|
+
1 8-14 (7) - 110M 837.1 MFLOP 75 38% 0.76x 0.7 GB 3 4.1 GB 5.9 GB fits
|
|
398
|
+
2 15-21 (7) - 110M 837.1 MFLOP 75 38% 0.76x 0.7 GB 2 3.5 GB 4.9 GB fits
|
|
399
|
+
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
|
|
400
|
+
* 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
401
|
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
402
|
|
|
398
|
-
Balance: slowest stage 3 at 1.
|
|
399
|
-
Predicted step at 8 microbatches (
|
|
400
|
-
Rebalanced split 9,9,9,1: 1.
|
|
403
|
+
Balance: slowest stage 3 at 1.70x the mean stage's predicted time.
|
|
404
|
+
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).
|
|
405
|
+
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
406
|
Bubble: 27.3% at 8 microbatches/step (17+ for under 15.0%).
|
|
402
407
|
|
|
403
|
-
warn Stage 3 has
|
|
404
|
-
Per-stage predicted ms per microbatch:
|
|
405
|
-
fix: layersPerStage 9,9,9,1: predicted
|
|
408
|
+
warn Stage 3 has 70.3% more predicted time than the mean stage (it also carries the LM head and the loss)
|
|
409
|
+
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.
|
|
410
|
+
fix: layersPerStage 9,9,9,1: predicted 40.2% faster steps at 8 microbatches (62.1% as microbatches grow).
|
|
406
411
|
warn Pipeline bubble is 27.3% of each step
|
|
407
412
|
1F1B with PP 4 and 8 microbatches per step: (p-1) / (m + (p-1)). Every GPU idles this share of the step.
|
|
408
413
|
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 +419,19 @@ Parallel layout check: Qwen/Qwen3-0.6B
|
|
|
414
419
|
skipped world-size: numGpus not given; the product tp x pp x dp x cp is taken as the world size.
|
|
415
420
|
skipped dp-seq-imbalance: no sequence-length histogram given (seqLenHistogram / --seq-hist); padded or packed fixed-length batches are assumed.
|
|
416
421
|
|
|
417
|
-
Derived from the graph, not measured. A stage's time is the sum of its layers: matmul
|
|
422
|
+
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
423
|
```
|
|
419
424
|
|
|
420
425
|
Measured on 4 L4s: the even split's step took 1478 and 1451 ms (two runs;
|
|
421
|
-
predicted
|
|
426
|
+
predicted 1566), and 9,9,9,1 was 35.3% and 34.4% faster (predicted 40.2%).
|
|
422
427
|
The last rank peaked at 9.7 GB on the even split and 7.3 GB on 9,9,9,1
|
|
423
428
|
(predicted 9.5 and 7.1).
|
|
424
429
|
|
|
425
|
-
Where it is off:
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
430
|
+
Where it is off: absolute step time runs over, by 2% to 7% on L4 and 23% to
|
|
431
|
+
27% on H100, where long matmuls run well above the 40% the model assumes; it
|
|
432
|
+
still overprices the LM head there (head over one block measured at 0.69x and
|
|
433
|
+
0.97x the predicted ratio on two models), so the last-stage gap reads a
|
|
434
|
+
little high. The byte counts are
|
|
429
435
|
for the stock PyTorch / transformers kernels; a stack with fused norms and a
|
|
430
436
|
fused loss moves fewer bytes. Calibrate against one short profiled run before
|
|
431
437
|
trusting a percentage on a new card.
|
|
@@ -434,16 +440,41 @@ trusting a percentage on a new card.
|
|
|
434
440
|
|
|
435
441
|
```
|
|
436
442
|
npx neurarch serve-check <hf-id | graph.json> --gpu h100 [--gpus 4] [--engine vllm|sglang|llamacpp] \
|
|
437
|
-
[--
|
|
443
|
+
[--vllm-version 0.19.1 | --sglang-version 0.5.22] [--against <old-hf-id>] \
|
|
444
|
+
[--gpu-mem <GiB>] [--gpu-mem-used <GiB>]
|
|
445
|
+
[--sampler temperature=0.7,top_p=0.8] [--receipt <startup plan | dir | vLLM log>] [--json] -- <launch command>
|
|
438
446
|
npx neurarch serve-check <hf-id> --gpu l4 --cmd "vllm serve Qwen/Qwen3-8B -tp 4 --max-model-len 32768"
|
|
439
447
|
```
|
|
440
448
|
|
|
449
|
+
Cards beyond the app's table: `a40`, `gh200-96g`, `gh200-144g`, `rtx-pro-6000`,
|
|
450
|
+
`ascend-910b` (memory only, no CUDA checks). `--gpu-mem <GiB>` sets the card's
|
|
451
|
+
total as torch reports it, on top of `--gpu` or alone for any other card;
|
|
452
|
+
`--gpu-mem-used <GiB>` is memory other processes already hold; vLLM's
|
|
453
|
+
`--kv-cache-memory-bytes` is read from the launch. When the repo publishes
|
|
454
|
+
`model.safetensors.index.json`, the weights read from config.json are compared
|
|
455
|
+
with its `total_size`, and past 10% apart the published size is used and the
|
|
456
|
+
report says so. Multimodal configs are checked on the language model's own
|
|
457
|
+
heads, widths and length, not the vision or audio tower's.
|
|
458
|
+
|
|
459
|
+
`--receipt` prints what vLLM measured next to the prediction. It reads a vLLM
|
|
460
|
+
startup plan (`VLLM_ENABLE_STARTUP_PLAN=1`, vLLM 0.26.0 and later, written to
|
|
461
|
+
`$VLLM_CACHE_ROOT/startup_plan/startup_plan_<fingerprint>.json`; give the file
|
|
462
|
+
or the directory and every rank is read) or a startup log ("Available KV cache
|
|
463
|
+
memory", "GPU KV cache size", "Estimated CUDA graph memory", ...). vLLM's own
|
|
464
|
+
stale-plan rules hold: a plan with another schema, a fingerprint that does not
|
|
465
|
+
match its file name, a non-positive size, or a free-memory baseline above this
|
|
466
|
+
card's memory is named and never quoted as a measurement. The fingerprint is a
|
|
467
|
+
hash of vLLM's internal config and cannot be recomputed outside vLLM, so the
|
|
468
|
+
receipt says it assumes the plan belongs to the launch you gave.
|
|
469
|
+
|
|
441
470
|
The launch command is the one you would run (`vllm serve ...`,
|
|
442
471
|
`python -m sglang.launch_server ...`, `llama-server -m x.gguf ...`). It reads
|
|
443
472
|
that, the model's `config.json`, `tokenizer_config.json`, `chat_template.jinja`
|
|
444
473
|
and `generation_config.json` from the Hub, and the card. For llama.cpp give the
|
|
445
474
|
repo the GGUF was converted from, since a `.gguf` carries no `config.json`; the
|
|
446
|
-
|
|
475
|
+
GGUF itself (`-m` a local file, or `-hf repo:QUANT` on the Hub, every shard of a
|
|
476
|
+
split file) is read by its header only, a few MB over HTTP range requests, so the
|
|
477
|
+
weights are the tensor table's real bytes, not a guess from the file name.
|
|
447
478
|
|
|
448
479
|
Why: across 66,584 public issues in 17 training, fine-tuning and serving repos
|
|
449
480
|
(2024 to 2026), the serving trackers grew 1.58x per month, and inside them the
|
|
@@ -469,14 +500,38 @@ What it checks (exit 1 on any `block`):
|
|
|
469
500
|
`rope_scaling` the way vLLM scales it. vLLM and SGLang refuse to start past
|
|
470
501
|
it, so that is a block; llama.cpp runs with a warning, so that is a warn; a
|
|
471
502
|
learned position table is a block everywhere.
|
|
472
|
-
3. **Memory
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
503
|
+
3. **Memory**, with each engine's own arithmetic, ported from its source and
|
|
504
|
+
cited by file and commit:
|
|
505
|
+
- **vLLM**: the KV cache spec per attention type (full, sliding window,
|
|
506
|
+
chunked local, MLA, Mamba / Gated DeltaNet / KDA state, cross attention),
|
|
507
|
+
KV heads replicated once TP passes them, the hybrid grouping and block
|
|
508
|
+
size (a Mamba state sets the attention block size), and the reserve taken
|
|
509
|
+
from total x `--gpu-memory-utilization` before the cache: weights,
|
|
510
|
+
activation peak, non-torch memory and, from 0.20.0, CUDA graphs. The last
|
|
511
|
+
three are measured by vLLM at startup and are estimates here, marked as
|
|
512
|
+
such. It predicts the two lines vLLM prints, "GPU KV cache size: N tokens"
|
|
513
|
+
and "Maximum concurrency for L tokens per request: Xx", and blocks where
|
|
514
|
+
vLLM refuses to start.
|
|
515
|
+
- **Version gates**: `gpu_memory_utilization` 0.9 before 0.20.0 and 0.92
|
|
516
|
+
from it, CUDA graph memory counted from 0.20.0 (both in the 0.20.0 tag,
|
|
517
|
+
though the log line says 0.21), sliding layers holding two batches in
|
|
518
|
+
flight from 0.26.0, the token line printed from concurrency from 0.21.0.
|
|
519
|
+
Without `--vllm-version` the newest release the tables were read from is
|
|
520
|
+
assumed, and the report lists every default it filled in.
|
|
521
|
+
- **SGLang**: its own `mem_fraction_static` formula (512 MB + 1.5 x chunked
|
|
522
|
+
prefill + parallel slack + CUDA graph reserve, 10 GiB floor above 60 GiB)
|
|
523
|
+
and tier defaults, a warn when `--mem-fraction-static` leaves less than
|
|
524
|
+
that, and the KV tokens it would allocate.
|
|
525
|
+
- **llama.cpp**: `-c` allocated up front, sliding-window layers sized the
|
|
526
|
+
way `llama-kv-cache-iswa.cpp` sizes them, weights from the GGUF header.
|
|
527
|
+
4. **Quant and dtype vs the card**: each engine release's own
|
|
528
|
+
`get_min_capability()` per method and compressed-tensors scheme, generated
|
|
529
|
+
from vLLM (0.11.0, 0.19.1, 0.32.0) and SGLang (0.5.22) source by
|
|
530
|
+
`scripts/gen-serve-engine-tables.mjs`, with the line it came from; methods
|
|
531
|
+
vLLM moved to plugins (GGUF in 0.24.0, bitsandbytes in 0.28.0) name the
|
|
532
|
+
plugin. The **vLLM recipe** for the model, when one of the 215 exists: a
|
|
533
|
+
tool-call or reasoning parser that differs, a missing `--trust-remote-code`,
|
|
534
|
+
a release below `min_vllm_version`, a card marked unsupported.
|
|
480
535
|
5. **Template and sampling**: a missing or overridden chat template; tool
|
|
481
536
|
choice without a parser (vLLM refuses to start); a thinking template with
|
|
482
537
|
no reasoning parser; sampler defaults the engine will apply against
|
|
@@ -495,24 +550,37 @@ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 --gpus 4 -- vllm serve Qwen/Qw
|
|
|
495
550
|
Qwen/Qwen3-8B on vLLM
|
|
496
551
|
TP 4 x PP 1 x DP 1, 4 x l4 (sm89), dtype bf16, weights unquantized, KV cache auto
|
|
497
552
|
served length 65536 (--max-model-len 65536); the model's derived maximum 40960
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
553
|
+
engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
|
|
554
|
+
default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
|
|
555
|
+
default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
|
|
556
|
+
default assumed: max_num_batched_tokens 2048 (vllm serve default on L4 (24 GB))
|
|
557
|
+
|
|
558
|
+
memory per GPU, predicted: 22.04 GiB x 0.92 = 20.28 GiB
|
|
559
|
+
- weights 3.81 GiB
|
|
560
|
+
- activation peak 0.58 GiB (estimate; vLLM measures this)
|
|
561
|
+
- non-torch (NCCL, CUDA) 0.27 GiB (estimate; vLLM measures this)
|
|
562
|
+
- CUDA graphs 1.04 GiB (estimate; vLLM measures this)
|
|
563
|
+
= KV cache 14.57 GiB: 26,529 blocks of 16 tokens (36 full)
|
|
564
|
+
36,864 KV bytes per token over the full-length layers; one full-length request 2.25 GiB
|
|
565
|
+
vLLM would print: GPU KV cache size: 424,464 tokens; Maximum concurrency for 65,536 tokens per request: 6.47x
|
|
502
566
|
weights: 2 bytes per parameter (16-bit)
|
|
567
|
+
card total: derived: nvidia-smi 23034 MiB less the 468 MiB gap measured on H100
|
|
503
568
|
|
|
504
569
|
block Served length 65536 is past the model's 40960-token context
|
|
505
570
|
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
571
|
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
|
|
508
|
-
|
|
509
|
-
fix: Set the flag to what fits (
|
|
572
|
+
warn --max-num-seqs 256, but at most 6 requests fit at the full 65536 tokens
|
|
573
|
+
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.
|
|
574
|
+
fix: Set the flag to what fits (6), shorten the max length, use an fp8 KV cache, or add GPUs as DP replicas.
|
|
510
575
|
info The template has a thinking block and no --reasoning-parser is set
|
|
511
576
|
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
|
-
|
|
577
|
+
fix: Add --reasoning-parser qwen3 (the vLLM recipe for Qwen/Qwen3-8B).
|
|
578
|
+
source: github.com/vllm-project/recipes/blob/2338e9edec/models/Qwen/Qwen3-8B.yaml
|
|
579
|
+
info pad_token_id 151643 is also an EOS id
|
|
580
|
+
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.
|
|
581
|
+
fix: For fine-tuning, set a distinct pad token.
|
|
514
582
|
|
|
515
|
-
checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, context, quant-support, memory, memory-fit, chat-template, sampler
|
|
583
|
+
checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, context, quant-support, memory, memory-fit, chat-template, recipe, sampler
|
|
516
584
|
```
|
|
517
585
|
|
|
518
586
|
The FP8 build of Qwen3-30B-A3B at TP 4: the experts are 768 wide, a quarter is
|
|
@@ -523,21 +591,41 @@ $ npx neurarch serve-check Qwen/Qwen3-30B-A3B-FP8 --gpu h100 --gpus 4 -- vllm se
|
|
|
523
591
|
Qwen/Qwen3-30B-A3B-FP8 on vLLM
|
|
524
592
|
TP 4 x PP 1 x DP 1, 4 x h100-sxm (sm90), dtype bf16, weights fp8, KV cache auto
|
|
525
593
|
served length 32768 (--max-model-len 32768); the model's derived maximum 40960
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
594
|
+
engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
|
|
595
|
+
default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
|
|
596
|
+
default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
|
|
597
|
+
default assumed: max_num_batched_tokens 8192 (vllm serve default on H100 SXM (80 GB))
|
|
598
|
+
default assumed: max_num_seqs 1024 (vllm serve default on H100 SXM (80 GB))
|
|
599
|
+
|
|
600
|
+
memory per GPU, predicted: 79.19 GiB x 0.92 = 72.85 GiB
|
|
601
|
+
- weights 7.25 GiB
|
|
602
|
+
- activation peak 2.32 GiB (estimate; vLLM measures this)
|
|
603
|
+
- non-torch (NCCL, CUDA) 2.10 GiB (estimate; vLLM measures this)
|
|
604
|
+
- CUDA graphs 1.04 GiB (estimate; vLLM measures this)
|
|
605
|
+
= KV cache 60.14 GiB: 164,229 blocks of 16 tokens (48 full)
|
|
606
|
+
24,576 KV bytes per token over the full-length layers; one full-length request 0.75 GiB
|
|
607
|
+
vLLM would print: GPU KV cache size: 2,627,664 tokens; Maximum concurrency for 32,768 tokens per request: 80.18x
|
|
530
608
|
weights: fp8 weights (1 byte) with the embedding and LM head kept 16-bit
|
|
609
|
+
card total: vLLM log, llm-d-planner accuracy report (H100-80GB "physical 79.19 GiB")
|
|
531
610
|
|
|
532
611
|
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
612
|
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
613
|
fix: Use a TP size where 768 / TP is a multiple of 128 (1, 2), or enable expert parallelism so experts stay whole.
|
|
614
|
+
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
615
|
info MoE with 128 experts at TP 4 without expert parallelism
|
|
536
616
|
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
617
|
fix: Try --enable-expert-parallel (EP = TP x DP) and compare throughput.
|
|
538
|
-
|
|
618
|
+
info vLLM would log "GPU KV cache size: 2,627,664 tokens" and "Maximum concurrency for 32,768 tokens per request: 80.19x" (predicted)
|
|
619
|
+
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.
|
|
620
|
+
info The template has a thinking block and no --reasoning-parser is set
|
|
621
|
+
The reasoning text comes back inside message.content instead of reasoning_content, which breaks clients that hide or strip it.
|
|
622
|
+
fix: Add --reasoning-parser qwen3.
|
|
623
|
+
info pad_token_id 151643 is also an EOS id
|
|
624
|
+
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.
|
|
625
|
+
fix: For fine-tuning, set a distinct pad token.
|
|
539
626
|
|
|
540
627
|
checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, expert-parallel, context, quant-support, memory, memory-fit, chat-template, sampler
|
|
628
|
+
not checked: recipe: no vLLM recipe for "Qwen/Qwen3-30B-A3B-FP8" in the 215-recipe index (vllm-project/recipes@2338e9edec).
|
|
541
629
|
```
|
|
542
630
|
|
|
543
631
|
The same MoE at TP 8, past its 4 KV heads:
|
|
@@ -547,11 +635,23 @@ $ npx neurarch serve-check Qwen/Qwen3-30B-A3B --gpu h100 --gpus 8 -- vllm serve
|
|
|
547
635
|
Qwen/Qwen3-30B-A3B on vLLM
|
|
548
636
|
TP 8 x PP 1 x DP 1, 8 x h100-sxm (sm90), dtype bf16, weights unquantized, KV cache auto
|
|
549
637
|
served length 32768 (--max-model-len 32768); the model's derived maximum 40960
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
638
|
+
engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
|
|
639
|
+
default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
|
|
640
|
+
default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
|
|
641
|
+
default assumed: max_num_batched_tokens 8192 (vllm serve default on H100 SXM (80 GB))
|
|
642
|
+
default assumed: max_num_seqs 1024 (vllm serve default on H100 SXM (80 GB))
|
|
643
|
+
|
|
644
|
+
memory per GPU, predicted: 79.19 GiB x 0.92 = 72.85 GiB
|
|
645
|
+
- weights 7.11 GiB
|
|
646
|
+
- activation peak 2.32 GiB (estimate; vLLM measures this)
|
|
647
|
+
- non-torch (NCCL, CUDA) 2.10 GiB (estimate; vLLM measures this)
|
|
648
|
+
- CUDA graphs 1.04 GiB (estimate; vLLM measures this)
|
|
649
|
+
= KV cache 60.29 GiB: 164,625 blocks of 16 tokens (48 full)
|
|
650
|
+
24,576 KV bytes per token over the full-length layers; one full-length request 0.75 GiB
|
|
651
|
+
vLLM would print: GPU KV cache size: 2,634,000 tokens; Maximum concurrency for 32,768 tokens per request: 80.38x
|
|
554
652
|
weights: 2 bytes per parameter (16-bit)
|
|
653
|
+
card total: vLLM log, llm-d-planner accuracy report (H100-80GB "physical 79.19 GiB")
|
|
654
|
+
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
655
|
|
|
556
656
|
warn TP 8 is past 4 KV heads: each KV head is replicated 2x
|
|
557
657
|
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 +659,17 @@ $ npx neurarch serve-check Qwen/Qwen3-30B-A3B --gpu h100 --gpus 8 -- vllm serve
|
|
|
559
659
|
info MoE with 128 experts at TP 8 without expert parallelism
|
|
560
660
|
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
661
|
fix: Try --enable-expert-parallel (EP = TP x DP) and compare throughput.
|
|
562
|
-
|
|
662
|
+
info vLLM would log "GPU KV cache size: 2,634,000 tokens" and "Maximum concurrency for 32,768 tokens per request: 80.38x" (predicted)
|
|
663
|
+
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.
|
|
664
|
+
info The template has a thinking block and no --reasoning-parser is set
|
|
665
|
+
The reasoning text comes back inside message.content instead of reasoning_content, which breaks clients that hide or strip it.
|
|
666
|
+
fix: Add --reasoning-parser qwen3 (the vLLM recipe for Qwen/Qwen3-30B-A3B).
|
|
667
|
+
source: github.com/vllm-project/recipes/blob/2338e9edec/models/Qwen/Qwen3-30B-A3B.yaml
|
|
668
|
+
info pad_token_id 151643 is also an EOS id
|
|
669
|
+
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.
|
|
670
|
+
fix: For fine-tuning, set a distinct pad token.
|
|
563
671
|
|
|
564
|
-
checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, expert-parallel, context, quant-support, memory, memory-fit, chat-template, sampler
|
|
672
|
+
checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, expert-parallel, context, quant-support, memory, memory-fit, chat-template, recipe, sampler
|
|
565
673
|
```
|
|
566
674
|
|
|
567
675
|
FP8 on an A100 (sm80): it loads, as weight-only:
|
|
@@ -571,19 +679,34 @@ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu a100-40g -- vllm serve Qwen/Qwen3
|
|
|
571
679
|
Qwen/Qwen3-8B on vLLM
|
|
572
680
|
TP 1 x PP 1 x DP 1, 1 x a100-40g (sm80), dtype bf16, weights fp8, KV cache auto
|
|
573
681
|
served length 32768 (--max-model-len 32768); the model's derived maximum 40960
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
682
|
+
engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
|
|
683
|
+
default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
|
|
684
|
+
default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
|
|
685
|
+
default assumed: max_num_batched_tokens 2048 (vllm serve default on A100 (40 GB))
|
|
686
|
+
default assumed: max_num_seqs 256 (vllm serve default on A100 (40 GB))
|
|
687
|
+
|
|
688
|
+
memory per GPU, predicted: 39.54 GiB x 0.92 = 36.38 GiB
|
|
689
|
+
- weights 8.79 GiB
|
|
690
|
+
- activation peak 0.58 GiB (estimate; vLLM measures this)
|
|
691
|
+
- non-torch (NCCL, CUDA) 0.27 GiB (estimate; vLLM measures this)
|
|
692
|
+
- CUDA graphs 1.04 GiB (estimate; vLLM measures this)
|
|
693
|
+
= KV cache 25.70 GiB: 11,696 blocks of 16 tokens (36 full)
|
|
694
|
+
147,456 KV bytes per token over the full-length layers; one full-length request 4.50 GiB
|
|
695
|
+
vLLM would print: GPU KV cache size: 187,136 tokens; Maximum concurrency for 32,768 tokens per request: 5.71x
|
|
578
696
|
weights: fp8 weights (1 byte) with the embedding and LM head kept 16-bit
|
|
697
|
+
card total: derived: nvidia-smi 40960 MiB less the 468 MiB gap measured on H100
|
|
579
698
|
|
|
580
699
|
warn fp8 on A100 (40 GB) (sm80) is not native: it runs on a fallback kernel
|
|
581
|
-
|
|
700
|
+
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
701
|
fix: Expect the memory saving and not the speedup; for native fp8 use an sm89+ card.
|
|
583
702
|
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
|
-
|
|
703
|
+
info vLLM would log "GPU KV cache size: 187,136 tokens" and "Maximum concurrency for 32,768 tokens per request: 5.71x" (predicted)
|
|
704
|
+
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.
|
|
705
|
+
info pad_token_id 151643 is also an EOS id
|
|
706
|
+
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.
|
|
707
|
+
fix: For fine-tuning, set a distinct pad token.
|
|
585
708
|
|
|
586
|
-
checked: gpu-count, tp-heads, tp-kv-heads, context, quant-support, memory, memory-fit, chat-template, sampler
|
|
709
|
+
checked: gpu-count, tp-heads, tp-kv-heads, context, quant-support, memory, memory-fit, chat-template, recipe, sampler
|
|
587
710
|
```
|
|
588
711
|
|
|
589
712
|
gpt-oss-20b (MXFP4 experts) on an A100. Current vLLM runs it there through the
|
|
@@ -594,40 +717,53 @@ $ npx neurarch serve-check openai/gpt-oss-20b --gpu a100-80g -- vllm serve opena
|
|
|
594
717
|
openai/gpt-oss-20b on vLLM
|
|
595
718
|
TP 1 x PP 1 x DP 1, 1 x a100-80g (sm80), dtype bf16, weights mxfp4, KV cache auto
|
|
596
719
|
served length 131072 (not set: the engine derives it from the config); the model's derived maximum 131072
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
720
|
+
engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
|
|
721
|
+
default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
|
|
722
|
+
default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
|
|
723
|
+
default assumed: max_num_batched_tokens 2048 (vllm serve default on A100 (80 GB))
|
|
724
|
+
|
|
725
|
+
memory per GPU, predicted: 79.15 GiB x 0.92 = 72.82 GiB
|
|
726
|
+
- weights 12.80 GiB
|
|
727
|
+
- activation peak 0.19 GiB (estimate; vLLM measures this)
|
|
728
|
+
- non-torch (NCCL, CUDA) 0.27 GiB (estimate; vLLM measures this)
|
|
729
|
+
- CUDA graphs 1.04 GiB (estimate; vLLM measures this)
|
|
730
|
+
= KV cache 58.52 GiB: 159,786 blocks of 16 tokens (12 sliding, 12 full)
|
|
731
|
+
49,152 KV bytes per token over the full-length layers; one full-length request 3.10 GiB
|
|
732
|
+
vLLM would print: GPU KV cache size: 2,476,465 tokens; Maximum concurrency for 131,072 tokens per request: 18.89x
|
|
601
733
|
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
|
|
734
|
+
card total: vLLM log "total_gpu_memory (79.15GiB)" on A100-SXM4-80GB (github.com/vllm-project/vllm/issues/18446)
|
|
735
|
+
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
736
|
|
|
603
737
|
warn mxfp4 on A100 (80 GB) (sm80) is not native: it runs on a fallback kernel
|
|
604
|
-
|
|
738
|
+
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
739
|
fix: Expect the memory saving and not the speedup; for native mxfp4 use an sm90+ card.
|
|
606
740
|
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
|
|
608
|
-
|
|
741
|
+
warn --max-num-seqs 64, but at most 18 requests fit at the full 131072 tokens
|
|
742
|
+
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
743
|
fix: Set the flag to what fits (18), shorten the max length, use an fp8 KV cache, or add GPUs as DP replicas.
|
|
610
744
|
info gpt-oss: the Jinja chat template in the repo was reported to diverge from the harmony training format (not vLLM)
|
|
611
745
|
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
746
|
fix: No change needed on this engine; keep it in mind if the deployment moves.
|
|
613
747
|
source: github.com/waybarrios/vllm-mlx/issues/568; vLLM gpt-oss recipe (openai-harmony rendering)
|
|
614
|
-
|
|
748
|
+
info pad_token_id 199999 is also an EOS id
|
|
749
|
+
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.
|
|
750
|
+
fix: For fine-tuning, set a distinct pad token.
|
|
615
751
|
|
|
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
|
|
752
|
+
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
753
|
```
|
|
618
754
|
|
|
619
755
|
llama.cpp with `-c` past the model's context, and llama.cpp's own sampling
|
|
620
756
|
defaults against the model's:
|
|
621
757
|
|
|
622
758
|
```
|
|
623
|
-
$ npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 -- llama-server -
|
|
759
|
+
$ 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
760
|
Qwen/Qwen3-8B on llama.cpp
|
|
625
761
|
1 x l4 (sm89), weights Q4_K_M, KV cache q8_0/q8_0
|
|
626
762
|
served length 65536 (-c 65536 (one unified KV buffer, so one sequence may use all of it)); the model's derived maximum 40960
|
|
627
763
|
|
|
628
|
-
memory per GPU
|
|
764
|
+
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
765
|
78,336 KV bytes per token; one full-length sequence 5.13 GB
|
|
630
|
-
weights:
|
|
766
|
+
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
767
|
|
|
632
768
|
warn Served length 65536 is past the model's 40960-token context
|
|
633
769
|
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 +772,11 @@ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 -- llama-server -m Qwen3-8B-Q4
|
|
|
636
772
|
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
773
|
fix: Pass --temp 0.6 --top-p 0.95 --top-k 20 (llama.cpp does not read generation_config.json).
|
|
638
774
|
source: kimi.com/blog/kimi-vendor-verifier
|
|
639
|
-
|
|
775
|
+
info pad_token_id 151643 is also an EOS id
|
|
776
|
+
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.
|
|
777
|
+
fix: For fine-tuning, set a distinct pad token.
|
|
640
778
|
|
|
641
|
-
checked: context, memory, memory-fit, chat-template, sampler
|
|
779
|
+
checked: context, gguf-header, memory, memory-fit, chat-template, sampler
|
|
642
780
|
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
781
|
not checked: quant-support: llama.cpp's CUDA backend runs every GGUF type on these cards; support is not a per-architecture table.
|
|
644
782
|
```
|
|
@@ -650,74 +788,361 @@ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu h100 --against Qwen/Qwen2.5-7B-In
|
|
|
650
788
|
Qwen/Qwen3-8B on vLLM
|
|
651
789
|
TP 1 x PP 1 x DP 1, 1 x h100-sxm (sm90), dtype bf16, weights unquantized, KV cache auto
|
|
652
790
|
served length 32768 (--max-model-len 32768); the model's derived maximum 40960
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
791
|
+
engine vLLM 0.32.0 (assumed; pass --vllm-version to change)
|
|
792
|
+
default assumed: gpu_memory_utilization 0.92 (vLLM >= 0.20.0 default)
|
|
793
|
+
default assumed: CUDA graph memory taken from the KV budget (vLLM >= 0.20.0)
|
|
794
|
+
default assumed: max_num_batched_tokens 8192 (vllm serve default on H100 SXM (80 GB))
|
|
795
|
+
default assumed: max_num_seqs 1024 (vllm serve default on H100 SXM (80 GB))
|
|
796
|
+
|
|
797
|
+
memory per GPU, predicted: 79.19 GiB x 0.92 = 72.85 GiB
|
|
798
|
+
- weights 15.26 GiB
|
|
799
|
+
- activation peak 2.32 GiB (estimate; vLLM measures this)
|
|
800
|
+
- non-torch (NCCL, CUDA) 0.27 GiB (estimate; vLLM measures this)
|
|
801
|
+
- CUDA graphs 1.04 GiB (estimate; vLLM measures this)
|
|
802
|
+
= KV cache 53.97 GiB: 24,562 blocks of 16 tokens (36 full)
|
|
803
|
+
147,456 KV bytes per token over the full-length layers; one full-length request 4.50 GiB
|
|
804
|
+
vLLM would print: GPU KV cache size: 392,992 tokens; Maximum concurrency for 32,768 tokens per request: 11.99x
|
|
657
805
|
weights: 2 bytes per parameter (16-bit)
|
|
806
|
+
card total: vLLM log, llm-d-planner accuracy report (H100-80GB "physical 79.19 GiB")
|
|
658
807
|
|
|
659
|
-
|
|
808
|
+
info vLLM would log "GPU KV cache size: 392,992 tokens" and "Maximum concurrency for 32,768 tokens per request: 11.99x" (predicted)
|
|
809
|
+
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.
|
|
810
|
+
info pad_token_id 151643 is also an EOS id
|
|
811
|
+
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.
|
|
812
|
+
fix: For fine-tuning, set a distinct pad token.
|
|
660
813
|
info model_type: qwen2 -> qwen3
|
|
661
814
|
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
815
|
info num_hidden_layers: 28 -> 36
|
|
663
816
|
Layer count changes weights and KV per token; PP stage splits must be redone.
|
|
664
|
-
|
|
817
|
+
info hidden_size: 3584 -> 4096
|
|
818
|
+
Width changes weights, the TP divisibility of every linear, and activation memory.
|
|
819
|
+
info num_attention_heads: 28 -> 32
|
|
820
|
+
Head count changes which TP sizes are legal.
|
|
665
821
|
info num_key_value_heads: 4 -> 8
|
|
666
822
|
KV heads change KV bytes per token and where TP starts replicating KV.
|
|
667
|
-
|
|
823
|
+
info head_dim: (absent) -> 128
|
|
824
|
+
Head dimension changes KV bytes per token and the attention kernels that apply.
|
|
825
|
+
info intermediate_size: 18944 -> 12288
|
|
826
|
+
FFN width changes weights and which TP sizes divide it.
|
|
668
827
|
info vocab_size: 152064 -> 151936
|
|
669
828
|
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
829
|
info max_position_embeddings: 32768 -> 40960
|
|
671
830
|
The longest servable length changes; --max-model-len / --context-length may now be past it or leave length unused.
|
|
672
|
-
|
|
831
|
+
info sliding_window: 131072 -> null
|
|
832
|
+
Sliding window changes KV per token at long lengths and which attention backends apply.
|
|
673
833
|
info chat_template: hash 6aca5d55 -> hash 1bae85c9
|
|
674
834
|
Every chat request renders differently: re-render a reference conversation (with tool calls) and re-run the evals that depend on format.
|
|
675
835
|
info generation_config.temperature: 0.7 -> 0.6
|
|
676
836
|
The recommended sampling changes; a gateway that pins the old value now overrides the new model's recommendation.
|
|
677
|
-
|
|
837
|
+
info generation_config.top_p: 0.8 -> 0.95
|
|
838
|
+
The recommended sampling changes; a gateway that pins the old value now overrides the new model's recommendation.
|
|
839
|
+
info generation_config.repetition_penalty: 1.05 -> (absent)
|
|
840
|
+
The recommended sampling changes; a gateway that pins the old value now overrides the new model's recommendation.
|
|
841
|
+
info weights per GPU: 15.2 GB -> 16.4 GB
|
|
842
|
+
Same engine flags and card, computed for both models.
|
|
678
843
|
info KV bytes per token per GPU: 57,344 -> 147,456
|
|
679
844
|
Same engine flags and card, computed for both models.
|
|
680
|
-
info concurrent full-length sequences (upper bound):
|
|
845
|
+
info concurrent full-length sequences (upper bound): 31 -> 11
|
|
846
|
+
Same engine flags and card, computed for both models.
|
|
847
|
+
info derived maximum length: 32768 -> 40960
|
|
681
848
|
Same engine flags and card, computed for both models.
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
the
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
|
695
|
-
|
|
|
696
|
-
|
|
|
697
|
-
|
|
|
698
|
-
|
|
|
699
|
-
|
|
|
700
|
-
|
|
|
701
|
-
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
849
|
+
|
|
850
|
+
checked: gpu-count, tp-heads, tp-kv-heads, context, quant-support, memory, memory-fit, chat-template, recipe, sampler, change
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
Every run ends with the basis paragraph, left out above: what is predicted,
|
|
854
|
+
what is estimated, and the accuracy below.
|
|
855
|
+
|
|
856
|
+
How close the prediction is to what vLLM logged, by llm-d-planner's method
|
|
857
|
+
(percent error against the engine's own "Available KV cache memory" and "GPU
|
|
858
|
+
KV cache size" lines), on public data only and no GPU time
|
|
859
|
+
(`npx vite-node --script scripts/serve-check-validation.ts`):
|
|
860
|
+
|
|
861
|
+
| set | what goes in | quantity | n | mean abs error | median abs error |
|
|
862
|
+
| --- | --- | --- | ---: | ---: | ---: |
|
|
863
|
+
| A. llm-d-planner's vLLM 0.19.0 runs, H100 | card, flags, config | KV GiB | 16 | 0.33% | 0.13% |
|
|
864
|
+
| A | | KV tokens | 6 | 0.12% | 0.13% |
|
|
865
|
+
| B. public GitHub issue logs | the KV memory vLLM logged | KV tokens | 21 | 1.07% | 0.01% |
|
|
866
|
+
| B | | max concurrency | 21 | 3.95% | 0.02% |
|
|
867
|
+
| C. the same logs, end to end | card, flags, config | KV GiB | 9 | 85.89% | 7.63% |
|
|
868
|
+
| C | | KV tokens | 11 | 76.20% | 8.69% |
|
|
869
|
+
|
|
870
|
+
Set A is in-sample for the one fitted constant (16 bytes per sampler logit in
|
|
871
|
+
the activation estimate). Set B is out of sample and isolates the ported KV
|
|
872
|
+
arithmetic: full attention, sliding window (gemma-2, gemma-3, gpt-oss),
|
|
873
|
+
chunked local (Llama 4), Mamba-2 (Nemotron-H), Gated DeltaNet (Qwen3-Next,
|
|
874
|
+
Qwen3.5), KDA (Kimi Linear) and Whisper's cross attention all land within
|
|
875
|
+
0.6% on tokens; the misses are a gemma-3 run whose scheduler token budget the
|
|
876
|
+
flags do not show (concurrency +60%) and two Gated DeltaNet dev builds (+8% and
|
|
877
|
+
+13%). Set C is where the estimates show: the median run is within 8%, and the
|
|
878
|
+
mean is carried by runs whose startup the flags do not describe (a gpt-oss-120b
|
|
879
|
+
run whose CUDA graphs took 9.79 GiB, a Kimi Linear run at 64,000 batched
|
|
880
|
+
tokens, a gemma-3 run whose vision encoder is profiled too). For reference,
|
|
881
|
+
llm-d-planner reports 7.82% mean absolute error on KV memory and 16.65% on
|
|
882
|
+
concurrency for its own planner on vLLM 0.19 / H100.
|
|
883
|
+
|
|
884
|
+
The quant tables are generated, not kept by hand: `get_min_capability()` per
|
|
885
|
+
method and compressed-tensors scheme from vLLM 0.11.0, 0.19.1 and 0.32.0 and
|
|
886
|
+
SGLang 0.5.22, each with its commit (`src/utils/serveEngineTables.generated.ts`,
|
|
887
|
+
regenerated by `node scripts/gen-serve-engine-tables.mjs --vllm <clone>
|
|
888
|
+
--sglang <clone> --recipes <clone>`). Where the two engines disagree on the
|
|
889
|
+
same card (SGLang wants sm80 for fp8 and AWQ-Marlin, vLLM sm75) the finding
|
|
890
|
+
says so. Whether a method runs natively or on a fallback kernel (fp8 on sm80
|
|
891
|
+
runs weight-only through FP8 Marlin, MXFP4 on sm80 through Marlin, NVFP4 below
|
|
892
|
+
sm100 weight-only) is from vLLM's docs, which the registry does not encode.
|
|
893
|
+
GGUF tensor bytes use ggml's block sizes; llama.cpp's sampler defaults come
|
|
894
|
+
from its [server README](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md).
|
|
895
|
+
|
|
896
|
+
What it is not: a launch. vLLM measures its activation peak, non-torch memory
|
|
897
|
+
and CUDA graph pool at startup; here they are estimates, labelled in the
|
|
898
|
+
output. A card's usable total is a logged value for H100 and A100-80GB and is
|
|
899
|
+
derived from nvidia-smi for the rest. Template checks read files and do not
|
|
900
|
+
render a conversation, so "no template finding" does not prove two stacks
|
|
901
|
+
produce the same prompt. Not covered: TensorRT-LLM (whose
|
|
902
|
+
`free_gpu_memory_fraction` is a share of free memory after weights, not of the
|
|
903
|
+
card), SGLang's separate sliding-window and Mamba pools, sparse-attention
|
|
904
|
+
indexer caches (DeepSeek V3.2 / V4), multimodal encoder profiling,
|
|
905
|
+
attention-backend numerics, LoRA adapters, speculative decoding, disaggregated
|
|
906
|
+
prefill / decode, and anything about throughput or latency.
|
|
907
|
+
|
|
908
|
+
## A policy the repo checks in: `.neurarch.yml`, waivers, baselines, SARIF
|
|
909
|
+
|
|
910
|
+
Every check above prints what it computed. A `.neurarch.yml` at the repository
|
|
911
|
+
root says what this repository does about it: which findings block, which are
|
|
912
|
+
accepted until a date by a named owner, which were already there before
|
|
913
|
+
anyone looked, and what budget a run may not cross. The same file is read by
|
|
914
|
+
the CLI, by the SkyPilot admin policy and by the SLURM helper, through one
|
|
915
|
+
engine (`src/utils/policy/`), so a CI check and an admission decision over the
|
|
916
|
+
same file cannot disagree. With no policy file, no baseline and no policy
|
|
917
|
+
flag, nothing here runs and the CLI behaves exactly as before.
|
|
918
|
+
|
|
919
|
+
```yaml
|
|
920
|
+
# yaml-language-server: $schema=https://neurarch.com/schema/neurarch-policy-v1.json
|
|
921
|
+
version: 1
|
|
922
|
+
extends: [neurarch>recommended] # neurarch>strict | neurarch>advisory | local>path | github>org/repo//path.yml#tag
|
|
923
|
+
defaults:
|
|
924
|
+
gpu: h100 # used when the command names no --gpu
|
|
925
|
+
seq_len: 4096 # used when the command names no --seq-len
|
|
926
|
+
budget:
|
|
927
|
+
cards_allowed: [h100, h200] # also max_params: 70B, max_cost_per_run_usd: 2000
|
|
928
|
+
rules:
|
|
929
|
+
layout/pipeline-bubble: block # off | info | warn | block; "memory/*" and "*" re-level warnings and blocks
|
|
930
|
+
waivers:
|
|
931
|
+
- rule: layout/stage-imbalance
|
|
932
|
+
owner: "@li"
|
|
933
|
+
reason: "LM head stage measured at 1.17x on the cluster; rebalance lands with the v2 recipe"
|
|
934
|
+
expires: 2026-12-15
|
|
935
|
+
- rule: serve/context-over-derived
|
|
936
|
+
model: "Qwen/*" # scope: model, path and cluster globs
|
|
937
|
+
owner: "@ana"
|
|
938
|
+
reason: "YaRN x4 validated to 131k on our eval set"
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
The schema is published at
|
|
942
|
+
[neurarch.com/schema/neurarch-policy-v1.json](https://neurarch.com/schema/neurarch-policy-v1.json)
|
|
943
|
+
(`npx neurarch policy schema` prints it); `examples/.neurarch.yml` has every
|
|
944
|
+
field. `npx neurarch policy show` is the effective policy after presets, with
|
|
945
|
+
each waiver's dates and where they came from:
|
|
946
|
+
|
|
947
|
+
```
|
|
948
|
+
$ npx neurarch policy show
|
|
949
|
+
.neurarch.yml extends neurarch>recommended
|
|
950
|
+
defaults gpu=h100 seq_len=4096
|
|
951
|
+
budget cards_allowed=h100,h200
|
|
952
|
+
rule layout/pipeline-bubble: block
|
|
953
|
+
waiver layout/stage-imbalance owner=@li created 2026-10-14 (git-blame) in force until 2026-12-15
|
|
954
|
+
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)
|
|
955
|
+
info policy/waiver-expiry-defaulted: Waiver for serve/context-over-derived has no expiry: it applies until 2026-11-17 (created + 30 days)
|
|
956
|
+
```
|
|
957
|
+
|
|
958
|
+
A check run under it prints its own report unchanged, then what the policy
|
|
959
|
+
decided and why the exit code is what it is:
|
|
960
|
+
|
|
961
|
+
```
|
|
962
|
+
$ npx neurarch layout Qwen/Qwen3-8B --tp 4 --pp 8 --dp 4 --micro 1 --global-batch 512 --source train.sh
|
|
963
|
+
policy default: --gpu h100 (from .neurarch.yml)
|
|
964
|
+
policy default: --seq-len 4096 (from .neurarch.yml)
|
|
965
|
+
Parallel layout check: Qwen/Qwen3-8B
|
|
966
|
+
...
|
|
967
|
+
policy policy .neurarch.yml (extends neurarch>recommended)
|
|
968
|
+
warn layout/uneven-default-split: 36 layers do not divide evenly into PP 8
|
|
969
|
+
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]
|
|
970
|
+
reason: LM head stage measured at 1.17x on the cluster; rebalance lands with the v2 recipe
|
|
971
|
+
info policy/waiver-expiry-defaulted: Waiver for serve/context-over-derived has no expiry: it applies until 2026-11-17 (created + 30 days)
|
|
972
|
+
nothing blocks, 1 waived: exit 0
|
|
973
|
+
```
|
|
974
|
+
|
|
975
|
+
**Waivers never last forever.** Trivy and Snyk both treat a waiver with no
|
|
976
|
+
expiry as permanent. Here a missing or unreadable `expires` is `created + 30
|
|
977
|
+
days`, and an info finding says the default was taken. A missing `created` is
|
|
978
|
+
the git blame date of the waiver's line, else the date the first run saw it
|
|
979
|
+
(recorded in `.neurarch/waivers-seen.json`, so it does not move; commit it),
|
|
980
|
+
never "now", which would renew the waiver on every run. A waiver with no
|
|
981
|
+
`owner` or no `reason` does not apply, and says so. An expired waiver brings
|
|
982
|
+
its finding back and is a finding itself (`policy/waiver-expired`, a block
|
|
983
|
+
under `neurarch>strict`). A waiver is in force through its expiry day (UTC).
|
|
984
|
+
Findings about the policy file cannot themselves be waived.
|
|
985
|
+
|
|
986
|
+
**Inline waivers** go in the file the run was checked from (`--source`): a
|
|
987
|
+
launch script, an sbatch file, a recipe. Same fields, same engine, dated by git
|
|
988
|
+
blame of the comment's line, scoped to that file:
|
|
989
|
+
|
|
990
|
+
```bash
|
|
991
|
+
# neurarch-ignore: serve/context-over-derived reason="YaRN validated to 64k" owner=@ana expires=2026-12-01
|
|
992
|
+
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'
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
**Baselines** judge only what is new. `npx neurarch baseline <check ...>` runs
|
|
996
|
+
the check and writes what it found to `.neurarch/baseline.json` (rule id plus a
|
|
997
|
+
fingerprint over the checker, rule, model, source file and the finding's title
|
|
998
|
+
with numbers removed, so a re-estimate of a known problem is not "new"). Later
|
|
999
|
+
runs report and fail on new findings only; `--all` shows the rest:
|
|
1000
|
+
|
|
1001
|
+
```
|
|
1002
|
+
$ npx neurarch baseline layout Qwen/Qwen3-8B --tp 4 --pp 8 --dp 4 --micro 1 --global-batch 512 --source train.sh
|
|
1003
|
+
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.
|
|
1004
|
+
|
|
1005
|
+
$ npx neurarch layout Qwen/Qwen3-8B --tp 3 --pp 8 --dp 4 --micro 1 --global-batch 512 --source train.sh
|
|
1006
|
+
...
|
|
1007
|
+
policy policy .neurarch.yml (extends neurarch>recommended), baseline .neurarch/baseline.json
|
|
1008
|
+
block layout/tp-heads: TP 3 does not divide 32 attention heads
|
|
1009
|
+
block layout/tp-kv-heads: TP 3 neither divides nor is a multiple of 8 KV heads
|
|
1010
|
+
block layout/tp-hidden: TP 3 does not divide hidden size 4096
|
|
1011
|
+
3 blocking, 1 waived, 2 in baseline (2 not shown; --all to show): exit 1
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
**SARIF 2.1.0** for every check (`layout`, `serve-check`, the main check's data
|
|
1015
|
+
fit, memory plan, lint and change gate, the budget lines and the policy's own
|
|
1016
|
+
findings): `--sarif out.sarif`. Each rule carries full metadata; each result
|
|
1017
|
+
carries `partialFingerprints.primaryLocationLineHash`, computed with GitHub's
|
|
1018
|
+
own algorithm (ported from codeql-action, MIT), so an API upload deduplicates
|
|
1019
|
+
like an Action upload, plus `neurarchFinding/v1`. A waived finding stays in the
|
|
1020
|
+
file with a `suppressions` entry (owner, reason, expiry). GitHub shows a pull
|
|
1021
|
+
request alert only on a line the pull request changed, and these findings are
|
|
1022
|
+
about a whole launch, so results anchor to a changed line in `--source` when
|
|
1023
|
+
`--changed-lines` is given (a `git diff -U0` file, or `path:3-5,9`), preferring
|
|
1024
|
+
one that names the flag (`--tp`, `--max-model-len`, the model id), and
|
|
1025
|
+
otherwise to the line that names the flag or the model.
|
|
1026
|
+
`examples/github-precheck.yml` is a complete workflow with
|
|
1027
|
+
`github/codeql-action/upload-sarif`:
|
|
1028
|
+
|
|
1029
|
+
```yaml
|
|
1030
|
+
- run: git diff -U0 "origin/${{ github.base_ref }}...HEAD" > changes.diff
|
|
1031
|
+
- run: |
|
|
1032
|
+
mkdir -p sarif
|
|
1033
|
+
npx --yes neurarch layout Qwen/Qwen3-8B --tp 4 --pp 4 --dp 8 --micro 1 --global-batch 512 \
|
|
1034
|
+
--source recipes/qwen3/train.sh --changed-lines changes.diff --sarif sarif/layout.sarif
|
|
1035
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
1036
|
+
if: always()
|
|
1037
|
+
with:
|
|
1038
|
+
sarif_file: sarif
|
|
1039
|
+
```
|
|
1040
|
+
|
|
1041
|
+
Flags on every check: `--policy <file>` (default: the nearest `.neurarch.yml`
|
|
1042
|
+
up to the repo root, or `NEURARCH_POLICY`), `--no-policy`, `--sarif <file>`,
|
|
1043
|
+
`--source <file>`, `--changed-lines <diff | spec>`, `--cluster <name>` (or
|
|
1044
|
+
`NEURARCH_CLUSTER`, `SLURM_CLUSTER_NAME`), `--baseline <file>`, `--all`. A
|
|
1045
|
+
policy file that cannot be read stops the run with exit 2 and the reasons: a
|
|
1046
|
+
policy read halfway is one nobody wrote. `npx neurarch policy validate` checks
|
|
1047
|
+
it alone. Presets are fetched only for `github>` references (raw.githubusercontent.com,
|
|
1048
|
+
`GITHUB_TOKEN` when set); `neurarch>` presets are built in.
|
|
1049
|
+
|
|
1050
|
+
## A record someone else can verify: `--attest`, `--cyclonedx`
|
|
1051
|
+
|
|
1052
|
+
```
|
|
1053
|
+
npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 --gpus 4 \
|
|
1054
|
+
--attest precheck.intoto.json --cyclonedx precheck.cdx.json \
|
|
1055
|
+
-- vllm serve Qwen/Qwen3-8B -tp 4 --max-model-len 32768
|
|
1056
|
+
npx neurarch layout ./graph.json --tp 4 --pp 2 --dp 8 --attest r.json --model-dir ./checkpoint
|
|
1057
|
+
npx neurarch policy apply --json --attest r.json --model-dir ./checkpoint < findings.json
|
|
1058
|
+
```
|
|
1059
|
+
|
|
1060
|
+
`--attest` (on the main check, `layout`, `serve-check` and `policy apply`)
|
|
1061
|
+
writes an [in-toto Statement v1](https://github.com/in-toto/attestation/blob/main/spec/v1/statement.md)
|
|
1062
|
+
with in-toto's own [test-result](https://github.com/in-toto/attestation/blob/main/spec/predicates/test-result.md)
|
|
1063
|
+
predicate: `result` (`PASSED`, `WARNED`, `FAILED`; `FAILED` whenever the run
|
|
1064
|
+
exits non-zero), `passedTests` / `warnedTests` / `failedTests` by rule id, and
|
|
1065
|
+
in `configuration` the CLI version and the sha256 of every file whose code or
|
|
1066
|
+
tables decided the verdict (the bundles, the repo's `.neurarch.yml`, the
|
|
1067
|
+
`--source` file). The verdicts, findings and the command line sit in one
|
|
1068
|
+
extension field, `neurarchPrecheck`, described by
|
|
1069
|
+
<https://neurarch.com/schema/precheck-attestation-v1.json>.
|
|
1070
|
+
|
|
1071
|
+
The subjects are the model's files, hashed and named the way OpenSSF
|
|
1072
|
+
[model-transparency](https://github.com/sigstore/model-transparency)
|
|
1073
|
+
(`model_signing`) does it, and the first subject is the root digest
|
|
1074
|
+
`model_signing sign` signs, so a model signature and a pre-check record point
|
|
1075
|
+
at the same bytes. `--model-dir` hashes a local copy; without it a Hub id is
|
|
1076
|
+
read at the commit `main` points to (LFS files by their recorded sha256, small
|
|
1077
|
+
files downloaded and hashed), and a graph file is its own subject.
|
|
1078
|
+
|
|
1079
|
+
The output is deterministic: keys sorted, no clock. A time appears only with
|
|
1080
|
+
`--attest-time <RFC 3339>`, a URL only with `--attest-url`, so two runs over
|
|
1081
|
+
the same inputs write the same bytes and a record can be diffed and signed.
|
|
1082
|
+
`examples/github-attest.yml` signs it with `actions/attest`, after which
|
|
1083
|
+
`gh attestation verify <model file> -R <owner>/<repo> --predicate-type https://in-toto.io/attestation/test-result/v0.1`
|
|
1084
|
+
finds it.
|
|
1085
|
+
|
|
1086
|
+
`--cyclonedx` writes a CycloneDX 1.6 BOM with one `machine-learning-model`
|
|
1087
|
+
component (its files as `file` components with SHA-256 hashes) carrying the
|
|
1088
|
+
verdicts as `neurarch:` properties: `neurarch:training:peak_gb`,
|
|
1089
|
+
`neurarch:training:smallest_card`, `neurarch:serve:verdict`,
|
|
1090
|
+
`neurarch:layout:verdict` and the rest listed in
|
|
1091
|
+
`src/utils/attestation/index.ts`. A fragment to merge into the BOM your SBOM
|
|
1092
|
+
tool already writes; valid against the official 1.6 schema on its own.
|
|
1093
|
+
|
|
1094
|
+
## Which Hugging Face downloads are not pinned to a commit
|
|
1095
|
+
|
|
1096
|
+
```
|
|
1097
|
+
npx neurarch pin-check [paths...] [--resolve] [--json] [--sarif pins.sarif]
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
A model id with no revision loads whatever `main` points at on the day the job
|
|
1101
|
+
runs: weights, tokenizer, chat template and config can all move under the same
|
|
1102
|
+
name. `pin-check` reads `.py`, `.ipynb`, YAML, shell scripts and Dockerfiles for
|
|
1103
|
+
`from_pretrained`, `load_dataset`, `hf_hub_download`, `snapshot_download`,
|
|
1104
|
+
`pipeline(model=...)`, `vllm serve`, `python -m sglang.launch_server`, the vLLM
|
|
1105
|
+
API server module, `huggingface-cli download` / `hf download`, and YAML model
|
|
1106
|
+
keys (`base_model`, `model_name_or_path`, `model`, ...) without a revision.
|
|
1107
|
+
|
|
1108
|
+
| Rule | Code | Default | What it means |
|
|
1109
|
+
|---|---|---|---|
|
|
1110
|
+
| `pin/hf-unpinned` | NX-PIN-001 | warn | a repo id and no revision |
|
|
1111
|
+
| `pin/hf-floating-revision` | NX-PIN-002 | warn | the revision is `main`, a tag or `refs/pr/N`, which can move |
|
|
1112
|
+
| `pin/hf-unpinned-dynamic` | NX-PIN-003 | info | the repo id is a variable and there is no revision |
|
|
1113
|
+
|
|
1114
|
+
It follows Bandit's B615 (`huggingface_unsafe_download`): a revision of at least
|
|
1115
|
+
7 hex characters is a commit; a revision written as an expression is given the
|
|
1116
|
+
benefit of the doubt; `./`, `/` and `../` are local; `# nosec` and
|
|
1117
|
+
`# nosec B615` are honoured. On Bandit's own example file it flags the same 15
|
|
1118
|
+
lines Bandit 1.9.4 flags and none of the safe ones (a test). Where it differs:
|
|
1119
|
+
it also reads serving launches, CLI downloads, YAML recipes and notebooks; a
|
|
1120
|
+
repo id in a variable is `info`, not a warning, because that variable is a
|
|
1121
|
+
local checkpoint about as often as a Hub id; `**kwargs`, `local_files_only=True`,
|
|
1122
|
+
`load_dataset("json", ...)`-style local builders and paths like `os.path.join(...)`
|
|
1123
|
+
or `output_dir` are not reported.
|
|
1124
|
+
|
|
1125
|
+
`--resolve` asks the Hub for the commit `main` points at now and writes it into
|
|
1126
|
+
the fix (`revision="<sha>"`, `--revision <sha>` or `model_revision: <sha>`,
|
|
1127
|
+
whichever the file uses). It is the only network call, and it is off by
|
|
1128
|
+
default. Once a model is pinned, extend the Renovate preset at
|
|
1129
|
+
<https://www.neurarch.com/changes-feeds/renovate/preset.json> and Renovate opens
|
|
1130
|
+
a PR when a tracked model moves, linking what changed key by key.
|
|
1131
|
+
|
|
1132
|
+
Severity, waivers (`# neurarch-ignore: pin/hf-unpinned owner=... reason=...`
|
|
1133
|
+
in the file), the baseline and `--sarif` all come from the policy layer below;
|
|
1134
|
+
`rules: { pin/*: block }` in `.neurarch.yml` makes it a gate.
|
|
1135
|
+
|
|
1136
|
+
Measured on public files, judged by hand line by line (2026-10-18):
|
|
1137
|
+
|
|
1138
|
+
| Sample | Files | Findings | Wrong | Missed (in scope) |
|
|
1139
|
+
|---|---|---|---|---|
|
|
1140
|
+
| Tuning set (the rules above were adjusted on it) | 25 from 25 repos | 42 | 0 (4 before tuning) | 0 (5 before tuning) |
|
|
1141
|
+
| 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 |
|
|
1142
|
+
|
|
1143
|
+
Calls outside the list (`SentenceTransformer("...")`, `vllm.LLM(model=...)`, a
|
|
1144
|
+
`--tokenizer` flag, Kubernetes `args:` lists) are not read, so "missed" counts
|
|
1145
|
+
only the forms above.
|
|
721
1146
|
|
|
722
1147
|
## What it refuses to do
|
|
723
1148
|
|