Archived
arch/common: GLM-5.3's blocks, and f32 scales, MXFP4 experts and sigmoid routing in the shared ones
New blocks: mHC (rad_block_mhc.h), KDA and its state (rad_block_glm_kda.h, rad_block_kda_state.h), absorbed MLA over a latent cache (rad_block_glm_mla.h, rad_block_mla_latent.h), the DSA indexer and its paged key cache (rad_block_glm_indexer.h, rad_block_dsa_cache.h), the correction-bias router (rad_block_glm_router.h), and rad_tp_split.h: a replicated f32 projection computed column-split over the ranks and all-gathered, so every value is the replicated one's bits (from RADIANCE_GLM_TP_SPLIT_ROWS rows, 256 by default). The shared blocks gain what GLM's checkpoint stores, each off unless a model asks for it: - LinearFP8 reads a block-fp8 weight whose scale plane is f32 (dtype fp8a8f32), and the import check accepts that form beside bf16 scales. - GateQuantFP8 serves a clamped SwiGLU (swiglu_clamped), optionally fused with its quantiser. - MoeFP8 takes MXFP4 experts (format 8) and block-fp8 experts with f32 scales (format 9), the sigmoid router with f32 weights, an ungated shared arm, the router/scatter fusion and the sort's inverse handed to the gather (moe_scatter_inv, moe_gather_inv) where they resolve. - The MLP's gated fold excludes the forms it cannot serve (f32 scales, a clamped product). share_test checks that KDA's convolution weight shards per head across its three parts at TP4.
This commit is contained in:
1 parent
78c58841bf
commit
544753fc40
13 files changed
+1296
-61
No files matched your search
@@ -60,13 +60,16 @@ struct MlpFP8 {
|
||||
/* The next block absorbs this block's closing all-reduce, so this one must not issue it.
|
||||
* Counterpart of `ar_in`; both sides ask ar_fused_ok(g, T), so they agree. */
|
||||
bool ar_out = false;
|
||||
/* Set before declare: a clamped product (`swiglu_limit`) and its quantiser as one launch
|
||||
* (GateQuantFP8::fuse_clamped). */
|
||||
bool swiglu_quant = false;
|
||||
|
||||
/* `fold`: a predecessor's delta is still in `w.h.x` and this norm does its residual add
|
||||
* (false for the first block of a chain). `add_out`: issue the trailing add here. See
|
||||
* rad_fp8.h. */
|
||||
int declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const Wire& wire,
|
||||
const Src& src, bool fold = false, bool add_out = true,
|
||||
int ar_in = kArNone, bool ar_out_ = false);
|
||||
int ar_in = kArNone, bool ar_out_ = false, double swiglu_limit = 0);
|
||||
void step(RadCtx* c, const RadBatch* batch) const;
|
||||
/* The block over the first `T` rows of its buffers (see MoeFP8::step_rows). */
|
||||
void step_rows(RadCtx* c, int64_t T) const { slice(c, T, 0, T); }
|
||||
@@ -76,7 +79,7 @@ struct MlpFP8 {
|
||||
|
||||
inline int MlpFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const Wire& wire,
|
||||
const Src& src, bool fold, bool add_out,
|
||||
int ar_in, bool ar_out_) {
|
||||
int ar_in, bool ar_out_, double swiglu_limit) {
|
||||
g = geom; w = wire; layer = l;
|
||||
ar_out = ar_out_;
|
||||
|
||||
@@ -96,12 +99,16 @@ inline int MlpFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, co
|
||||
* (LinearFP8::reads_x); a block-fp8 down_proj reads only codes and scales. */
|
||||
const char* down_base = nm.f("blk.%d.ffn_down", l);
|
||||
RAD_ARCH_TRY(down.probe(b, nm, g, down_base, { src.down }));
|
||||
RAD_ARCH_TRY(gq_ffn.declare(b, g, w.gate_up, w.ffn, g.n_ff, "silu", 0, down.reads_x));
|
||||
gq_ffn.fuse_clamped = swiglu_quant;
|
||||
RAD_ARCH_TRY(gq_ffn.declare(b, g, w.gate_up, w.ffn, g.n_ff, "silu", 0, down.reads_x,
|
||||
false, swiglu_limit));
|
||||
|
||||
/* The fold (decl_gated_fold), an fp8a8 tile, so bf16, MXFP4, rotated 5-bit, 4-bit and int8
|
||||
* gate_up weights take the pair. Declared over int8 codes, only a host kernel would take it,
|
||||
* and that would pin the layer's weights to the host. */
|
||||
if (!gate_up.bf16 && !gate_up.mx && !gate_up.paro5 && !gate_up.w4 && !gate_up.i8)
|
||||
/* The fold (decl_gated_fold), an fp8a8 tile, so bf16, f32-scaled, MXFP4, rotated 5-bit, 4-bit
|
||||
* and int8 gate_up weights take the pair, and so does a clamped (swiglu_limit) product.
|
||||
* Declared over int8 codes, only a host kernel would take it, and that would pin the layer's
|
||||
* weights to the host. */
|
||||
if (swiglu_limit <= 0 && !gate_up.bf16 && !gate_up.f32_scale && !gate_up.mx &&
|
||||
!gate_up.paro5 && !gate_up.w4 && !gate_up.i8)
|
||||
op_gated = decl_gated_fold(b, g.max_tok, gate_up.N, gate_up.K, gate_up.w, gate_up.ws,
|
||||
{ w.h.q, w.h.s },
|
||||
gq_ffn.want_x
|
||||
|
||||
Reference in new issue
Block a user