gpu-head-to-head
aien-dev/gpu-head-to-head
Brought by drakestapleton
gpu-head-to-head / q35-9b / ORDERED-WEIGHTS.md
| 1 | # Ordered weight verification |
| 2 | |
| 3 | The old sorted-value checks remain historical evidence. They cannot establish |
| 4 | the tensor layout: see `results/WEIGHTS.md.correction.json` and its Wolfram |
| 5 | counterexample. This check compares named tensors at their expected positions. |
| 6 | |
| 7 | The converter reference is llama.cpp |
| 8 | `7aca0d2ea8d92b56911233b822db01f9fbb1ae50`, particularly |
| 9 | `conversion/qwen.py` and `gguf-py/gguf/tensor_mapping.py`. The checker validates |
| 10 | Q/K prefixes, grouped-to-tiled V-head rows, output-projection columns, conv1d |
| 11 | channels, scalar head parameters, widening and zero-centred norm folding. |
| 12 | Unknown names, types, shapes, malformed lengths and missing coverage refuse the |
| 13 | check. Model files are opened read-only. |
| 14 | |
| 15 | `tools/weight-files.mjs` and `tools/ordered-weights.mjs` only catalogue and move |
| 16 | bytes. Arithmetic transformations call existing seeded-Omega `bin`/`sexp` units |
| 17 | through `weight-numeric-glue.c`. For the exact converter exponential, the final |
| 18 | check uses the pinned converter's ATen CPU `exp` through `torch-cpu-exp.cpp`. |
| 19 | This is an independent verification oracle, never an engine/build dependency. |
| 20 | No Python process or GPU model is started by that helper. The library does link |
| 21 | libcudart; this is not a claim that its process has no NVIDIA libraries. |
| 22 | |
| 23 | The verification dependency is Torch `2.14.0a0+b2c75dd062.nv26.09` in image digest |
| 24 | `557747337846eecf34486866f3d992383c6f8af869fdb0e365b5093fcaee02c2`. |
| 25 | Its role is to reproduce the converter's CPU numerical function. No Omega |
| 26 | replacement is planned for this independent oracle. Production remains outside |
| 27 | this check. Build logs record the host/container compilers and binary hashes. |
| 28 | |
| 29 | The initial Omega exponential reference differs from the converter's values by |
| 30 | at most one binary32 ULP in the observed inputs, as calculated by the retained |
| 31 | Wolfram query `exp-oracle-difference.wl`. That attempt remains a mismatch record. |
| 32 | No tolerance was widened: the final comparison uses exact bytes from the pinned |
| 33 | converter library. Both numeric helpers also match the retained independent |
| 34 | Wolfram control vectors and refuse malformed byte inputs. |
| 35 | |
| 36 | ## Reproduce |
| 37 | |
| 38 | Use the same pinned model files and compiler/bridge/backend artifacts recorded |
| 39 | in `resumption.json`. Build the verifier against that Omega kernel object: |
| 40 | |
| 41 | ```sh |
| 42 | sh q35-9b/tools/build-weight-oracles.sh NEW_ORACLE_DIR /absolute/path/omega_ggml_kernels.o |
| 43 | node --test q35-9b/tools/test-ordered-weights.mjs |
| 44 | STACK_TORCH_ORACLE_DIR=/absolute/NEW_ORACLE_DIR node q35-9b/tools/ordered-weights.mjs \ |
| 45 | HF_DIR BF16_GGUF NEW_ORACLE_DIR/weight-numeric-glue NEW_REPORT.json \ |
| 46 | --negexp-helper="$PWD/q35-9b/tools/torch-cpu-exp.sh" |
| 47 | ``` |
| 48 | |
| 49 | The build and report refuse existing outputs. The optional `--only=NAME` is a |
| 50 | partial diagnostic and never returns a whole-model verdict. `--mutant-order` |
| 51 | deliberately leaves the original head order in the expected buffer; it preserves |
| 52 | the values but must fail against a genuinely reordered target tensor. |
| 53 | |
| 54 | ## Observed scope |
| 55 | |
| 56 | The source-bound local report `ordered-weight-check-3.json` compares all 427 |
| 57 | named text tensors exactly, with no mismatches. The 15 GGUF MTP tensors are |
| 58 | explicitly excluded from plain decoding, as in the original protocol; image and |
| 59 | MTP source tensors are separately listed. The real-tensor wrong-order mutant |
| 60 | for `blk.0.attn_qkv.weight` fails the intended byte comparison. Synthetic parser, |
| 61 | mapping and corruption controls pass. |
| 62 | |
| 63 | This verifies the named file transformations for the pinned checkpoint. It does |
| 64 | not prove every inference operation, full backend model qualification, output |
| 65 | correctness, deployment, or performance. Those gates remain separate. |