Archived
qwen35_fp8: the GDN state cache at f16 when a deployment asks (RADIANCE_GDN_STATE_F16=1)
libr4d's recurrent update and chunk scan already read the state's width off the cache; the plugin declared it f32 unconditionally because f16 changes the generated text. A deployment may now trade that: RADIANCE_GDN_STATE_F16=1 (exactly) declares the cache f16, anything else keeps f32, and the declare log says so. The default does not change. Lossy. Qwen3.8-27B (MXFP4, TP2), mean KL against the bf16 reference, f32 -> f16: - k6_v4 KV: chunk 2048 0.040238 -> 0.040005; chunk 64 (the state stored and rounded every 64 tokens) 0.039607 -> 0.040468, top-1 94.07 -> 94.00 %; - fp8 KV: chunk 2048 0.039171 -> 0.039600 (+1.1 %), chunk 64 0.039327 -> 0.039690 (+0.9 %). It halves the state pool, its host checkpoints and the state's traffic, which grows with the decoding sequences. Decode on two R9700s, greedy, three rounds (medians, tok/s, f32 -> f16): - no speculation: 1 stream 67.1 -> 67.5 (+0.6 %), 4 246.8 -> 253.3 (+2.6 %), 16 708.0 -> 779.5 (+10.1 %); the rounds agree to a tenth; - speculation 7: 1 stream 222.2 -> 215.1 (-3.2 %), 4 636.9 -> 621.0 (-2.5 %), 16 1223.8 -> 1276.7 (+4.3 %); f16 also changes which drafts the greedy text accepts, and the text and the step were not separated. So it is for many concurrent sequences where the KL is acceptable. GUIDE §4.4 has the tables. arch_test: the state group is f32 unset, at "0" and at "yes", f16 at "1". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9eaf10da6e
commit
4d68a01a08
4 files changed
+73
-8
No files matched your search
@@ -6154,6 +6154,27 @@ void lint_qwen35_fp8_family(Fn declare, StepFn step, const RadModelMeta* meta, i
|
||||
|
||||
} /* namespace */
|
||||
|
||||
/* The GDN state cache's width is a deployment's choice: f32 by default, f16 with
|
||||
* RADIANCE_GDN_STATE_F16=1 (libr4d's kernels read the width off the cache), anything else f32. */
|
||||
TEST(qwen35_fp8_gdn_state_is_f32_unless_the_deployment_asks_f16) {
|
||||
MetaKV mk = q35fp8_meta();
|
||||
for (const char* v : { (const char*)nullptr, "1", "0", "yes" }) {
|
||||
if (v) setenv("RADIANCE_GDN_STATE_F16", v, 1);
|
||||
RadBuilder b;
|
||||
RadBuildCtx ctx = build_ctx();
|
||||
const int rc = stderr_of_rc([&] { return qwen35_fp8::declare(&b, mk.meta(), &ctx); });
|
||||
unsetenv("RADIANCE_GDN_STATE_F16");
|
||||
REQUIRE_EQ(rc, RAD_OK);
|
||||
int n = 0;
|
||||
for (const RecKV& g : b.kv_groups)
|
||||
if (g.name == "kv_gdn_state") {
|
||||
++n;
|
||||
CHECK_EQ(g.d.dtype, (v && std::string(v) == "1") ? RAD_F16 : RAD_F32);
|
||||
}
|
||||
CHECK_EQ(n, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* The fp8 sibling of qwen35_bf16: the same layers with every large linear a block-fp8 gemm_nt_q
|
||||
* read at fp8a8, one quantiser per activation, and the attention's output gate, multiply and
|
||||
* quantiser fused into gate_quant_fp8 (the sigmoid/mul pair is the bf16-linear form only). The
|
||||
|
||||
Reference in new issue
Block a user