Archived
Add Spark rotated-int8 inference and calibration
Serve the Spark X2.6 trunk on IQ8R's rotated int8 grid. Six projection types a layer carry fwht128-rotated int8 weights with a bf16 scale per 128 columns; activations are quantised into the same 128-column groups and feed the `i8a8h` rows, exact GELU runs before the down projection's own Hadamard quantiser, and the embedding, the two norms a layer, the head's norm and the 16-row attention gate stay as they are. The descriptor is `w8a8_fwht128`, and the container says `quantization_config.quant_method=w8a8`, `fmt=fwht128`. `data/recipes/spark-x26-4b-iq8r.recipe` fits those weights by GPTQ against the model's own calibration Hessians, which the BF16 plugin writes as RADGRAM2 files under `RADIANCE_CALIB_DIR`; each layer's f32 [K,K] accumulators are 533 MB, so `RADIANCE_SPARK_CALIB_LAYERS=lo:hi` calibrates a slice at a time into one directory. The output head is RTN. Column-sharded inputs and their offsets must land on whole scale groups, so a rank with an unaligned span is refused rather than served with misaligned scales: TP 1, 2, 4 and 8 align for these shapes, TP 3 does not for the FFN-down shard. Calibration asks for TP=1, because the off-diagonal cross-rank terms only exist on one card. `tests/spark25_iq8r.py` compares a deterministic quantised fixture against the Transformers reference, top-10 probabilities included, across cached decoding; `--tp 2` checks two fake host ranks and `--wide-tp --tp N` the group-aligned attention and FFN shards for N from 1 to 8. Run it under a GPU-denying device cgroup, as with the BF16 fixture. Against this checkpoint's own BF16 container, 32 held-out chat, math, code and tool-call samples and 31,391 positions, greedy with prefix caching off: 98.60% of positions keep their top token, mean KL 0.00408, median 6.5e-5, p99 0.0496, p99.9 0.348, worst 11.88. The tail is the honest part -- 13 positions above one nat -- and leaving the first twelve layers in BF16 takes the worst to 0.247 with nothing above one nat, for about 12% of prefill and 17% of decode. One R9700, zero cached prompt tokens: 11.8k, 11.8k and 11.3k tok/s of prefill at 1.1k, 4.4k and 9.9k-token prompts, 93.7 tok/s of decode from a short prompt and 88.9 with a 4.4k-token context. 8.29 GiB of BF16 weights become 4.52 GiB. That comparison is distribution agreement against BF16, not a task benchmark, and the corpus the Grams came from is public text held disjoint from the holdout by hash; no MMLU or GSM8K-class number is claimed here. The numbers need the prefill softmax scaling per row rather than per wave: while a row's rounding depended on its wave-mates, the quantised container was worse off against BF16 than its own error explains.
This commit is contained in:
1 parent
5d6de60318
commit
cb97b1c886
9 files changed
+974
-44
No files matched your search
+29
-5
@@ -112,11 +112,35 @@ otherwise it fails with `RAD_E_UNSUPPORTED` rather than running rank-local parti
|
||||
serves these collectives at 2, 3, 4 and 8 ranks; other widths resolve only on a library with a
|
||||
general `all_reduce` (libref), so a card deployment is limited to those worlds.
|
||||
|
||||
The initial implementation serves BF16 with tied embeddings, headwise sigmoid gates and the
|
||||
checkpoint's own rotary parameters. It does not implement DSpark, quantisation recipes, other gate
|
||||
activations or rotary-scaling overrides. The tokenizer and its template come from the checkpoint;
|
||||
the architecture declares the `<think>`/`</think>` reasoning markers and the
|
||||
`<tool_call>name<arg_key>...` tool-call format.
|
||||
Both plugins reject multi-rank declarations if a required exact collective cannot be resolved;
|
||||
otherwise a missing reduction would silently leave rank-local projections in the residual.
|
||||
|
||||
The tokenizer and its template come from the checkpoint; the architecture declares the
|
||||
`<think>`/`</think>` reasoning markers and the `<tool_call>name<arg_key>...` tool-call format.
|
||||
DSpark, other gate activations and rotary-scaling overrides are not implemented.
|
||||
|
||||
## Rotated int8 (IQ8R)
|
||||
|
||||
`arch/spark25_w8a8` serves a trunk whose linears use the fwht128-rotated int8 grid: per-128 int8
|
||||
activation codes feed `i8a8h` GEMMs, while the embedding and small per-head gate remain BF16 and
|
||||
normalisation gains remain FP32. Exact GELU runs before the down projection's separate Hadamard quantiser. The output head
|
||||
may be BF16 or a separately quantised int8 table. The descriptor is `w8a8_fwht128`; the container
|
||||
must set `quantization_config.quant_method=w8a8` and `quantization_config.fmt=fwht128`.
|
||||
Column-sharded inputs and their offsets must be whole 128-column scale groups. A rank with an
|
||||
unaligned span is refused, not served with misaligned scales.
|
||||
|
||||
`data/recipes/spark-x26-4b-iq8r.recipe` fits the six trunk projection types against BF16
|
||||
calibration Grams, and quantises the output head with RTN. The BF16 plugin records them with
|
||||
`RADIANCE_CALIB_DIR`, `RADIANCE_CALIB_TOKENS`, and `RADIANCE_SPARK_CALIB_LAYERS=lo:hi`; calibration
|
||||
requires TP=1 to retain off-diagonal cross-rank terms. Drive a representative corpus through
|
||||
prefill with `--no-prefix-cache` and no speculative decoding. Each slice writes six RADGRAM2 files
|
||||
per layer. Calibration completeness is not a measure of quality: compare the resulting container
|
||||
against BF16 on disjoint data, including the tail of the per-position KL distribution.
|
||||
|
||||
`tests/spark25_iq8r.py` compares a deterministic quantised fixture with the Transformers reference,
|
||||
including top-10 probabilities across cached decoding. `--tp 2` checks two fake host ranks, and
|
||||
`--wide-tp --tp N` exercises group-aligned attention and FFN shards for N from 1 to 8. As with the
|
||||
BF16 fixture, run it under a GPU-denying device cgroup on a shared machine.
|
||||
|
||||
For a CPU differential against the reference implementation's `configuration_spark.py` and
|
||||
`modeling_spark.py`, with Python's torch, transformers and safetensors installed:
|
||||
|
||||
Reference in new issue
Block a user