Archived
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:
1 parent
6f034d989f
commit
385318f81a
10 files changed
+602
-57
No files matched your search
@@ -10,6 +10,7 @@
|
||||
* The error bounds carry margin and catch a wrong plane layout, which decodes to noise.
|
||||
*/
|
||||
#include "quant_fixture.h"
|
||||
#include "format/ggml_planes.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -134,6 +135,24 @@ TEST(ggml_writes_each_type_as_its_affine_planes) {
|
||||
}
|
||||
}
|
||||
|
||||
/* The core cannot call libquant, so a GGUF is read through its own copy of the encodings
|
||||
* (core/format/ggml_planes.h); this holds every type of the copy to the quantiser's. */
|
||||
TEST(the_reader_names_the_planes_the_quantiser_writes) {
|
||||
NEED_LIBQUANT();
|
||||
const RadQuantizerInfo* q = quantizer("ggml");
|
||||
REQUIRE(q != nullptr);
|
||||
for (const ggml_planes::Type& t : ggml_planes::kTypes) {
|
||||
Opts o;
|
||||
o.s("type", gguf_dtype(t.ggml)->name);
|
||||
const RadQuantWeight qw = weight_of("w", 4, 512, nullptr);
|
||||
RadEncoding written, read;
|
||||
REQUIRE_EQ(q->encoding(o.data(), o.n(), &qw, &written), RAD_OK);
|
||||
REQUIRE(ggml_plane_encoding(t.ggml, &read));
|
||||
CHECK_EQ(enc_name(read), enc_name(written));
|
||||
CHECK(rad_enc_equal(&read, &written));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(every_type_decodes_within_its_bound) {
|
||||
NEED_LIBQUANT();
|
||||
const int64_t C = 1024;
|
||||
|
||||
Reference in new issue
Block a user