Validation boundaries / pattern atlas
Three boundaries
Follow container, topology and value checks. Explore 14,512 recorded pattern matches.
for (i = 0; i < header_count; i++)
buf[i] = read_entry(stream);Header count 6, allocated capacity 4: writes 2 cells outside buffer[4] because framing never bounds count against capacity.
for (ax = 0; ax < 4; ax++)
dim = input.dims[ax]; // input carries [N, C] onlyInput shape [N, C] (rank 2) passed to a 4D Conv kernel expecting [N, C, H, W]: missing spatial axes H and W are indexed past input.dims[2].
inv = 1.0f / scale_d;
fn = dispatch_table[k]; // table holds E0..E3Expert index k = 5, scale d = 0.25: indexes past dispatch_table[E0..E3] without a range guard.
- Boundary 01
Container framing
Artifacts .safetensors, .gguf, index.jsonDo the header sizes, offsets and lengths stay inside the file and agree with each other?
Pickle removal acts here. Replacing a pickle-based checkpoint with a tensor-only container removes code execution at load time, which belongs to Boundary 1. Boundaries 2 and 3 are unchanged: a well-formed file can still declare the wrong geometry or carry values that break native code.
Pre-load checksS-0 Span and configuration parity
- Boundary 02
Architecture and graph metadata
Artifacts config.json, generation_config.json, tokenizer.json, GGUF key-value metadataDo tensor names, ranks, element types and dimensions agree with the declared model configuration?
- Boundary 03
Numerical values
Artifacts tensor payloadsAre the stored numbers safe to use as comparison inputs, divisors, sort keys and array indexes in native code?
Pre-load checksB3-1 Reject NaN and infinity in float tensorsB3-2A Reject non-finite block scales; allow finite zero and subnormalsB3-2B Require finite, positive divisor scalesB3-3 Range-check routing and index tensors against a trusted boundB3-Spectral Audit weight matrices for rank-one structure
Select any Class I–IV card to filter the 14,512-match native sink diagram below by its corresponding pattern class:
- Class IComparison sentinel exhaustionRelease abort · 3,638
A search loop starts from -1 and NaN makes every comparison false, so the sentinel is later used as an index.
best = -1; if (NaN > best) false -> table[-1]Rule B3-1 · Reject NaN and infinity in float tensors
- Class IIFloat-to-integer and divisor scaleScale divide & cast · 10,051
A zero, NaN or huge scale reaches a division or a float-to-integer cast whose result is undefined and differs between CPU architectures.
(int32_t)(x / scale_d) where scale_d in {0.0, NaN, 1e38}Rules B3-2A / B3-2B · Require finite positive divisor scales
- Class IIIOrdering and reduction mismatchRelease abort · 3,638
Sorts and running sums assume finite, ordered values; NaN breaks the assumption.
sort([0.4, qNaN, 0.9]) -> broken comparator / prefix sumRule B3-1 · Finite total-order & prefix-sum invariant
- Class IVUnchecked integer routingIndex tensor · 823
A stored integer tensor is used directly as an array subscript or pointer offset without a range check.
expert_offsets[topk_ids[i]] without 0 <= id < num_expertsRule B3-3 · Range-check routing & index tensors
Where stored numbers reach native code
Pattern matches for the four ways a stored number can reach native code unchecked, counted across seven open-source inference and ML source trees. 14,512 matches in all.
Line-oriented pattern matches. They are not bugs and they have not been triaged. A match is a hypothesis. Whether a value in a model file can reach it, and what follows, are separate questions that each need their own check.
- line-oriented heuristic: macros, templates and cross-function guards are not resolved
- guard_present means a guard-shaped expression appears earlier in the same function scope; it is not a proof that the guard dominates the sink
- a hit is a hypothesis that needs a replay and a read of the source at the site; reachability from a weight file and product impact are separate claims
14,512 / 14,512 pattern matches
All patterns across all seven source trees. Counts are pattern matches; they do not establish reachability or confirmed defects.
Each tree counts as 100, so a large tree does not hide a small one. This view compares the mix of patterns within each tree.
Raw match counts. One tree and one pattern dominate, and that says how much code matches the pattern, not how risky the tree is.
Matches per 1,000 scanned lines. This is pattern density, not risk.
The same counts as a table
| Source tree | Pinned at | Lines | Float to int | Index tensor | Scale divide | Release abort | All | Per 1,000 lines |
|---|---|---|---|---|---|---|---|---|
| llama.cpp (ggml/src) | 223373742b | 266,809 | 210 | 149 | 573 | 1,566 | 2,498 | 9.36 |
| whisper.cpp | 95ea8f9bfb | 506,132 | 242 | 153 | 583 | 1,747 | 2,725 | 5.38 |
| vLLM (csrc) | ee0da84ab9 | 108,017 | 115 | 253 | 36 | 288 | 692 | 6.41 |
| XNNPACK | 0a66ebb581 | 2,990,199 | 7,877 | 105 | 87 | 1 | 8,070 | 2.70 |
| tract | 5b7ef4f8c6 | 222,094 | 138 | 42 | 39 | 20 | 239 | 1.08 |
| SentencePieceincomplete | bcd4d8c92f | 46,629 | 4 | 2 | 0 | 9 | 15 | 0.32 |
| OpenCV (modules/dnn) | 43a4c20ef8 | 264,877 | 121 | 119 | 26 | 7 | 273 | 1.03 |
| All trees | 4,404,757 | 8,707 | 823 | 1,344 | 3,638 | 14,512 |
Each row is a recorded scan of the tree at the upstream commit shown. No file, line or function is published.