neurarch 0.1.2 → 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/README.md CHANGED
@@ -1,14 +1,22 @@
1
1
  # neurarch
2
2
 
3
- What a GPU training job needs before it takes a reservation: the peak memory at
4
- its batch, the smallest card that holds it, and what one run costs, read from a
5
- Hugging Face `config.json` (or a traced graph). No account, no download, no GPU.
3
+ The pre-check for an open-weight model change, before it takes a GPU or
4
+ traffic. From a Hugging Face `config.json` (or a traced graph), without running
5
+ the model: what a training job needs (the peak memory at its batch, the smallest
6
+ card that holds it, what one run costs), whether a parallel layout is legal and
7
+ balanced (`layout`), whether a serving launch will start and hold what it
8
+ promises (`serve-check`), and whether the data fits what the config accepts.
9
+ No account, no download, no GPU.
6
10
 
7
11
  ```
8
12
  npx neurarch rightsize jobs.csv # each past job's request next to what it needed
9
13
  npx neurarch Qwen/Qwen3-8B --batch 8 # the training peak for one model
10
14
  npx neurarch oom error.txt --model Qwen/Qwen3-8B --batch 8 # why it ran out of memory, and the least invasive fix
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
+ 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
11
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
12
20
  npx neurarch bert-base-uncased --seq-len 1024 --tokenizer-size 30524 # does the data fit what the config accepts
13
21
  ```
14
22
 
@@ -174,7 +182,7 @@ npx neurarch rightsize jobs.csv --out report.md
174
182
  ```
175
183
 
176
184
  ```
177
- 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.
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.
178
186
  ```
179
187
 
180
188
  For each job in the CSV: what it requested (card x count), what it needed
@@ -251,6 +259,891 @@ wall hours, so a request cut from 8 cards to 1 is capacity reserved and not
251
259
  needed, not a promise the same job finishes as fast. The report prints all of
252
260
  this next to the numbers.
253
261
 
262
+ ## Is this parallel split legal, balanced, and worth running
263
+
264
+ ```
265
+ npx neurarch layout <hf-id | graph.json> --tp 4 --pp 4 --dp 8 --micro 1 --global-batch 512 --seq-len 4096 \
266
+ [--gpu h100] [--gpus 128] [--cp 2] [--ep 8] [--schedule 1f1b|interleaved --virtual 2] \
267
+ [--layers 9,10,10,7] [--zero 1|2|3 | --fsdp] [--recompute] [--fused-ce] [--seq-hist hist.csv] [--json]
268
+ ```
269
+
270
+ ByteDance traced five months of its own LLM training ("Understanding
271
+ Stragglers in Large Model Training Using What-if Analysis", OSDI 2025,
272
+ arXiv:2505.05713): 10.4% of allocated GPU-hours went to stragglers, 42.5% of
273
+ jobs ran at least 10% slower than their straggler-free what-if, and machine
274
+ problems explained the majority of the slowdown in only 1.7% of straggling
275
+ jobs. In 39.3% of jobs the last pipeline stage caused most of it, because it
276
+ carries the LM head and the loss on top of an even share of transformer
277
+ layers; uneven sequence lengths affected 21.4%, at 1.34x on average. Those are
278
+ configuration choices, and all of them are readable from the model before the
279
+ job starts.
280
+
281
+ `layout` checks five things:
282
+
283
+ 1. **Legality** (exit 1): tp x pp x dp x cp against `--gpus`; TP against the
284
+ attention heads, KV heads (a multiple of them is a replication warning),
285
+ hidden and FFN widths; PP against the blocks and `--layers` against the
286
+ block count; global batch = micro x grad-accum x dp; EP against the experts
287
+ and dp x cp; CP against the sequence length; TP past one node.
288
+ 2. **Stage balance**: a predicted forward + backward time per microbatch for
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.
299
+ 3. **Pipeline bubble**: (p-1)/v over (m + (p-1)/v), and the microbatch count
300
+ that brings it under 15%.
301
+ 4. **Per-stage memory**: weights, gradients and Adam state for that stage's
302
+ parameters after TP / EP / ZeRO sharding, plus activations for the
303
+ microbatches 1F1B keeps in flight on that stage (four on stage 0 at PP 4,
304
+ one on the last), against the card, with the same calibrated upper bound
305
+ as the training-peak estimate. The stage with the loss also holds the fp32
306
+ copy of the seq x vocab logits and its gradient (`--fused-ce` drops it).
307
+ 5. **Sequence imbalance across DP ranks**, with `--seq-hist` (CSV of
308
+ `len,count`): the expected slowest rank over the mean, with per-sequence
309
+ work modelled as a*len + b*len^2 from the graph's own FLOPs, against a
310
+ token-packed batch.
311
+
312
+ Qwen3-8B (151,936-token vocabulary, untied head) at TP 4 x PP 4 x DP 8:
313
+
314
+ ```
315
+ $ npx neurarch layout Qwen/Qwen3-8B --tp 4 --pp 4 --dp 8 --micro 1 --global-batch 512 --seq-len 4096 --gpu h100
316
+ Parallel layout check: Qwen/Qwen3-8B
317
+ 128 GPUs (h100-sxm, 80 GB), 36 blocks, schedule 1f1b, ZeRO 0, 64 microbatches/step, global batch 512
318
+
319
+ stage blocks extra params FLOPs/tok ms/mb* mem-bound vs mean act/mb in-flight peak/GPU upper fits
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.
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).
326
+
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.
330
+ Bubble: 4.5% at 64 microbatches/step.
331
+
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).
335
+
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
337
+ skipped world-size: numGpus not given; the product tp x pp x dp x cp is taken as the world size.
338
+ skipped dp-seq-imbalance: no sequence-length histogram given (seqLenHistogram / --seq-hist); padded or packed fixed-length batches are assumed.
339
+
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.
341
+ ```
342
+
343
+ A Llama-3.1-8B layout (128,256-token vocabulary, the ungated
344
+ `NousResearch/Meta-Llama-3.1-8B` mirror of the config) with a small global
345
+ batch and variable-length data. `hist.csv` is `256,4000 / 1024,3000 /
346
+ 2048,2000 / 4096,1000`:
347
+
348
+ ```
349
+ $ npx neurarch layout NousResearch/Meta-Llama-3.1-8B --tp 4 --pp 4 --dp 8 --micro 1 --global-batch 64 --seq-len 4096 --gpu h100 --seq-hist hist.csv
350
+ Parallel layout check: NousResearch/Meta-Llama-3.1-8B
351
+ 128 GPUs (h100-sxm, 80 GB), 32 blocks, schedule 1f1b, ZeRO 0, 8 microbatches/step, global batch 64
352
+
353
+ stage blocks extra params FLOPs/tok ms/mb* mem-bound vs mean act/mb in-flight peak/GPU upper fits
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.
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).
360
+
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.
364
+ Bubble: 27.3% at 8 microbatches/step (17+ for under 15.0%).
365
+ DP sequence imbalance: slowest rank 1.529x the mean; packed 1.016x (monte-carlo).
366
+
367
+ warn Pipeline bubble is 27.3% of each step
368
+ 1F1B with PP 4 and 8 microbatches per step: (p-1) / (m + (p-1)). Every GPU idles this share of the step.
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.
370
+ warn Uneven sequence lengths make the slowest of 8 DP ranks ~52.9% slower than the mean
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.
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).
376
+
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
378
+ skipped world-size: numGpus not given; the product tp x pp x dp x cp is taken as the world size.
379
+
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.
381
+ ```
382
+
383
+ What it is not: a timing. Every ms and every percentage above is predicted
384
+ from the graph and the card's datasheet numbers. It was checked against real
385
+ runs in `scripts/layout-calibration/` of the main repo: Qwen3-0.6B trained
386
+ with 1F1B on 2 and 4 L4s, where the predicted speedup of every split it was
387
+ asked about landed within 5.4 points of measured, and Qwen3-4B on 2 H100s,
388
+ within 2.3. On the first layout:
389
+
390
+ ```
391
+ $ npx neurarch layout Qwen/Qwen3-0.6B --pp 4 --micro 1 --grad-accum 8 --seq-len 2048 --gpu l4
392
+ Parallel layout check: Qwen/Qwen3-0.6B
393
+ 4 GPUs (l4, 24 GB), 28 blocks, schedule 1f1b, ZeRO 0, 8 microbatches/step, global batch 8
394
+
395
+ stage blocks extra params FLOPs/tok ms/mb* mem-bound vs mean act/mb in-flight peak/GPU upper fits
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.
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).
402
+
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.
406
+ Bubble: 27.3% at 8 microbatches/step (17+ for under 15.0%).
407
+
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).
411
+ warn Pipeline bubble is 27.3% of each step
412
+ 1F1B with PP 4 and 8 microbatches per step: (p-1) / (m + (p-1)). Every GPU idles this share of the step.
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
+ info Tied LM head costed on the last stage
415
+ The checkpoint ties the output head to the embedding (151936 x 1024). The weight is shared; the matmul and the loss are not, and under PP the last stage keeps its own copy of the matrix.
416
+ fix: Nothing to change; this says why the last stage is heavier than its block count suggests.
417
+
418
+ 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
419
+ skipped world-size: numGpus not given; the product tp x pp x dp x cp is taken as the world size.
420
+ skipped dp-seq-imbalance: no sequence-length histogram given (seqLenHistogram / --seq-hist); padded or packed fixed-length batches are assumed.
421
+
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.
423
+ ```
424
+
425
+ Measured on 4 L4s: the even split's step took 1478 and 1451 ms (two runs;
426
+ predicted 1566), and 9,9,9,1 was 35.3% and 34.4% faster (predicted 40.2%).
427
+ The last rank peaked at 9.7 GB on the even split and 7.3 GB on 9,9,9,1
428
+ (predicted 9.5 and 7.1).
429
+
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
435
+ for the stock PyTorch / transformers kernels; a stack with fused norms and a
436
+ fused loss moves fewer bytes. Calibrate against one short profiled run before
437
+ trusting a percentage on a new card.
438
+
439
+ ## Will this serving launch start, and hold what it promises
440
+
441
+ ```
442
+ npx neurarch serve-check <hf-id | graph.json> --gpu h100 [--gpus 4] [--engine vllm|sglang|llamacpp] \
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>
446
+ npx neurarch serve-check <hf-id> --gpu l4 --cmd "vllm serve Qwen/Qwen3-8B -tp 4 --max-model-len 32768"
447
+ ```
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
+
470
+ The launch command is the one you would run (`vllm serve ...`,
471
+ `python -m sglang.launch_server ...`, `llama-server -m x.gguf ...`). It reads
472
+ that, the model's `config.json`, `tokenizer_config.json`, `chat_template.jinja`
473
+ and `generation_config.json` from the Hub, and the card. For llama.cpp give the
474
+ repo the GGUF was converted from, since a `.gguf` carries no `config.json`; the
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.
478
+
479
+ Why: across 66,584 public issues in 17 training, fine-tuning and serving repos
480
+ (2024 to 2026), the serving trackers grew 1.58x per month, and inside them the
481
+ fastest-growing classes are the arithmetic ones: parallel config 3.96x,
482
+ quantization / dtype 2.43x, max length and KV cache 2.41x. An empirical study
483
+ of 929 inference-engine bugs (Liu et al., arXiv 2506.09713, ACM TOSEM) puts
484
+ configuration at 23% of root causes. And serving config changes quality
485
+ silently: gpt-oss-120b scored 0.400 against 0.650 on the same weights because
486
+ the repo's Jinja template diverges from the harmony training format
487
+ ([vllm-mlx #568](https://github.com/waybarrios/vllm-mlx/issues/568)); Moonshot
488
+ ships a [vendor verifier](https://github.com/MoonshotAI/K2-Vendor-Verifier)
489
+ for Kimi K2 because hosts mis-set templates, tool-call schemas and sampling.
490
+
491
+ What it checks (exit 1 on any `block`):
492
+
493
+ 1. **Parallel**: TP divides the attention heads; TP past the KV heads
494
+ replicates them (warn) or does not divide them (block); TP divides the FFN
495
+ or expert width, and a block-quantized checkpoint's per-rank slice holds
496
+ whole blocks; TP x PP x DP against `--gpus`; expert parallel against the
497
+ expert count; MoE at TP 4+ without EP (info).
498
+ 2. **Context**: the served length (`--max-model-len`, `--context-length`,
499
+ llama.cpp `-c` per slot) against `max_position_embeddings` scaled by
500
+ `rope_scaling` the way vLLM scales it. vLLM and SGLang refuse to start past
501
+ it, so that is a block; llama.cpp runs with a warning, so that is a warn; a
502
+ learned position table is a block everywhere.
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.
535
+ 5. **Template and sampling**: a missing or overridden chat template; tool
536
+ choice without a parser (vLLM refuses to start); a thinking template with
537
+ no reasoning parser; sampler defaults the engine will apply against
538
+ `generation_config.json` (vLLM reads it by default, `--generation-config
539
+ vllm` turns that off, llama.cpp never reads it); pad == eos; BOS added twice;
540
+ a short cited list of reported mismatches (gpt-oss Jinja vs harmony, Kimi K2
541
+ tool calls, Qwen3 greedy decoding).
542
+ 6. **Change** (`--against <old-model>`): which config keys, template and
543
+ recommended sampling changed, and the memory numbers recomputed for both
544
+ under the same flags.
545
+
546
+ Qwen3-8B on four L4s, with a length past the model and a batch the cache cannot hold:
547
+
548
+ ```
549
+ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu l4 --gpus 4 -- vllm serve Qwen/Qwen3-8B --tensor-parallel-size 4 --max-model-len 65536 --max-num-seqs 256
550
+ Qwen/Qwen3-8B on vLLM
551
+ TP 4 x PP 1 x DP 1, 4 x l4 (sm89), dtype bf16, weights unquantized, KV cache auto
552
+ served length 65536 (--max-model-len 65536); the model's derived maximum 40960
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
566
+ weights: 2 bytes per parameter (16-bit)
567
+ card total: derived: nvidia-smi 23034 MiB less the 468 MiB gap measured on H100
568
+
569
+ block Served length 65536 is past the model's 40960-token context
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.
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).
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.
575
+ info The template has a thinking block and no --reasoning-parser is set
576
+ The reasoning text comes back inside message.content instead of reasoning_content, which breaks clients that hide or strip it.
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.
582
+
583
+ checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, context, quant-support, memory, memory-fit, chat-template, recipe, sampler
584
+ ```
585
+
586
+ The FP8 build of Qwen3-30B-A3B at TP 4: the experts are 768 wide, a quarter is
587
+ 192, and the checkpoint's FP8 blocks are 128 wide:
588
+
589
+ ```
590
+ $ npx neurarch serve-check Qwen/Qwen3-30B-A3B-FP8 --gpu h100 --gpus 4 -- vllm serve Qwen/Qwen3-30B-A3B-FP8 --tensor-parallel-size 4 --max-model-len 32768
591
+ Qwen/Qwen3-30B-A3B-FP8 on vLLM
592
+ TP 4 x PP 1 x DP 1, 4 x h100-sxm (sm90), dtype bf16, weights fp8, KV cache auto
593
+ served length 32768 (--max-model-len 32768); the model's derived maximum 40960
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
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")
610
+
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
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").
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)
615
+ info MoE with 128 experts at TP 4 without expert parallelism
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.
617
+ fix: Try --enable-expert-parallel (EP = TP x DP) and compare throughput.
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.
626
+
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).
629
+ ```
630
+
631
+ The same MoE at TP 8, past its 4 KV heads:
632
+
633
+ ```
634
+ $ npx neurarch serve-check Qwen/Qwen3-30B-A3B --gpu h100 --gpus 8 -- vllm serve Qwen/Qwen3-30B-A3B --tensor-parallel-size 8 --max-model-len 32768
635
+ Qwen/Qwen3-30B-A3B on vLLM
636
+ TP 8 x PP 1 x DP 1, 8 x h100-sxm (sm90), dtype bf16, weights unquantized, KV cache auto
637
+ served length 32768 (--max-model-len 32768); the model's derived maximum 40960
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
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))
655
+
656
+ warn TP 8 is past 4 KV heads: each KV head is replicated 2x
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.
658
+ fix: TP 4 with DP 2 serves more sequences on the same GPUs, if the weights fit at TP 4.
659
+ info MoE with 128 experts at TP 8 without expert parallelism
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.
661
+ fix: Try --enable-expert-parallel (EP = TP x DP) and compare throughput.
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.
671
+
672
+ checked: gpu-count, tp-heads, tp-kv-heads, tp-ffn, expert-parallel, context, quant-support, memory, memory-fit, chat-template, recipe, sampler
673
+ ```
674
+
675
+ FP8 on an A100 (sm80): it loads, as weight-only:
676
+
677
+ ```
678
+ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu a100-40g -- vllm serve Qwen/Qwen3-8B --quantization fp8 --max-model-len 32768 --reasoning-parser qwen3
679
+ Qwen/Qwen3-8B on vLLM
680
+ TP 1 x PP 1 x DP 1, 1 x a100-40g (sm80), dtype bf16, weights fp8, KV cache auto
681
+ served length 32768 (--max-model-len 32768); the model's derived maximum 40960
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
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
698
+
699
+ warn fp8 on A100 (40 GB) (sm80) is not native: it runs on a fallback kernel
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.
701
+ fix: Expect the memory saving and not the speedup; for native fp8 use an sm89+ card.
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/)
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.
708
+
709
+ checked: gpu-count, tp-heads, tp-kv-heads, context, quant-support, memory, memory-fit, chat-template, recipe, sampler
710
+ ```
711
+
712
+ gpt-oss-20b (MXFP4 experts) on an A100. Current vLLM runs it there through the
713
+ Marlin MXFP4 kernel, so this is a warn and not a block; on a T4 it is a block:
714
+
715
+ ```
716
+ $ npx neurarch serve-check openai/gpt-oss-20b --gpu a100-80g -- vllm serve openai/gpt-oss-20b --max-num-seqs 64
717
+ openai/gpt-oss-20b on vLLM
718
+ TP 1 x PP 1 x DP 1, 1 x a100-80g (sm80), dtype bf16, weights mxfp4, KV cache auto
719
+ served length 131072 (not set: the engine derives it from the config); the model's derived maximum 131072
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
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)
736
+
737
+ warn mxfp4 on A100 (80 GB) (sm80) is not native: it runs on a fallback kernel
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.
739
+ fix: Expect the memory saving and not the speedup; for native mxfp4 use an sm90+ card.
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)
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.
743
+ fix: Set the flag to what fits (18), shorten the max length, use an fp8 KV cache, or add GPUs as DP replicas.
744
+ info gpt-oss: the Jinja chat template in the repo was reported to diverge from the harmony training format (not vLLM)
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.
746
+ fix: No change needed on this engine; keep it in mind if the deployment moves.
747
+ source: github.com/waybarrios/vllm-mlx/issues/568; vLLM gpt-oss recipe (openai-harmony rendering)
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.
751
+
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
753
+ ```
754
+
755
+ llama.cpp with `-c` past the model's context, and llama.cpp's own sampling
756
+ defaults against the model's:
757
+
758
+ ```
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
760
+ Qwen/Qwen3-8B on llama.cpp
761
+ 1 x l4 (sm89), weights Q4_K_M, KV cache q8_0/q8_0
762
+ served length 65536 (-c 65536 (one unified KV buffer, so one sequence may use all of it)); the model's derived maximum 40960
763
+
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
765
+ 78,336 KV bytes per token; one full-length sequence 5.13 GB
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
767
+
768
+ warn Served length 65536 is past the model's 40960-token context
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.
770
+ fix: Serve at most 40960, or add rope scaling where the model card supports it, with the card's own original length (e.g. --rope-scaling yarn --rope-scale F --yarn-orig-ctx N, with N x F >= 65536; N is the native length the card states, which can be below max_position_embeddings).
771
+ warn Sampling defaults differ from the model's generation_config.json: temperature 0.8, top_k 40
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).
773
+ fix: Pass --temp 0.6 --top-p 0.95 --top-k 20 (llama.cpp does not read generation_config.json).
774
+ source: kimi.com/blog/kimi-vendor-verifier
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.
778
+
779
+ checked: context, gguf-header, memory, memory-fit, chat-template, sampler
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.
781
+ not checked: quant-support: llama.cpp's CUDA backend runs every GGUF type on these cards; support is not a per-architecture table.
782
+ ```
783
+
784
+ Swapping a model behind the same flags:
785
+
786
+ ```
787
+ $ npx neurarch serve-check Qwen/Qwen3-8B --gpu h100 --against Qwen/Qwen2.5-7B-Instruct -- vllm serve Qwen/Qwen3-8B --max-model-len 32768 --reasoning-parser qwen3
788
+ Qwen/Qwen3-8B on vLLM
789
+ TP 1 x PP 1 x DP 1, 1 x h100-sxm (sm90), dtype bf16, weights unquantized, KV cache auto
790
+ served length 32768 (--max-model-len 32768); the model's derived maximum 40960
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
805
+ weights: 2 bytes per parameter (16-bit)
806
+ card total: vLLM log, llm-d-planner accuracy report (H100-80GB "physical 79.19 GiB")
807
+
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.
813
+ info model_type: qwen2 -> qwen3
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.
815
+ info num_hidden_layers: 28 -> 36
816
+ Layer count changes weights and KV per token; PP stage splits must be redone.
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.
821
+ info num_key_value_heads: 4 -> 8
822
+ KV heads change KV bytes per token and where TP starts replicating KV.
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.
827
+ info vocab_size: 152064 -> 151936
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.
829
+ info max_position_embeddings: 32768 -> 40960
830
+ The longest servable length changes; --max-model-len / --context-length may now be past it or leave length unused.
831
+ info sliding_window: 131072 -> null
832
+ Sliding window changes KV per token at long lengths and which attention backends apply.
833
+ info chat_template: hash 6aca5d55 -> hash 1bae85c9
834
+ Every chat request renders differently: re-render a reference conversation (with tool calls) and re-run the evals that depend on format.
835
+ info generation_config.temperature: 0.7 -> 0.6
836
+ The recommended sampling changes; a gateway that pins the old value now overrides the new model's recommendation.
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.
843
+ info KV bytes per token per GPU: 57,344 -> 147,456
844
+ Same engine flags and card, computed for both models.
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
848
+ Same engine flags and card, computed for both models.
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.
1146
+
254
1147
  ## What it refuses to do
255
1148
 
256
1149
  - **No safetensors index on the Hub** → it prints nothing and says so. A
@@ -272,6 +1165,8 @@ npx neurarch <model-id> # bert-base-uncased, Qwen/Qwen3-8B, ...
272
1165
  npx neurarch <model-id> --layers # every layer, not the first 12
273
1166
  npx neurarch <model-id> --json # machine-readable
274
1167
  npx neurarch rightsize jobs.csv # requested vs needed GPU over past jobs
1168
+ npx neurarch layout <model-id> --tp 4 --pp 4 --dp 8 --global-batch 512 --seq-len 4096 # parallel split check
1169
+ npx neurarch serve-check <model-id> --gpu h100 -- vllm serve <model-id> ... # serving launch check
275
1170
  ```
276
1171
 
277
1172
  Exit code is `1` when the model cannot be read or a check blocks, `0`
@@ -282,9 +1177,9 @@ Set `HF_TOKEN` to read a gated repo. The token is sent only to
282
1177
 
283
1178
  ## Related
284
1179
 
285
- - <https://neurarch.com/compare> — the same comparison for two models, in a
1180
+ - <https://neurarch.com/compare>: the same comparison for two models, in a
286
1181
  browser, no account
287
- - `POST https://www.neurarch.com/api/v1/check` — run the checks on a graph of
1182
+ - `POST https://www.neurarch.com/api/v1/check`: run the checks on a graph of
288
1183
  your own
289
- - [`neurarch-lint`](https://www.npmjs.com/package/neurarch-lint) — the same
1184
+ - [`neurarch-lint`](https://www.npmjs.com/package/neurarch-lint): the same
290
1185
  checks against PyTorch source