libquant: a column-split linear's Hessian from per-rank parts

Under tensor parallelism an attention output or down projection sees only its rank's K / world
columns, so no rank can write the K x K Gram. A tap may write each rank's block as
<stem>.part; with no whole file calib_sum places the parts on the diagonal in rank order (the
cross-rank products, never formed, zero) and converts the result like a whole file. Parts that
do not cover K, or not in domain 0, are reported and the weight rounds to nearest. Tested
byte for byte against the whole block-diagonal file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mici81andClaude Opus 5.5 authored and StillDeadcode committed 2026-10-19 10:41:22 +02:00
1 parent c94a0e6cc2
commit 400bbefa13
4 files changed
+106 -2

No files matched your search

+8 -1
View File
@@ -51,7 +51,14 @@ std::string calib_resolve(const char* dir, const char* name, int64_t K);
/* Every rank's file for `stem` in `dir`, each converted into `domain` (0, or the Hadamard width a
* rotated grid quantises in), summed into `acc` (K x K, double, row-major). Returns the number of
* files read, 0 when there are none. A file that exists but is unusable (wrong magic, wrong K,
* short, or a domain that cannot be converted) is reported on stderr and skipped. */
* short, or a domain that cannot be converted) is reported on stderr and skipped.
*
* With no whole file, the parts: under tensor parallelism a column-split linear (an attention
* output or down projection) sees only its rank's K / world input columns, so each rank's tap
* writes the Gram of those as `<stem>.part` (gram.r<rank>.<stem>.part.bin). They are placed on
* the diagonal in rank order, the cross-rank products, never formed on one card, left zero. The
* parts must cover K exactly and be in domain 0 (a rotation of K does not keep the blocks); the
* result is then converted into `domain` like a whole file. */
int calib_sum(const char* dir, const std::string& stem, int64_t K, int64_t domain,
std::vector<double>* acc);