Archived
bailing_hybrid: Ling-3.0-flash on an IQ8R trunk
Flash clamps its SwiGLU in its last layers (routed 35-41, shared 34-41). The plugin and MoeFP8's check for int8 activations refused a rotated int8 trunk over them, since the int8 gated products had no clamped form. With the previous commit they have one, so both refusals go. MoeFP8 keeps the refusal for a W5NL down projection: no clamp writes its rotated E4M3 codes. flash_iq8r_clamps_its_gated_products_then_quantises_them_rotated declares flash's IQ8R container at one, two and four ranks, every rank: 15 swiglu_step, each followed by had_quant_act_i8g reading its plane at group 128; against the same container without the clamp lists 15 ops more and 15 gated_had_quant_i8g fewer, and no unrotated int8 or E4M3 quantiser. The steps run lint-clean. It fails without the previous commit. The graph hashes of the bf16 and four-bit containers stay the same. bailing_hybrid_arch_test: 9 of 9 pass; ctest -LE 'gpu|oot': 181 of 181 (3 skipped).
This commit is contained in:
1 parent
2e558e2dcc
commit
33f9644701
5 files changed
+65
-29
No files matched your search
@@ -42,7 +42,8 @@
|
||||
* library serves the rotating norm, each linear quantises the norm's bf16 output itself and
|
||||
* the routed experts read a rotated copy written once a layer. The linears the recipe keeps
|
||||
* bf16 (the KDA beta, the MLA's low-rank q and kv and its head gate) read the norm's bf16
|
||||
* output in either case. Unclamped SwiGLU only: the int8 gated products have no clamped form.
|
||||
* output in either case. A clamped SwiGLU (flash's last layers) writes the bf16 product,
|
||||
* which had_quant_act_i8g quantises: one launch more than the unclamped gated product.
|
||||
* - any other (bf16, the four-bit experts of ling3-w4a8-rtn and ling-3.0-tiny-iq4, the GGUF
|
||||
* releases): the norms write E4M3 codes, each linear reads the bf16 plane or quantises it
|
||||
* itself, and four-bit experts read the E4M3 pair (rotated ones a rotated copy of it).
|
||||
@@ -854,7 +855,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
int64_t shared_g8 = m.trunk_g8;
|
||||
if (m.trunk_rot) {
|
||||
/* The routed experts read the trunk's rotated int8 codes (MoeFP8::a8), which only a
|
||||
* rotated expert meets; and the int8 gated products have no clamped form. */
|
||||
* rotated expert meets. A clamped layer clamps, then quantises (GateQuantFP8). */
|
||||
for (int l = (int)s.dense_layers; l < (int)s.n_layer + (mtp ? 1 : 0); ++l) {
|
||||
const MoeFP8::Config& c = msrc[(size_t)l].cfg;
|
||||
if (c.expert_bf16 || !c.expert_rot) {
|
||||
@@ -864,14 +865,6 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
l, c.expert_bf16 ? "plain bf16" : "unrotated");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
if (c.swiglu_limit > 0 || c.shared_swiglu_limit > 0) {
|
||||
fprintf(stderr, "radiance: bailing_hybrid: layer %d clamps its SwiGLU (routed %g, "
|
||||
"shared %g) and the trunk is rotated int8, whose gated products "
|
||||
"write int8 codes with no clamped form; this checkpoint is served "
|
||||
"with a bf16 or four-bit trunk\n",
|
||||
l, c.swiglu_limit, c.shared_swiglu_limit);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
m.norm_fed = rad_op_declared(b, "rmsnorm_had_quant_i8g") != 0;
|
||||
/* The shared expert's down projection is a trunk linear whose input codes take the group
|
||||
|
||||
@@ -1087,15 +1087,20 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
const bool pair = w.eff.q8 && w.eff.s8 && w.eff.q8_rot && w.eff.g8 == RAD_FP8_BLOCK;
|
||||
const bool down_supported = down_w5_fp8 ? (w.eff.q && w.eff.s && kServed[fmt[1]])
|
||||
: kServed8[fmt[1]] != nullptr;
|
||||
/* A clamped layer is served too: GateQuantFP8 clamps into the bf16 plane, then
|
||||
* quantises it into the rotated codes. Not before a W5NL down projection, which reads
|
||||
* rotated E4M3: no clamp writes those codes. */
|
||||
const bool clamp_w5 = down_w5_fp8 && c.swiglu_limit > 0;
|
||||
if (!pair || !c.expert_rot || !kServed8[fmt[0]] || !down_supported || c.calib ||
|
||||
c.swiglu_limit > 0) {
|
||||
clamp_w5) {
|
||||
fprintf(stderr, "radiance: layer %d: int8 activations meet rotated experts (int8, "
|
||||
"four-bit, or the codebook at E4M3 scales a 64 or 32 of K) through "
|
||||
"rotated codes at one scale a 128 of K, unclamped, outside "
|
||||
"calibration; these are %s / %s%s\n", l,
|
||||
"rotated codes at one scale a 128 of K, outside calibration; these "
|
||||
"are %s / %s%s%s\n", l,
|
||||
kServed[fmt[0]] ? kServed[fmt[0]] : kServed8[fmt[0]],
|
||||
kServed[fmt[1]] ? kServed[fmt[1]] : kServed8[fmt[1]],
|
||||
pair ? "" : ", and the gated product's int8 pair is not that");
|
||||
pair ? "" : ", and the gated product's int8 pair is not that",
|
||||
clamp_w5 ? ", and a W5NL down projection is served unclamped only" : "");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
# conv1d weights, the router, the embedding and the lm_head.
|
||||
#
|
||||
# Serves at --tp 1 or 2: at 4 the dense layer's 1152-column slice cuts a 256-column scale group.
|
||||
# Ling-3.0-flash clamps its SwiGLU in its last layers, which the int8 gated products have no form
|
||||
# for, so this recipe's forms do not serve it.
|
||||
# Ling-3.0-flash clamps its SwiGLU in its last layers; on this trunk those layers write the bf16
|
||||
# product and quantise it after, one launch more a layer (docs/ARCHITECTURES.md).
|
||||
|
||||
blk.*.attn_qkv.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
|
||||
blk.*.attn_forget.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
|
||||
|
||||
@@ -22,7 +22,7 @@ plugin claims.
|
||||
| `arch/clef_fp8` | `clef` | `fp8_e4m3` | the same over `qwen35_fp8`'s trunk |
|
||||
| `arch/qwen4exp_fp8` | `qwen4exp` | *(empty)* | Qwen4-Exp (Qwen3.8-Flash-Next), a bf16 checkpoint quantised at convert (`data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe`) or an AutoRound int4 release (`qwen4exp-autoround-i8-hc8m.recipe`) |
|
||||
| `arch/glm5next` | `glm5next` | *(empty)* | GLM-5.3-Flash: four mHC residual streams over 34 KDA and 11 sparse latent-attention (MLA) layers with a DSA indexer, 288 experts at top-8 under sigmoid routing, attention and dense layers as the container stores them; its MTP layer is a serial drafter. Pictures through its vision tower (`arch/common/rad_block_glm_vision.h`); bf16 KV |
|
||||
| `arch/bailing_hybrid` | `bailinghybrid` | *(empty)* | Ling-3.0-flash and its fine-tunes (Ling-3.0-flash-Sante) from the bf16 checkpoint: 35 KDA and 7 dense latent-attention (MLA) layers with a rotary part and a head-wise gate, 512 experts at top-8 under group-limited sigmoid routing with an ungated shared expert, the routed experts as the recipe stores them (`data/recipes/ling3-w4a8-rtn.recipe`); its MTP layer is a serial drafter; Ling-3.0-tiny from its bf16 checkpoint with an IQ8R trunk and rotated int8 experts (`data/recipes/ling-3.0-tiny-iq8r.recipe`, TP1/2; flash's clamped SwiGLU layers have no int8 form); bf16 KV |
|
||||
| `arch/bailing_hybrid` | `bailinghybrid` | *(empty)* | Ling-3.0-flash and its fine-tunes (Ling-3.0-flash-Sante) from the bf16 checkpoint: 35 KDA and 7 dense latent-attention (MLA) layers with a rotary part and a head-wise gate, 512 experts at top-8 under group-limited sigmoid routing with an ungated shared expert, the routed experts as the recipe stores them (`data/recipes/ling3-w4a8-rtn.recipe`); its MTP layer is a serial drafter; Ling-3.0-tiny from its bf16 checkpoint with an IQ8R trunk and rotated int8 experts (`data/recipes/ling-3.0-tiny-iq8r.recipe`, TP1/2), and flash on the same trunk with rotated experts (its clamped layers clamp, then quantise); bf16 KV |
|
||||
| `arch/bailing_hybrid_gguf` | `bailinghybrid` | `gguf_ftype_25` | Ling-3.0-tiny (24 layers, MLA every fourth with a 256-wide query LoRA, 128 experts of 512 at top-8) as the IQ4_NL GGUF release, its experts re-quantised by `data/recipes/ling-3.0-tiny-iq4.recipe`; no MTP; bf16 KV |
|
||||
| `arch/bailing_hybrid_gguf_q80` | `bailinghybrid` | `gguf_ftype_7` | the same tiny family, Q8_0 GGUF release, served whole |
|
||||
| `arch/bailing_hybrid_gguf_q4km` | `bailinghybrid` | `gguf_ftype_15` | the same tiny family, Q4_K_M GGUF release, served whole |
|
||||
@@ -1149,8 +1149,10 @@ shards the same way; its norms take no collective (each block's all-reduce stays
|
||||
`all_reduce` before the residual add), so no `ar_` norm is declared at two ranks.
|
||||
|
||||
**The trunk's form** is read from layer 0's fused q|k|v. A rotated int8 trunk needs rotated
|
||||
experts (int8 or a rotated four-bit form) and no SwiGLU clamp: the int8 gated products have no
|
||||
clamped form, so flash's clamped layers (routed 35-41, shared 34-41) are refused on it by name.
|
||||
experts (int8 or a rotated four-bit form). Flash's clamped layers (routed 35-41, shared 34-41)
|
||||
write the clamped bf16 product (`swiglu_step`) and quantise it with `had_quant_act_i8g` at the
|
||||
group of the down projection that reads it: one launch more than the unclamped
|
||||
`gated_had_quant_i8g`, in those layers only.
|
||||
Rotated int8 experts under an unrotated trunk are refused too. Where no loaded library serves
|
||||
`rmsnorm_had_quant_i8g` (a CPU-only engine), each int8 linear quantises the norm's bf16 output
|
||||
itself and the routed experts read a rotated int8 copy written once a layer.
|
||||
|
||||
@@ -445,8 +445,8 @@ TEST(bf16_and_four_bit_containers_keep_their_graphs) {
|
||||
}
|
||||
|
||||
/* What the plugin refuses by name: a rotated trunk over unrotated experts, rotated int8 experts
|
||||
* under an unrotated trunk, an IQ8R trunk over a clamped SwiGLU (flash's last layers), and the
|
||||
* tiny IQ8R trunk at four ranks, whose 1152-column dense slice cuts a 256-column scale group. */
|
||||
* under an unrotated trunk, and the tiny IQ8R trunk at four ranks, whose 1152-column dense slice
|
||||
* cuts a 256-column scale group. */
|
||||
TEST(refuses_mismatched_forms) {
|
||||
{
|
||||
MetaKV mk = tiny_meta();
|
||||
@@ -468,14 +468,6 @@ TEST(refuses_mismatched_forms) {
|
||||
CHECK_EQ(stderr_of_rc([&] { return bailing_hybrid::declare(&b, mk.meta(), &ctx); }),
|
||||
RAD_E_UNSUPPORTED);
|
||||
}
|
||||
{
|
||||
MetaKV mk = flash_meta();
|
||||
RadBuilder b;
|
||||
iq8r_encs(&b);
|
||||
RadBuildCtx ctx = build_ctx();
|
||||
CHECK_EQ(stderr_of_rc([&] { return bailing_hybrid::declare(&b, mk.meta(), &ctx); }),
|
||||
RAD_E_UNSUPPORTED);
|
||||
}
|
||||
{
|
||||
MetaKV mk = tiny_meta();
|
||||
RadBuilder b;
|
||||
@@ -509,6 +501,50 @@ TEST(flash_iq8r_without_clamps_declares_its_drafter_on_the_int8_trunk) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Flash's IQ8R trunk with its clamp lists declares at one, two and four ranks. Each clamped gated
|
||||
* product (routed in layers 35-41, shared in 34-41) is two launches: the clamp into the bf16 plane
|
||||
* (swiglu_step) and the rotating int8 quantiser reading it (had_quant_act_i8g, at the 128-column
|
||||
* group of the int8 down projection that reads the codes). Against the same container without
|
||||
* the clamp lists, those 15 gated_had_quant_i8g become 15 such pairs and no other op changes; no
|
||||
* unrotated int8 and no E4M3 quantiser exists, and the steps run lint-clean. */
|
||||
TEST(flash_iq8r_clamps_its_gated_products_then_quantises_them_rotated) {
|
||||
for (int world : { 1, 2, 4 }) {
|
||||
for (int rank = 0; rank < world; ++rank) {
|
||||
MetaKV plain = flash_meta();
|
||||
plain.drop("expert_swiglu_limit_list").drop("share_expert_swiglu_limit_list");
|
||||
RadBuilder b0;
|
||||
iq8r_encs(&b0);
|
||||
RadBuildCtx c0 = build_ctx(rank, world);
|
||||
REQUIRE_EQ(bailing_hybrid::declare(&b0, plain.meta(), &c0), RAD_OK);
|
||||
MetaKV mk = flash_meta();
|
||||
RadBuilder b;
|
||||
iq8r_encs(&b);
|
||||
RadBuildCtx ctx = build_ctx(rank, world);
|
||||
REQUIRE_EQ(bailing_hybrid::declare(&b, mk.meta(), &ctx), RAD_OK);
|
||||
CHECK(bailing_hybrid::g_model[0].trunk_rot);
|
||||
CHECK_EQ(count_op(b, "swiglu_step"), 15);
|
||||
CHECK_EQ(count_op(b, "had_quant_act_i8g") - count_op(b0, "had_quant_act_i8g"), 15);
|
||||
CHECK_EQ(count_op(b0, "gated_had_quant_i8g") - count_op(b, "gated_had_quant_i8g"), 15);
|
||||
CHECK_EQ(b.ops.size(), b0.ops.size() + 15);
|
||||
CHECK_EQ(count_op(b, "quant_act_i8g"), 0);
|
||||
CHECK_EQ(count_op(b, "quant_act_fp8"), 0);
|
||||
CHECK_EQ(count_op(b, "swiglu_clamped"), 0);
|
||||
for (size_t i = 0; i + 1 < b.ops.size(); ++i) {
|
||||
if (b.ops[i].op != "swiglu_step") continue;
|
||||
const RecOp& q = b.ops[i + 1];
|
||||
CHECK_EQ(q.op, std::string("had_quant_act_i8g"));
|
||||
REQUIRE_EQ(b.ops[i].writes.size(), (size_t)1);
|
||||
CHECK(std::find(q.reads.begin(), q.reads.end(), b.ops[i].writes[0]) !=
|
||||
q.reads.end());
|
||||
const RecParam* g = param(&q, "group");
|
||||
REQUIRE(g != nullptr);
|
||||
CHECK_EQ(g->ival, 128LL);
|
||||
}
|
||||
steps_lint_clean(b, rank, world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Per-instance state lives in the declaring instance's slot, so a second engine in the process
|
||||
* leaves the first one's model alone. */
|
||||
TEST(declares_into_its_own_slot) {
|
||||
|
||||
Reference in new issue
Block a user