Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# hipfire-calib-data
|
| 2 |
+
|
| 3 |
+
Native BF16-teacher calibration artifacts (`.calib.hfq`) and fixed KLD
|
| 4 |
+
reference tensors (`.ref_*.bin`) produced by the hipfire quantization-quality
|
| 5 |
+
campaign. One folder per architecture.
|
| 6 |
+
|
| 7 |
+
Produced on an AMD MI300X (`gfx942`, CDNA3). **All scoring was performed
|
| 8 |
+
elsewhere** (`gfx1201`); the MI300X was a producer only, because uncalibrated
|
| 9 |
+
MQ4 is degenerate on gfx942.
|
| 10 |
+
|
| 11 |
+
## `.calib.hfq` — HFQM calibration package
|
| 12 |
+
|
| 13 |
+
```
|
| 14 |
+
header 32B: magic "HFQM" | version u32=1 | arch_id u32 | n_entries u32
|
| 15 |
+
| metadata_offset u64 | data_offset u64
|
| 16 |
+
metadata: self-delimited JSON blob
|
| 17 |
+
index: n_entries u32 | per-entry { name_len u16 | name | quant_type u8
|
| 18 |
+
| n_dims u8 | shape[n_dims u32] | group_size u32 | data_size u64 }
|
| 19 |
+
payloads: concatenated, in index order, from data_offset
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
Each tensor contributes two entries: `<name>.hessian` and `<name>.imatrix`.
|
| 23 |
+
A 496-tensor model therefore has `n_entries = 992`.
|
| 24 |
+
|
| 25 |
+
### Hessian storage: `Bf16TrilDiagF32` (quant_type 130)
|
| 26 |
+
|
| 27 |
+
Per Hessian, `K*4 + K*(K-1)/2 * 2` bytes:
|
| 28 |
+
|
| 29 |
+
- **diagonal** — exact `f32`, `K * 4` bytes
|
| 30 |
+
- **strict lower triangle** — `bf16`, mirrored on read, index `i*(i-1)/2 + j` for `i > j`
|
| 31 |
+
|
| 32 |
+
`bf16` conversion is **truncation** (`f32_bits >> 16`), not round-to-nearest.
|
| 33 |
+
|
| 34 |
+
These are full Hessians (`XX^T`), not diagonals. A 496-tensor 27B package is
|
| 35 |
+
~31.5 GB, averaging ~63 MB per Hessian; a diagonal-only package would be ~10 MB
|
| 36 |
+
total.
|
| 37 |
+
|
| 38 |
+
## REQUIRED: project to PSD before Cholesky
|
| 39 |
+
|
| 40 |
+
**Reading a stored Hessian and running Cholesky directly will fail on roughly
|
| 41 |
+
half of all tensors.** This is measured, not theoretical.
|
| 42 |
+
|
| 43 |
+
`bf16` off-diagonals perturb the Gram matrix out of positive-semidefiniteness by
|
| 44 |
+
an amount comparable to `mean(diag(H))`. Measured on
|
| 45 |
+
`layers.1.linear_attn.in_proj_qkv` (K=5120) of the Qwen3.8-27B package:
|
| 46 |
+
|
| 47 |
+
| quantity | value |
|
| 48 |
+
|---|---|
|
| 49 |
+
| `mean(diag(H))` | 9.951136e-01 |
|
| 50 |
+
| off-diagonal RMS | 7.889832e-01 |
|
| 51 |
+
| Cauchy-Schwarz violations | **0 / 1,047,552** |
|
| 52 |
+
| leading 1024x1024 `lambda_min` | **-2.088e-01** (353 of 1024 eigenvalues negative) |
|
| 53 |
+
| negative eigenvalue energy | **0.99%** of positive |
|
| 54 |
+
|
| 55 |
+
Zero Cauchy-Schwarz violations means the data is structurally sound — this is
|
| 56 |
+
precision noise, not corruption or a normalization error.
|
| 57 |
+
|
| 58 |
+
Because `lambda_min` scales roughly as `sqrt(K)`, failure is K-dependent:
|
| 59 |
+
|
| 60 |
+
| K | `-lambda_min / mean(diag)` | observed GPTQ outcome |
|
| 61 |
+
|---|---|---|
|
| 62 |
+
| 5120 | ~1.0 | ~50% of tensors fail Cholesky |
|
| 63 |
+
| 6144 | ~1.1 | passes only at near-max damping, correction collapses to ~0 |
|
| 64 |
+
| 17408 | ~1.8 | fails always |
|
| 65 |
+
|
| 66 |
+
Raising the damping cap is **not** a fix: once `damp ~ mean(diag(H))`,
|
| 67 |
+
`H + damp*I` is diagonal-dominated and GPTQ degenerates to round-to-nearest.
|
| 68 |
+
|
| 69 |
+
### The fix
|
| 70 |
+
|
| 71 |
+
Eigendecompose, clip negative eigenvalues to zero, rebuild:
|
| 72 |
+
|
| 73 |
+
```python
|
| 74 |
+
evals, evecs = numpy.linalg.eigh(H)
|
| 75 |
+
H = (evecs * numpy.clip(evals, 0.0, None)) @ evecs.T
|
| 76 |
+
H = (H + H.T) / 2
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
Measured effect on the tensor above:
|
| 80 |
+
|
| 81 |
+
| | Cholesky succeeds at damp |
|
| 82 |
+
|---|---|
|
| 83 |
+
| raw stored | 1.0065 (exceeds a `1.0 * mean(diag)` cap, so it fails) |
|
| 84 |
+
| PSD-projected | **0.01** |
|
| 85 |
+
|
| 86 |
+
The projection changes the matrix by **0.1004%** (relative Frobenius), which is
|
| 87 |
+
*below* `bf16`'s own ~0.391% quantization step. It removes less than the storage
|
| 88 |
+
format already discarded: denoising, not signal loss. Cost is one `O(K^3)`
|
| 89 |
+
eigendecomposition per tensor — the same order as the Cholesky it enables.
|
| 90 |
+
|
| 91 |
+
## `.ref_*.bin` — KLD reference tensors
|
| 92 |
+
|
| 93 |
+
Fixed teacher logits for paired KLD/PPL scoring. **top-k 256, not
|
| 94 |
+
full-vocabulary**, so absolute KLD values are *not* comparable to
|
| 95 |
+
`llama.cpp --kl-divergence` tables. Relative ranking within this instrument is
|
| 96 |
+
valid; absolute cross-table comparison is not. Oracle NLL/PPL were computed from
|
| 97 |
+
full-vocab teacher logits before top-k serialization.
|
| 98 |
+
|
| 99 |
+
Protocol: `n_ctx` 2048, 24 chunks, prefill scoring mode.
|
| 100 |
+
|
| 101 |
+
| suffix | corpus |
|
| 102 |
+
|---|---|
|
| 103 |
+
| `ref_wt2` | WikiText-2 — prose. An out-of-distribution tripwire. |
|
| 104 |
+
| `ref_v6sel` | Held-out rendered chat-template conversations, 0% prose. |
|
| 105 |
+
| `ref_ag` | AG News. |
|
| 106 |
+
|
| 107 |
+
**A prose reference alone is insufficient for a chat model.** It compresses arm
|
| 108 |
+
margins by roughly 3x relative and can invert a PPL ranking. Score against a
|
| 109 |
+
deployment-distribution reference alongside the prose tripwire.
|