Archived
MTP coupling on qwen35_fp8's 2-bit draft head; libxe2 rows for the coupling ops
- arch: under --draft-coupling the MtpBlockFP8 draft head keeps the 2-bit logits' top 8, rescores them against the trunk's head (logit_rerank) and runs one mtp_couple_propose a round, as the Flash-Next head does; qwen35_fp8 declares the draw/state planes and a pitch-8 proposal. Off, nothing changes. - libxe2: device rows for mtp_couple_propose / mtp_couple_verify, a work-item a row over spechub's own row helpers and argument readers (built into xe2_couple.cpp). - spechub: mtp_couple_propose takes an optional q_temp (Q = softmax(score / q_temp)); exact at any value. RADIANCE_MTP_Q_TEMP sets it on qwen35_fp8 (default 1: 1.0 > 0.7 > 0.5 here). w4a16-rtn-mtp4, depth 7 adaptive, temperature 0.7: decode proxy 76.9 -> 78.8 tok/s, BetterBench decode 80.5 -> 81.7; greedy 8/8 identical with coupling on. Host tests (spechub|couple|abi|mtp) 7/7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bfb1ebd1dd
commit
175f0bbd33
8 files changed
+160
-15
No files matched your search
@@ -193,6 +193,8 @@ struct Model {
|
||||
rad_buf b_mtp_e = 0, b_mtp_c = 0, b_mtp_x = 0, b_mtp_h = 0;
|
||||
rad_buf b_mtp_dq = 0, b_mtp_ds = 0, b_mtp_dsum = 0;
|
||||
rad_buf b_mtp_dlog = 0, b_mtp_didx = 0, b_mtp_dval = 0;
|
||||
rad_buf b_mtp_couple_draws = 0, b_mtp_couple_state = 0;
|
||||
int64_t mtp_topr = 1;
|
||||
|
||||
/* Auxiliary hidden-state taps, declared only when the container carries a drafter that wants
|
||||
* them. A DFlash2 drafter reads the residual stream at several intermediate layers and
|
||||
@@ -1169,8 +1171,27 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
m.b_mtp_dlog = decl_b(b, nm.f("mtp_dlog"), g.act_dtype, {g.max_logit_rows, mtp_draft_rows(g.n_vocab_all)});
|
||||
/* A draft round's proposal comes out of row_topk here, never through the sampler's
|
||||
* token buffer. */
|
||||
m.b_mtp_didx = decl_b(b, nm.f("mtp_didx"), RAD_I32, {g.max_logit_rows, 1});
|
||||
m.b_mtp_dval = decl_b(b, nm.f("mtp_dval"), RAD_F32, {g.max_logit_rows, 1});
|
||||
/* --draft-coupling: a top-8 shortlist, rescored against the trunk's head, that each
|
||||
* round's mtp_couple_propose samples x ~ Q from into column 0 (rad_block_mtp_fp8.h) */
|
||||
m.mtp_topr = ctx->draft_coupling ? 8 : 1;
|
||||
m.b_mtp_didx = decl_b(b, nm.f("mtp_didx"), RAD_I32, {g.max_logit_rows, m.mtp_topr});
|
||||
m.b_mtp_dval = decl_b(b, nm.f("mtp_dval"), RAD_F32, {g.max_logit_rows, m.mtp_topr});
|
||||
if (ctx->draft_coupling) {
|
||||
if (ctx->max_spec < 1 || ctx->max_spec > RAD_MTP_COUPLE_MAX_ROUNDS) {
|
||||
rad_note(b, "--draft-coupling on: the MTP head couples at most %d rounds",
|
||||
RAD_MTP_COUPLE_MAX_ROUNDS);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
m.b_mtp_couple_draws = decl_b(b, nm.f("mtp_couple_draws"), RAD_U32,
|
||||
{g.max_seqs, RAD_MTP_COUPLE_DRAW_WORDS}, RAD_BUF_PERSIST);
|
||||
m.b_mtp_couple_state = decl_b(b, nm.f("mtp_couple_state"), RAD_U32,
|
||||
{ctx->max_spec, g.max_seqs, RAD_MTP_COUPLE_STATE_WORDS},
|
||||
RAD_BUF_PERSIST);
|
||||
if (!m.b_mtp_couple_draws || !m.b_mtp_couple_state) return RAD_E_INVAL;
|
||||
rad_note(b, "MTP coupled: x~Q from the 2-bit head's top 8 rescored against the "
|
||||
"trunk's head, %d round(s); fixed-seed tokens are NOT preserved",
|
||||
ctx->max_spec);
|
||||
}
|
||||
}
|
||||
|
||||
/* The head reuses the trunk's working buffers (`attn_qg`, `attn_k`, the ffn planes, `h`),
|
||||
@@ -1185,6 +1206,9 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
tw.e = m.b_mtp_e; tw.c = m.b_mtp_c; tw.x = m.b_mtp_x;
|
||||
tw.dq = m.b_mtp_dq; tw.ds = m.b_mtp_ds; tw.dsum = m.b_mtp_dsum;
|
||||
tw.dlog = m.b_mtp_dlog; tw.didx = m.b_mtp_didx; tw.dval = m.b_mtp_dval;
|
||||
tw.topr = m.mtp_topr;
|
||||
if (const char* qt = std::getenv("RADIANCE_MTP_Q_TEMP")) tw.q_temp = std::atof(qt);
|
||||
tw.couple_draws = m.b_mtp_couple_draws; tw.couple_state = m.b_mtp_couple_state;
|
||||
tw.attn = tw_attn; tw.mlp = tw_mlp;
|
||||
|
||||
MtpHead::Src ts{};
|
||||
@@ -1238,7 +1262,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
dd.kind = RAD_DRAFT_SERIAL;
|
||||
dd.depth = ctx->max_spec;
|
||||
dd.proposal = m.b_mtp_didx;
|
||||
dd.proposal_pitch = 1;
|
||||
dd.proposal_pitch = m.mtp_topr; /* the pick is column 0 */
|
||||
dd.mask_token = -1;
|
||||
RAD_ARCH_TRY(rad_declare_drafter(b, &dd));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user