Archived
libquant: review fixes -- loops kept as the LAPACK reference (RAD_LQ_LAPACK=0) and tested against it, NaN pivots refused, 4 layer factors kept
The single-threaded loops stay beside LAPACK; RAD_LQ_LAPACK=0 takes them and gptq_through_lapack_matches_the_loops compares the two (output error equal to rounding). A factor whose diagonal is not finite and positive is refused, as the loops refused a NaN pivot that dpotrf lets through. The cache keeps the 4 most recent layer factors: a MoE layer's experts alternate between two stems. The size in the comment is the f32 factor's, 1.85 GB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
400bbefa13
commit
cec70ad1c7
2 files changed
+97
-16
No files matched your search
@@ -272,6 +272,34 @@ TEST(an_expert_reads_its_own_hessian_before_its_layers) {
|
||||
CHECK(same_planes(run(both, e11), run(only_pool, e11)));
|
||||
}
|
||||
|
||||
TEST(gptq_through_lapack_matches_the_loops) {
|
||||
/* Where OpenBLAS was found the factorisations go through LAPACK; RAD_LQ_LAPACK=0 takes the
|
||||
* single-threaded loops, the reference. The same Gram in two directories (the factor cache is
|
||||
* keyed by directory), one run each way: the output error agrees to rounding. Codes may
|
||||
* differ where error feedback lands on a rounding boundary. Without OpenBLAS both runs take
|
||||
* the loops and agree trivially. */
|
||||
NEED_LIBQUANT();
|
||||
const TempDir fast_dir("rad_quant_lapack"), loop_dir("rad_quant_loops");
|
||||
REQUIRE(!fast_dir.path.empty() && !loop_dir.path.empty());
|
||||
REQUIRE(write_gram(fast_dir.path + "/gram.r0.blk.2.attn_q.bin", kC, kT, H()));
|
||||
REQUIRE(write_gram(loop_dir.path + "/gram.r0.blk.2.attn_q.bin", kC, kT, H()));
|
||||
auto run = [&](const std::string& dir) {
|
||||
Opts o;
|
||||
o.s("codes", "i4").i("group", 32).s("scale", "f16").s("calib", dir.c_str());
|
||||
return quantise(quantizer("gptq"), o, kName, kR, kC, weight());
|
||||
};
|
||||
const Quantised fast = run(fast_dir.path);
|
||||
setenv("RAD_LQ_LAPACK", "0", 1);
|
||||
const Quantised loops = run(loop_dir.path);
|
||||
unsetenv("RAD_LQ_LAPACK");
|
||||
REQUIRE_EQ(fast.status, RAD_OK);
|
||||
REQUIRE_EQ(loops.status, RAD_OK);
|
||||
const double ef = out_err(weight(), decode(fast, kR, kC));
|
||||
const double el = out_err(weight(), decode(loops, kR, kC));
|
||||
std::fprintf(stderr, " LAPACK %.9g, loops %.9g\n", ef, el);
|
||||
CHECK(std::fabs(ef - el) <= 1e-6 * el);
|
||||
}
|
||||
|
||||
TEST(a_column_split_hessian_is_assembled_from_its_rank_parts) {
|
||||
/* Under tensor parallelism a down projection's tap sees one rank's K / 2 input columns, and each
|
||||
* rank writes the Gram of its own as `<stem>.part`. GPTQ against the two parts must quantise
|
||||
|
||||
Reference in new issue
Block a user