Archived
libxe2, arch/common: the 28 Oct pending set, the bf16 cast fused, the vectorized norm, a draft-vocab prefix
- gdn_kkt_solve on DPAS (~0.4 ms at 2048 tokens against 7.7), the int8 head's DPAS forms at 9-16 rows (verify past depth 7), the plain block norm (RadBuildCtx::plain_norm, set on the SYCL backend: `add` + `rmsnorm` where no reader takes the E4M3 codes) with the fast rmsnorm rows. - rmsnorm's bf16 rows up to 8192 wide: a work-item eight elements by one 16-byte load (the generic form walked 20 dependent loads a work-item): 24.7 -> 3.3 us a decode norm, ~3.5 ms a round. - w4a16: a bf16 activation narrowed to fp16 at the kernel's own load (the separate cast launch before every GEMM is gone), bit for bit the same. - RADIANCE_MTP_DRAFT_VOCAB=N: the 2-bit draft head over the vocabulary's first N ids (a prefix shortlist, GRIMOIRE's idea); the u2 layout hook takes an op N below the weight's rows. 131072: greedy acceptance identical on the decode proxy, draft head 650 -> 351 us a pass. KL against the exact-kernel reference (2002 positions): 0.002386, top-1 97.30% (was 0.002376 / 96.80%). Decode proxy (greedy, depth 5, mtp4): 72.0 -> 74.3 tok/s with the prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7580ec3d17
commit
726e532114
18 files changed
+472
-54
No files matched your search
@@ -382,6 +382,13 @@ struct NormQuantFP8 {
|
||||
rad_op op_arn6 = 0;
|
||||
/* The ops write had_quant_act_i8g's rotated int8 codes into the int8 pair (ActFP8::q8_rot). */
|
||||
bool hi8 = false;
|
||||
/* Set by the block before declare when Geom::plain_norm is on, no all-reduce is fused into
|
||||
* this norm, and no reader takes `a`'s code pair (LinearFP8::codes_free): the norm runs as
|
||||
* `add` (`op_add`, the residual stored before the variance reads it, as rmsnorm_quant_fp8
|
||||
* stores it) then `rmsnorm` into `a.x` -- rmsnorm_quant_fp8's residual and bf16 output,
|
||||
* without the codes. */
|
||||
bool x_only = false;
|
||||
rad_op op_add = 0;
|
||||
Geom gm{};
|
||||
/* The row width, for turning a row slice into element offsets. */
|
||||
int64_t n = 0;
|
||||
@@ -418,6 +425,24 @@ inline int NormQuantFP8::declare(RadBuilder* b, const Geom& g, rad_weight gain,
|
||||
"linears are bf16; its blocks take a prepared input instead\n");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
if (x_only) {
|
||||
if (fuse_ar != kArNone || !src || !a.x || !w || n <= 0) return RAD_E_INVAL;
|
||||
const int64_t rows = max_rows > 0 ? max_rows : g.max_tok;
|
||||
if (res) {
|
||||
op_add = rw(b, RAD_OP(b, "add",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{ src, res }, { res });
|
||||
if (!op_add) return RAD_E_INVAL;
|
||||
}
|
||||
op = rw(b, RAD_OP(b, "rmsnorm",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n), RAD_F64("eps", g.eps),
|
||||
RAD_F64("wadd", g.wadd), RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(w)),
|
||||
{ res ? res : src }, { a.x });
|
||||
return op ? RAD_OK : RAD_E_INVAL;
|
||||
}
|
||||
/* Rotated int8 codes (ActFP8::q8_rot) come from the `_had_quant_i8g` twins, into the int8
|
||||
* pair; the model checked they are declared before feeding. Otherwise E4M3, as always. */
|
||||
hi8 = a.q8_fed && a.q8_rot;
|
||||
@@ -493,6 +518,14 @@ inline void NormQuantFP8::step_plain(RadCtx* c, int64_t T, int64_t r0, int64_t r
|
||||
* different summation order would run. */
|
||||
inline void NormQuantFP8::step(RadCtx* c, int64_t T, int64_t r0, int64_t rows) const {
|
||||
if (rows <= 0) rows = T - r0;
|
||||
if (x_only) {
|
||||
if (op_add)
|
||||
RAD_ISSUE_N(c, op_add, rows, brow_slice(src, r0, rows, n), brow_slice(res, r0, rows, n),
|
||||
brow_slice(res, r0, rows, n));
|
||||
RAD_ISSUE_N(c, op, rows, brow_slice(res ? res : src, r0, rows, n), RAD_W(w),
|
||||
brow_slice(a.x, r0, rows, n));
|
||||
return;
|
||||
}
|
||||
RAD_ISSUE_N(c, pick(rows), rows, brow_slice(src, r0, rows, n),
|
||||
res ? brow_slice(res, r0, rows, n) : RAD_NONE, RAD_W(w),
|
||||
brow_slice(hi8 ? a.q8 : a.q, r0, rows, n),
|
||||
@@ -777,6 +810,11 @@ struct LinearFP8 {
|
||||
* declared. A producer writes the bf16 plane only when asked, so the block must ask for it when
|
||||
* this is set; otherwise the linear reads unwritten arena bytes. */
|
||||
bool reads_x = false;
|
||||
/* Whether it reads the bf16 plane alone and never the producer's code pair: a 4-bit weight
|
||||
* (cast or quantised from the plane by its own op) or a plain bf16 one. Known from probe();
|
||||
* a block norm all of whose readers are code-free may skip the quantiser
|
||||
* (NormQuantFP8::x_only). */
|
||||
bool codes_free = false;
|
||||
bool mapped = false; /* probe() made the name map; declare() does not make it again */
|
||||
/* The stored weight this linear's views take when it is not `<base>.weight`: a second linear
|
||||
* over one container entry, e.g. a whole projection beside its tensor-parallel slice. Set
|
||||
@@ -1082,6 +1120,7 @@ inline int LinearFP8::probe(RadBuilder* b, Names& nm, const Geom& g, const char*
|
||||
const bool rotated = known && (linear_is_paro_mxfp4(enc) || linear_is_paro_w5(enc) ||
|
||||
linear_is_paro_m2xfp4(enc));
|
||||
reads_x = g.w_bf16 || plain || probed_i8 || rotated || (known && linear_is_w4(enc));
|
||||
codes_free = plain || (known && linear_is_w4(enc));
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user