Archived
qwen35_fp8: read the delta net's out-projection beside its decode recurrent update
At decode heights the recurrent update runs one workgroup per (sequence, head) and leaves the card's memory mostly idle. Each delta-net layer now reads its out-projection (the whole weight, 7.9 MB a rank in MXFP4) into the on-die cache there, on the second lane behind a join from lane 0, as prefetch_beside does beside the all-reduces. Up to four decode sequences and 32 rows; no read on a step that carries a prompt's rows, at one rank, or where the deployment turns weight prefetch off (RadBuildCtx::weight_prefetch_off: nothing is declared). Qwen3.8-27B MXFP4 + DFlash2 at tp 2 on 2x R9700, production flags, 1k context, hwgrid ms/step, median of five interleaved rounds, none -> whole projection: x1 19.40 -> 19.10 (-1.5 %), x2 20.93 -> 20.78 (-0.7 %), x4 24.26 -> 24.17 (-0.4 %), every round faster at each of the three; x8 25.22 -> 25.48 (+1.0 %, four rounds of five slower) -- hence the four-sequence ceiling; x16 (64 rows, no read) and 90k x4 unchanged. 4 MB reads as the whole. Against this main (one round): x1 19.40 -> 19.15, other cells within noise. Greedy output identical to the build without the read (300/300 tokens on two prompts, |dlogprob| 0). arch_test: qwen35_fp8_reads_the_delta_net_out_projection_beside_its_decode_update; the qwen35_fp8 step pins move (prg_pins.py). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
49ca5ff9c6
commit
a64c75eb34
3 files changed
+76
-3
No files matched your search
@@ -127,6 +127,11 @@ struct GdnFP8 {
|
||||
* the widest decode window the fold serves. */
|
||||
rad_op op_cr = 0;
|
||||
int64_t cr_rows = 0;
|
||||
/* Set by the architecture after declare: a `prefetch` of the out-projection's leading bytes
|
||||
* (decl_prefetch, rad_arch.h), issued on the second lane beside the decode recurrent update on
|
||||
* steps of up to pf_out_rows rows and pf_out_seqs sequences. 0 where none is declared. */
|
||||
rad_op op_pf_out = 0;
|
||||
int64_t pf_out_rows = 0, pf_out_seqs = 0;
|
||||
rad_op op_ar = 0, op_add = 0;
|
||||
/* The next block absorbs this block's closing all-reduce (see rad_block_attn_gated_fp8.h). */
|
||||
bool ar_out = false;
|
||||
@@ -481,6 +486,14 @@ inline void GdnFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
const int64_t PT = T - DT;
|
||||
const int64_t in_w = conv_dim + v_dim; /* w.in.x's declared row width */
|
||||
|
||||
/* The recurrent update at decode heights runs one workgroup per (sequence, head) and leaves the
|
||||
* card's memory mostly idle, so the out-projection's weight is read into the on-die cache
|
||||
* beside it, on the second lane behind a join from lane 0 (as prefetch_beside). */
|
||||
if (op_pf_out && D > 0 && D <= pf_out_seqs && P == 0 && T <= pf_out_rows) {
|
||||
if (rad_lane_join(c, 0, 1) == RAD_OK && rad_lane(c, 1) == RAD_OK)
|
||||
RAD_ISSUE(c, op_pf_out, RAD_W(out.w));
|
||||
rad_lane(c, 0);
|
||||
}
|
||||
if (D > 0 && op_cr && qd <= cr_rows) {
|
||||
RAD_ISSUE_N(c, op_cr, qd,
|
||||
bcol(w.in.x, 0, conv_dim, DT), RAD_W(w_conv), RAD_NONE, kv_cache(kv_conv, layer),
|
||||
|
||||
@@ -114,6 +114,16 @@ using MtpHead = MtpFP8;
|
||||
* wash. The drafter's reads (Dflash2::Config::prefetch) take the same size. */
|
||||
constexpr int64_t kPrefetchBytes = (int64_t)12 << 20;
|
||||
constexpr int64_t kPrefetchStepRows = 32;
|
||||
/* The delta net's out-projection read into the on-die cache beside its decode recurrent update
|
||||
* (GdnFP8::op_pf_out): the update runs one workgroup per (sequence, head) and leaves the memory mostly
|
||||
* idle, so the whole projection (7.9 MB a rank in MXFP4; the read stops at the weight's end) is read
|
||||
* there. Qwen3.8-27B MXFP4 + DFlash2 at tp 2, production flags, 1k context, hwgrid ms/step, median of
|
||||
* five interleaved rounds, none -> whole: x1 19.40 -> 19.10, x2 20.93 -> 20.78, x4 24.26 -> 24.17
|
||||
* (every round faster), x8 25.22 -> 25.48 (four rounds of five slower: eight sequences' state traffic
|
||||
* fills the memory and the read competes with it), so up to four sequences. 4 MB read as the whole
|
||||
* (x1 19.24 / 19.10 against 19.20 / 19.06); 90k x4 and x16 (64 rows, no read) unchanged. */
|
||||
constexpr int64_t kGdnOutPrefetchBytes = (int64_t)8 << 20;
|
||||
constexpr int64_t kGdnOutPrefetchSeqs = 4;
|
||||
|
||||
struct Layer {
|
||||
int full = 0;
|
||||
@@ -1091,6 +1101,11 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
Layer& lay = m.layers[(size_t)l];
|
||||
lay.pf_gu_w = lay.mlp.gate_up.w;
|
||||
lay.op_pf_gu = decl_prefetch(b, lay.pf_gu_w, kPrefetchBytes);
|
||||
if (!lay.full) {
|
||||
lay.gdn.op_pf_out = decl_prefetch(b, lay.gdn.out.w, kGdnOutPrefetchBytes);
|
||||
lay.gdn.pf_out_rows = kPrefetchStepRows;
|
||||
lay.gdn.pf_out_seqs = kGdnOutPrefetchSeqs;
|
||||
}
|
||||
if (l + 1 < m.n_main) {
|
||||
const Layer& nx = m.layers[(size_t)l + 1];
|
||||
lay.pf_next_w = nx.full ? nx.attn.qg.w : nx.gdn.in.w;
|
||||
|
||||
+48
-3
@@ -7708,6 +7708,51 @@ TEST(qwen35_fp8_declares_fp8_linears_and_the_fused_output_gate) {
|
||||
CHECK(find_b(b, "mtp_x") == nullptr);
|
||||
}
|
||||
|
||||
/* At two ranks each delta-net layer reads its out-projection into the on-die cache beside the decode
|
||||
* recurrent update (GdnFP8::op_pf_out): a `prefetch` of the whole projection, issued right before
|
||||
* the update on steps of up to four decode sequences and 32 rows, none on a step of five or more
|
||||
* sequences, on a prompt's rows or at one rank. */
|
||||
TEST(qwen35_fp8_reads_the_delta_net_out_projection_beside_its_decode_update) {
|
||||
MetaKV mk = with_dflash2(q35fp8_meta());
|
||||
const RadEncoding mx = rad_enc_affine(RAD_FP4E2M1, RAD_E8M0, 1, rad::arch::RAD_MX_GROUP);
|
||||
const int n_gdn = 6;
|
||||
for (int world : { 1, 2 }) {
|
||||
RadBuilder b;
|
||||
b.encs = { { "blk.", mx } };
|
||||
RadBuildCtx ctx = spec_ctx(0, world, 7);
|
||||
ctx.max_tok = 2048;
|
||||
REQUIRE_EQ(stderr_of_rc([&] { return qwen35_fp8::declare(&b, mk.meta(), &ctx); }), RAD_OK);
|
||||
int declared = 0;
|
||||
for (const auto& o : b.ops)
|
||||
if (o.op == "prefetch" && o.w.size() == 1 &&
|
||||
b.weights[o.w[0] - 1].name.find("ssm_out") != std::string::npos) {
|
||||
++declared;
|
||||
CHECK_EQ(pint(&o, "bytes"), (int64_t)8 << 20);
|
||||
}
|
||||
CHECK_EQ(declared, world > 1 ? n_gdn : 0);
|
||||
|
||||
/* (decode sequences, rows each, prompt rows) -> whether the reads go */
|
||||
struct Case { int seqs, rows, prompt; bool reads; };
|
||||
for (const Case& cs : { Case{ 1, 8, 0, true }, Case{ 2, 8, 0, true }, Case{ 4, 8, 0, true },
|
||||
Case{ 4, 1, 0, true }, Case{ 5, 4, 0, false }, Case{ 8, 4, 0, false },
|
||||
Case{ 0, 0, 64, false }, Case{ 2, 8, 64, false } }) {
|
||||
const auto k = kit(b, std::vector<int>((size_t)cs.seqs, cs.rows),
|
||||
cs.prompt ? std::vector<int>{ cs.prompt } : std::vector<int>{});
|
||||
const auto v = run_passes(b, qwen35_fp8::step, { k.get() }, 0, world);
|
||||
CHECK_PASSES(b, v);
|
||||
const std::vector<std::string> ops = issued_ops(b, *v[0]);
|
||||
int updates = 0, beside = 0;
|
||||
for (size_t i = 0; i < ops.size(); ++i)
|
||||
if (ops[i] == "gdn_conv_recurrent_update" || ops[i] == "gdn_recurrent_update") {
|
||||
++updates;
|
||||
if (i > 0 && ops[i - 1] == "prefetch") ++beside;
|
||||
}
|
||||
CHECK_EQ(updates, cs.seqs ? n_gdn : 0);
|
||||
CHECK_EQ(beside, cs.reads && world > 1 ? n_gdn : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Every engine step the dense fp8 model runs lints clean at one and two ranks, the MTP head's
|
||||
* history pass and rounds included. */
|
||||
TEST(qwen35_fp8_steps_lint_clean_with_its_mtp_head) {
|
||||
@@ -10467,7 +10512,7 @@ struct ArchCases {
|
||||
qwen35_fp8::step, 3, {}, 0x20ab9ed24e409329ull);
|
||||
add("qwen35_fp8 + MTP, two ranks", [this, sc](RadBuilder* b) {
|
||||
auto c = sc(2, 3); return qwen35_fp8::declare(b, q35.meta(), &c); },
|
||||
nullptr, 3, { "ar_rmsnorm_quant_fp8" }, 0xd12381e7e3ede24dull);
|
||||
nullptr, 3, { "ar_rmsnorm_quant_fp8" }, 0x5b52afb1706a954eull);
|
||||
add("qwen35_fp8 + DFlash2", [this, sc](RadBuilder* b) {
|
||||
auto c = sc(1, 7); return qwen35_fp8::declare(b, q35df.meta(), &c); },
|
||||
qwen35_fp8::step, 7, {}, 0x365e4cbb415ac284ull);
|
||||
@@ -10476,7 +10521,7 @@ struct ArchCases {
|
||||
qwen35_w8a8::step, 7, {}, 0x742a596708bbda1dull);
|
||||
add("qwen35_w8a8 + DFlash2, two ranks", [this, sc](RadBuilder* b) {
|
||||
auto c = sc(2, 7); return w8a8_declare(b, q35w8df.meta(), &c); },
|
||||
nullptr, 7, { "ar_rmsnorm_quant_fp8" }, 0x7b7a1b301de20c1eull);
|
||||
nullptr, 7, { "ar_rmsnorm_quant_fp8" }, 0x93b6390d30e59953ull);
|
||||
add("qwen35moe_fp8 + MTP", [this, sc](RadBuilder* b) {
|
||||
auto c = sc(1, 3); return qwen35moe_fp8::declare(b, q35moe.meta(), &c); },
|
||||
qwen35moe_fp8::step, 3, {}, 0x4c7e42e71f167042ull);
|
||||
@@ -11223,7 +11268,7 @@ TEST(a_4096_budget_without_a_span_is_the_pinned_graph_and_steps) {
|
||||
{ "qwen4exp_fp8", 4, 0, 0x780814049d36bebcull, 0xfbe74f2b9d7020bfull },
|
||||
{ "qwen4exp_fp8", 4, 3, 0x0723ed824fef82d4ull, 0x36df57cac613c6cfull },
|
||||
{ "qwen35_fp8", 1, 0, 0xc56a518087e3f4b4ull, 0xa7ec3cf6252cd441ull },
|
||||
{ "qwen35_fp8", 2, 1, 0x61d309383f96b1acull, 0xbf359de7b8a6322cull },
|
||||
{ "qwen35_fp8", 2, 1, 0x6e644b3d13bac619ull, 0xdd5d65ef158c4136ull },
|
||||
{ "qwen35moe_fp8", 1, 0, 0x7a9330e0da08f97cull, 0x2b5989b2a6dbc7dfull },
|
||||
{ "qwen35moe_fp8", 2, 0, 0x3a2761e9546797f1ull, 0x4a597c66b5868eeeull },
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user