dflash2 coupled walk: Q at temperature 0.6 by default
Q's temperature (RADIANCE_DFLASH_Q_TEMP) only moves acceptance, never the output law. Held-out tokens per verify step at request temperature 1, x4, 32 rows of the eval set, Qwen3.8-27B MXFP4 with a DFlash2 drafter fine-tuned on our traffic, our serving flags: ordinary rule 3.52; coupled with Q at 1.0 3.71, 0.7 3.88, 0.5 3.85, 0.35 3.77. The walk's scores are flatter than the target's law, so a sharper Q puts its mass where the target's is; 0.6 is the default now. At 0.6, 3 interleaved rounds against the ordinary rule (64 held-out rows at x4, and three requests at x1 and x4, 1500 tokens, T 1): - tokens per step 3.53 -> 3.82 (+8.2 %), every round apart (3.50/3.49/3.61 vs 3.82/3.79/3.86); time-weighted decode +5.4 %; - decode per stream: 0.7k prompt x1 174.1 -> 181.7 (+4.4 %), x4 144.6 -> 153.8 (+6.4 %); 22k prompt x1 186.6 -> 191.0 (+2.3 %), x4 135.1 -> 146.2 (+8.2 %); 41k prompt x1 186.9 -> 196.8 (+5.3 %), x4 125.8 -> 135.0 (+7.3 %); aggregate at x4 +5.3..+5.5 %. Coupled at 0.6 against the ordinary rule, 5000-6000 samples of tokens 1-4 of two chat prompts: chi-square p 0.62..0.99. The walk's kernel issues each candidate's successor slice and unary score before the predecessor's codebook row (both are independent of it). This is the build measured above; it moved the pass time within noise (91.3 -> 90.8 us at M 16, steps 7), and tokens, ids, x and status still match the host oracle on all 40 random lattices (q by FP64 exp ulps, <= 4.3e-16). ctest (the environment-only tests excluded) 105/105. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
cb0abe9ac7
commit
ce79b12126
3 files changed
+26
-16
No files matched your search
@@ -424,8 +424,11 @@ static int declare_dflash2(RadBuilder* b, const RadModelMeta* meta, const RadBui
|
||||
/* --draft-coupling (RadBuildCtx::draft_coupling): the walk samples each draft from Q, its
|
||||
* scores' softmax over the best eight candidates, and the sampler couples the target's own draw
|
||||
* to it (abi/rad_spechub.h). The planes are named as the MTP head's, which is how the engine
|
||||
* finds them. RADIANCE_DFLASH_Q_TEMP sets Q's temperature (default 1); any value keeps the
|
||||
* output exact and moves only acceptance. */
|
||||
* finds them. RADIANCE_DFLASH_Q_TEMP sets Q's temperature; any value keeps the output exact
|
||||
* and moves only acceptance. The default, 0.6, is where held-out acceptance peaked on
|
||||
* Qwen3.8-27B MXFP4 + its DFlash2 drafter at request temperature 1 (tokens a step at x4, 32
|
||||
* rows: ordinary rule 3.52; Q at 1.0 3.71, 0.7 3.88, 0.5 3.85, 0.35 3.77): the walk's scores
|
||||
* are flatter than the target's law, and a sharper Q puts its mass where the target's is. */
|
||||
if (ctx->draft_coupling) {
|
||||
if (dc.steps() > RAD_MTP_COUPLE_MAX_ROUNDS || dc.sel_topk > RAD_DFLASH_COUPLE_MAX_K ||
|
||||
dc.sel_rank % RAD_DFLASH_EDGE_PARTS || dc.sel_rank > RAD_DFLASH_COUPLE_MAX_R) {
|
||||
@@ -435,6 +438,7 @@ static int declare_dflash2(RadBuilder* b, const RadModelMeta* meta, const RadBui
|
||||
RAD_DFLASH_COUPLE_MAX_R);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
dc.q_temp = 0.6;
|
||||
if (const char* e = std::getenv("RADIANCE_DFLASH_Q_TEMP")) {
|
||||
const double t = std::strtod(e, nullptr);
|
||||
if (!(t > 0.0) || t > 100.0) {
|
||||
|
||||
+1
-1
@@ -1943,7 +1943,7 @@ by 0.002-0.003 nats.
|
||||
| `--num-speculative-tokens N` | auto | speculative window; 0 disables. The ceiling under `--draft-window adaptive` |
|
||||
| `--draft-window MODE` | fixed | `fixed` drafts N every step; `adaptive` follows each sequence's acceptance and the measured step cost, serial draft heads only (§4.6) |
|
||||
| `--draft-short-from N` | 0 | a block drafter that declares a shorter block runs it from N decoding sequences on, its own block again two below; 0 never (§4.6) |
|
||||
| `--draft-coupling MODE` | off | `on`: a linear MTP drafter with a 2-bit candidate head (Qwen3.8-Flash-Next) samples each proposal from its reranked top-8 and the sampler maximally couples the target's draw to it. The output distribution is unchanged and a fixed seed yields other tokens than `off`. The head's law is taken at temperature 1, so it pays at high request temperatures and costs at low ones: on Flash-Next TP2 at 2x R9700, tokens per decode step +18% at temperature 1.0 and c1, +11% at 0.7 and c4, -4% at 0.3. Greedy rows are unchanged. A DFlash2 drafter (Qwen3.5/3.8) couples its candidate walk instead: each position is sampled from the softmax of the walk's own scores over its best eight candidates, at temperature `RADIANCE_DFLASH_Q_TEMP` (default 1). Any other drafter is refused at startup |
|
||||
| `--draft-coupling MODE` | off | `on`: a linear MTP drafter with a 2-bit candidate head (Qwen3.8-Flash-Next) samples each proposal from its reranked top-8 and the sampler maximally couples the target's draw to it. The output distribution is unchanged and a fixed seed yields other tokens than `off`. The head's law is taken at temperature 1, so it pays at high request temperatures and costs at low ones: on Flash-Next TP2 at 2x R9700, tokens per decode step +18% at temperature 1.0 and c1, +11% at 0.7 and c4, -4% at 0.3. Greedy rows are unchanged. A DFlash2 drafter (Qwen3.5/3.8) couples its candidate walk instead: each position is sampled from the softmax of the walk's own scores over its best eight candidates, at temperature `RADIANCE_DFLASH_Q_TEMP` (default 0.6, where acceptance peaked); on Qwen3.8-27B MXFP4 TP2 at 2x R9700 and request temperature 1, tokens per verify step +8% on held-out prompts at c4 (3.53 to 3.82) and decode +2..8% per stream at c1/c4. Any other drafter is refused at startup |
|
||||
| `--draft-model PATH` | | not implemented: merge the drafter at convert time |
|
||||
|
||||
**Server**
|
||||
|
||||
+19
-13
@@ -199,6 +199,20 @@ __global__ __launch_bounds__(kDfThreads) void dflash_couple(
|
||||
const int c = tid / RAD_DFLASH_EDGE_PARTS, j = tid % RAD_DFLASH_EDGE_PARTS;
|
||||
for (int64_t l = 0; l < steps; ++l) {
|
||||
const int64_t row = s * steps + l;
|
||||
/* What does not depend on the predecessor is loaded first, so its latency overlaps the
|
||||
* predecessor's codebook row: the candidate, its successor slice and its unary score. */
|
||||
const int32_t id = c < K ? cand[row * ld_cand + c] : -1;
|
||||
const bool id_ok = id >= 0 && id < vocab;
|
||||
const bool wide = R == 32 * RAD_DFLASH_EDGE_PARTS;
|
||||
uint4 v[4] = {};
|
||||
if (id_ok && wide) {
|
||||
/* DFlash2's rank 256: the slice's 32 values in four 16-byte loads issued together. A
|
||||
* load inside the fmaf chain would wait out one memory latency per element. */
|
||||
const uint4* src = reinterpret_cast<const uint4*>(succ + (int64_t)id * R + j * 32);
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 4; ++i) v[i] = src[i];
|
||||
}
|
||||
const float un = tid < K ? unary[row * ld_unary + tid] : 0.0f;
|
||||
const int32_t pid = spid;
|
||||
const bool ok = pid >= 0 && pid < vocab;
|
||||
for (int64_t r = tid; r < R; r += kDfThreads)
|
||||
@@ -207,24 +221,16 @@ __global__ __launch_bounds__(kDfThreads) void dflash_couple(
|
||||
: 0.0f;
|
||||
__syncthreads();
|
||||
if (c < K) {
|
||||
const int32_t id = cand[row * ld_cand + c];
|
||||
float pv = 0.0f;
|
||||
if (id >= 0 && id < vocab) {
|
||||
const uint16_t* srow = succ + (int64_t)id * R;
|
||||
if (R == 32 * RAD_DFLASH_EDGE_PARTS) {
|
||||
/* DFlash2's rank 256: the slice's 32 values in four 16-byte loads issued
|
||||
* together, then rad_dflash_edge_part's fmaf chain over them in its order. A
|
||||
* load inside the chain would wait out one memory latency per element. */
|
||||
const uint4* src = reinterpret_cast<const uint4*>(srow + j * 32);
|
||||
uint4 v[4];
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 4; ++i) v[i] = src[i];
|
||||
if (id_ok) {
|
||||
if (wide) {
|
||||
/* rad_dflash_edge_part's fmaf chain over the slice, in its order. */
|
||||
const uint16_t* h = reinterpret_cast<const uint16_t*>(v);
|
||||
const float* a = sa + j * 32;
|
||||
#pragma unroll
|
||||
for (int r = 0; r < 32; ++r) pv = fmaf(a[r], rad_dflash_bf2f(h[r]), pv);
|
||||
} else {
|
||||
pv = rad_dflash_edge_part(sa, srow, R, j);
|
||||
pv = rad_dflash_edge_part(sa, succ + (int64_t)id * R, R, j);
|
||||
}
|
||||
}
|
||||
part[tid] = pv;
|
||||
@@ -237,7 +243,7 @@ __global__ __launch_bounds__(kDfThreads) void dflash_couple(
|
||||
if (sid[tid] >= 0 && sid[tid] < vocab)
|
||||
for (int q = 0; q < RAD_DFLASH_EDGE_PARTS; ++q)
|
||||
acc += part[tid * RAD_DFLASH_EDGE_PARTS + q];
|
||||
sc[tid] = unary[row * ld_unary + tid] + acc;
|
||||
sc[tid] = un + acc;
|
||||
}
|
||||
if (tid < 8) slot_id[tid] = -2;
|
||||
__syncthreads();
|
||||
|
||||
Reference in new issue
Block a user