core/format, tools: GGUF Q8_0, Q4_K and Q6_K tensors import as their planes -- rad-convert writes them without a recipe

A GGUF tensor of block type Q8_0, Q4_K or Q6_K could only be dequantised, so rad-convert reached it
through a recipe rule and re-quantised what was already quantised. ckpt_resolve now states the
planes libquant's ggml quantiser writes for the same blocks and marks the weight imported, and
ckpt_plane_rows splits each row's blocks into them bit for bit. The split is
core/format/ggml_planes.h, the reader's copy of lq_ggml's unpack functions, since the core cannot
call libquant; a type there is one table row, its planes and its split. Pieces of one block type
joined along rows import, an expert's slices of a stacked tensor included; mixed types and column
joins keep a GGUF reason.

The weight is not trivial, so the loader refuses it with the hint to serve the container
rad-convert writes, and ckpt_rows_f32 still dequantises it for a recipe. A rule that declines such
a weight is an error in rad-convert, since keeping its planes would hide that the rule did not
apply (spec.md §4.4).

Tests: quant_ggml_test holds every type of the reader's table to the quantiser's encoding,
checkpoint_test decodes the planes of Q8_0, Q4_K (one-block rows and a row join) and Q6_K against
the block definition and holds an expert's gate|up, two slices of stacked Q4_K tensors, to the same
blocks stored on their own, and convert_test runs a declining rule over a Q8_0 tensor, with the
GGUF writer moved to tests/gguf_writer.h for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NunzeandClaude Opus 5.5 authored and StillDeadcode committed 2026-10-28 12:48:13 +01:00
1 parent 6f034d989f
commit 385318f81a
10 files changed
+602 -57

No files matched your search

+4 -2
View File
@@ -589,8 +589,10 @@ int main(int argc, char** argv) {
const RadQuantWeight qw = quant_weight(L, nullptr);
const int st = L.rule->q->encoding(L.rule->params.data(), (int)L.rule->params.size(),
&qw, &L.enc);
if (st == RAD_E_UNSUPPORTED && (L.src.trivial || L.src.imported)) {
/* declined (e.g. a norm under a matrix pattern): keep as is */
if (st == RAD_E_UNSUPPORTED &&
(L.src.trivial || (L.src.imported && !L.src.ggml_blocks))) {
/* declined (e.g. a norm under a matrix pattern): keep as is. Not a GGUF block
* tensor: keeping its planes would hide that the rule did not apply. */
L.rule = nullptr;
L.enc = L.src.enc;
} else if (st != RAD_OK) {