core, libr4d, arch: chained launches with block drafters, more prefill overlap, weight reads beside the all-reduces

Chained launches on the AQL backend (a dependent kernel waits on a queue counter in its own
prologue), on by default where the model's plugin measured a gain with its block drafter (the
Gemma 4 31B and 26B); the prefill overlap runs attention per slice with narrower lane-1
reductions; the next GEMM's weight is read into the on-die cache beside each all-reduce at decode
heights.

Squashed from:

- core, libr4d: chained launches -- dependent kernels wait in their prologue, not behind the barrier bit
- core, libr4d: chain a kernel by its name, not by the row that launched it
- libr4d, core: chained forms hold nothing across their body
- libr4d: a chained kernel's prologue polls its counter less often after the first few tries
- core/sched: the advance kernel's chained form
- docs: GUIDE lists RADIANCE_CHAIN; chained launches stay opt-in
- core/device: a chained packet behind a chained one keeps its barrier bit while a plain one may run
- libr4d: qkv_norm_rope and its kv_store fold as chained forms
- libr4d: the split-KV decode attention and its merge as chained forms
- libr4d: the four-rank fused junction's tail form as a chained form
- libr4d: the attention, prologue and junction chained forms hold nothing across their body
- libr4d: the 31B's windowed attention and quant_act_i8 as chained forms; r4d_chain.h stubs for the host emulator
- libr4d: DFlash2's kernels as chained forms
- libr4d: chained forms for the decode tail
- abi, core, arch: chained launches on by default where the plugin measured a gain with its drafter
- arch/gemma4_bf16: the prefill overlap's lane-1 all-reduces take the narrow launch (`overlap` 1)
- arch/gemma4_bf16, libr4d: the prefill overlap runs attention per slice; kv_len_trim
- abi, core, libr4d: RAD_LAYOUT_ANY, and a device-only weight read (prefetch)
- arch: read the next GEMM's weight into the cache beside each collective at decode heights

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
AshlynandClaude Opus 5.5 committed 2026-10-21 03:00:48 -05:00
1 parent 1bb7ad3ef9
commit ab2b3be6c0
53 files changed
+2239 -220

No files matched your search

+24 -2
View File
@@ -112,6 +112,23 @@ inline double embed_scale(int64_t hidden) {
return rad_bf16_to_f32(rad_f32_to_bf16((float)std::sqrt((double)hidden)));
}
/* prefetch where a library serves it: the 31B trunk reading the next GEMM's leading weight bytes
* into the on-die cache beside the all-reduce in front of that GEMM, at decode heights (on lane 0
* as a chained read, or on the second lane: rad_arch.h prefetch_lane0), and the DFlash2 drafter's
* reads likewise. It writes nothing the model reads. Each read takes a weight's first 20 MB. With
* the reads on lane 0 (two rounds on 4x R9700): 20 MB 391 / 391 code tok/s, 289 / 288 prose;
* 16 MB 386 / 384, 285 / 283; 24 MB 388 / 387; 12 MB 368 / 369. */
constexpr int64_t kPrefetchBytes = (int64_t)20 << 20;
/* down_proj's read, the trunk GEMM no other read covers: its first 9 MB, beside the attention. It
* took the place of o_proj's read there: the 31B at tp 4 on 4x R9700, two rounds, every reply
* identical, 380 / 281 / 203 tok/s against 367 / 271 / 196 with o_proj's 16 MB; 10, 11, 12, 14
* and 20 MB of down_proj 379, 377, 373, 373 and 362; down_proj beside o_proj's read, or beside the
* feed-forward reduction, slower than either alone. The reads beside a reduction are one queue,
* and a longer one beside the attention pushes gate_up's read past the reduction it should hide
* in. */
constexpr int64_t kPrefetchDownBytes = (int64_t)9 << 20;
/* Block fp8 as libr4d's fp8a8 GEMMs read it: fp8_e4m3 codes, a bf16 scale per 128x128 block, no
* transform (a recipe's `rtn codes=fp8_e4m3 block=128x128 scale=bf16`). */
inline bool block_fp8_128(const RadEncoding& e) {
@@ -149,25 +166,30 @@ inline long long dflash_block(const RadModelMeta* meta) {
/* DFlash proposes its whole block in one pass, so its depth is the block it was trained at less
* the anchor, and nothing else: 15 for z-lab's Gemma 4 drafters (block_size 16). True when the
* container carries one and `out` now names its depth. */
* container carries one and `out` now names its depth. Chained launches measured a gain with it
* (the 26B-A4B's speculative step, +1% on 4x R9700), so the probe asks for them
* (RadArchProbe::chain_pays). */
inline bool dflash_probe(const RadModelMeta* meta, RadArchProbe* out) {
if (dflash_kind(meta) != 1) return false;
const long long bs = dflash_block(meta);
if (bs <= 1) return false;
out->draft_depth = (int)(bs - 1);
out->draft_depth_fixed = 1;
out->chain_pays = 1;
return true;
}
/* The same for a DFlash2 drafter, for a plugin that serves rad_block_dflash2.h (the 31B's): its
* anchor predicts nothing either, so the depth is the trained block less one, 7 for RedHatAI's
* gemma-4-31B-it-speculator.dflash2 (block_size 8). */
* gemma-4-31B-it-speculator.dflash2 (block_size 8). Chained launches measured a gain with it (the
* 31B's speculative step, +13% on 4x R9700), so the probe asks for them. */
inline bool dflash2_probe(const RadModelMeta* meta, RadArchProbe* out) {
if (dflash_kind(meta) != 2) return false;
const long long bs = dflash_block(meta);
if (bs <= 1) return false;
out->draft_depth = (int)(bs - 1);
out->draft_depth_fixed = 1;
out->chain_pays = 1;
return true;
}