radiance 1.14.0

New models and formats:
- libr3d: a kernel library for RDNA3 (gfx11) cards
- nomic-embed-text-v2-moe (the nomicbert plugin)
- Gemma 4 E2B with its per-layer MLP width, and Google's unmodified E2B/E4B directories in bf16
- DeepSeek-V4.1-Flash converted straight from its release: the Engram tables, the fused imatrix and
  rad-convert --chat-template for a release that ships no template
- GGUF Q8_0, Q4_K and Q6_K tensors import as their planes; rad-convert writes them without a recipe
- Qwen3.8-Flash-Next-FP8 converts and serves through qwen4exp_fp8

Speed:
- hc_read's decode kernels as one grid (34.7 -> 25.2 us at 4 rows) and its tiled up-mix pipelined
- gemm_fp8a8: the narrow form's scales staged through LDS (Flash-Next int8 at 32 rows 83.6 -> 68.3
  us), the gated three-tile form at 8 waves (gate_up at 48 rows 272.9 -> 180.6 us)
- Qwen3.8-27B: the delta net's out-projection read beside its decode recurrent update (x1 19.40 ->
  19.10 ms a step), and the verify's split-KV attention sized by context depth (x3 at 180K 42.4 ->
  40.3 ms a step)
- Hy-Memory (HYV3) decode: fused QK norm, RoPE and KV store, residual adds folded into the norms,
  coalesced one-token expert GEMMs
- spechub: the coupled verify walks the live candidates only (151 -> 31 us a launch)

Speculation:
- DFlash2: lossless coupled acceptance at T > 0 (--draft-coupling on)
- A block drafter's proposals verified as a tree, on by default for the Gemma 4 31B's DFlash2, with
  a block-16 tree that runs its short block under load

Features:
- Decode-hot residency: --draft-expert-placement host, --expert-profile, --expert-pin-top, and
  --expert-stats FILE for the routed experts each layer selects
- --ngram-placement ram=DIR: one n-gram table shared by engines on separate cards
- Prefix cache: --prefix-resume exact (default) resumes a hit on the cold run's own chunk grid, so it
  answers bit-identically; snapshots at a head other prompts share, from 528-token prompts, and for
  tip-only one drafter window below the tip; hits on models whose KV groups have different block
  sizes; the snapshot store keeps a floor of 8 ahead of --host-headroom-mib
- Typed tool-call argument tags; rad-chatparse --request renders and reads back one request as the
  server does
- MiniMax-H3: keyframes ride a latent upscale
- Gemma 3's fused all-reduce junction on the lossy wire

Fixes:
- A speculative step shorter than its band (an MTP step of 4 rows at gqa 8) no longer stops the
  engine with a scratch refusal at issue (#293)
- --p2p off: prefill back to 1.12.0's rate; 1.13.0's push check read a host-memory slot over the link
  twice (#323)
- A chat template that cannot render a conversation is refused at load, not mid-request
- imatrix entries found under llama.cpp's spelling; the W4A8 prefill's tail scale read; the GDN conv
  kernels on an f32 weight; dense integer rows at the group they compute (a Q8_0 weight at group 32)
- --expert-profile refuses a profile recorded on another model
- hc_read's one-grid wait traps past its deadline instead of reading a stale value

Changes: Plugin ABI 31, unchanged. RADIANCE_DRAFT_TREE, DFLASH2_TREE_NODES, DFLASH2_TREE_TEMP and
DFLASH_Q_TEMP are gone (trees run where the probe says they pay; temperatures 1.25 / 0.6).
This commit is contained in:
Deadcode committed 2026-10-29 12:04:24 +01:00
1 parent 481fcd5df0
commit 4a61d7296b
160 files changed
+8790 -6819

No files matched your search

+205 -15
View File
@@ -166,9 +166,9 @@ struct Fixture {
cfg.max_ctx = max_ctx;
cfg.checkpoint_interval = 256;
cfg.prefix_cache = true;
/* The tests below were written for the nearest resume rule (a tail snapshot at the last
* quantum boundary, a hit at any snapshot or block); the exact rule's own tests set
* prefix_exact (--prefix-resume exact, the default). */
/* The fixture runs --prefix-resume nearest (a tail snapshot at the last quantum
* boundary, a hit at any snapshot or block); the exact-resume tests set prefix_exact
* (--prefix-resume exact, the engine's default) themselves. */
cfg.prefix_exact = false;
/* Config::n_spec defaults to -1 (`auto`), which engine_bringup resolves; this fixture
* skips that, and DraftController::configure refuses a negative depth. Speculation tests
@@ -314,8 +314,8 @@ TEST(chunk_geometry_rounds_the_checkpoint_interval_up_to_a_legal_chunk) {
}
/* A model with no linear state checkpoints only for a trunk window: the snapshot of the window
* behind a prompt's tail is what a prefix hit resumes from. A drafter's own window is recomputed
* by draft refill, so it takes no checkpoint and leaves the hit at any block. */
* behind a prompt's tail is what a prefix hit resumes from. A drafter's own window alone takes no
* checkpoint and leaves the hit at any block: draft refill recomputes it. */
TEST(chunk_geometry_snapshots_a_trunk_window_and_not_a_drafters) {
for (int drafter = 0; drafter < 2; ++drafter) {
Program prog;
@@ -343,6 +343,12 @@ TEST(chunk_geometry_snapshots_a_trunk_window_and_not_a_drafters) {
CHECK_OK(chunk_geometry_resolve(prog, cfg, &g));
CHECK_EQ(g.checkpoint_interval, drafter ? 0ll : 256ll);
CHECK(g.window_ckpt == !drafter);
/* Bring-up asks the same before the geometry is resolved (window_snapshots), and puts a
* block drafter's window in the snapshot only where it answers yes: a full-attention
* trunk takes no snapshot for its drafter's window alone. */
CHECK(window_snapshots(prog, cfg) == g.window_ckpt);
cfg.prefix_cache = false;
CHECK(!window_snapshots(prog, cfg));
}
}
@@ -379,7 +385,9 @@ TEST(window_prefill_writes_interval_snapshots_before_the_tail) {
REQUIRE(n > 0);
pos += n;
if (ckpt > 0) {
CHECK_EQ(ckpt, pos);
/* An interval snapshot ends its chunk; the tail's rides inside the last one. */
CHECK(ckpt == pos || pos == 1100);
CHECK(ckpt > pos - n);
snapshots.push_back(ckpt);
}
}
@@ -387,9 +395,10 @@ TEST(window_prefill_writes_interval_snapshots_before_the_tail) {
CHECK(snapshots == expected);
/* An aligned prompt must still snapshot before its last block: that block's
* generation marker changes when the client replays the assistant reply. */
* generation marker changes when the client replays the assistant reply. The snapshot
* is taken inside the chunk, which is not split for it. */
int64_t ckpt = -1;
CHECK_EQ(f.sch.plan_chunk(768, 1024, 512, &ckpt), 240ll);
CHECK_EQ(f.sch.plan_chunk(768, 1024, 512, &ckpt), 256ll);
CHECK_EQ(ckpt, 1008ll);
/* A shared step may end before the boundary; the next chunk must reach it. */
CHECK_EQ(f.sch.plan_chunk(0, 1100, 160, &ckpt), 160ll);
@@ -419,12 +428,12 @@ TEST(tip_only_window_prefill_writes_only_the_tail_snapshot) {
CHECK_EQ(ckpt, -1ll);
CHECK_EQ(f.sch.plan_chunk(512, 1100, 512, &ckpt), 512ll);
CHECK_EQ(ckpt, -1ll);
CHECK_EQ(f.sch.plan_chunk(1024, 1100, 512, &ckpt), 48ll);
CHECK_EQ(f.sch.plan_chunk(1024, 1100, 512, &ckpt), 76ll);
CHECK_EQ(ckpt, 1072ll);
CHECK_EQ(f.sch.plan_chunk(1072, 1100, 512, &ckpt), 28ll);
CHECK_EQ(ckpt, -1ll);
CHECK_EQ(f.sch.plan_chunk(768, 1024, 512, &ckpt), 240ll);
CHECK_EQ(f.sch.plan_chunk(768, 1024, 512, &ckpt), 256ll);
CHECK_EQ(ckpt, 1008ll);
CHECK_EQ(f.sch.plan_chunk(0, 256, 512, &ckpt), 256ll);
CHECK_EQ(ckpt, -1ll);
@@ -799,6 +808,105 @@ TEST(a_span_needs_an_interval_grid) {
CHECK_EQ((int64_t)f.sch.plan().e.size(), 2ll);
}
/* A Gemma-like model (a sliding window over a full-attention trunk, no linear state) resumes a
* prefix hit only from a window snapshot at an earlier prompt's tail. One is taken wherever that
* position, a block short of the prompt's end, is kWindowSnapshotMin or more, at the default
* 2048-token interval too, so a short conversation's next turn resumes: the shortest prompt takes
* its snapshot at the floor and one token less takes none, and a prompt past an interval takes the
* one it always did. An interval under the floor is the floor. A 1000-token prompt runs whole, its
* snapshot taken inside the chunk: the window's rows are still held when it ends, so unlike linear
* state nothing makes the prompt split there. */
TEST(a_window_snapshot_is_taken_at_the_tail_of_a_short_prompt_too) {
Fixture f;
f.build(4096, 64, /*max_tok=*/2048, 4096, /*windowed=*/true, /*linear=*/false);
f.cfg.checkpoint_interval = 2048;
CHECK_OK(f.start());
CHECK(f.sch.geometry().window_ckpt);
const int64_t Q = f.sch.geometry().quantum, back = std::max<int64_t>(Q, 16);
const int64_t floor = Scheduler::kWindowSnapshotMin, shortest = floor + back;
CHECK_EQ(floor % Q, (int64_t)0);
CHECK_EQ(f.sch.tail_checkpoint(shortest), floor);
CHECK_EQ(f.sch.tail_checkpoint(shortest - 1), (int64_t)-1);
CHECK_EQ(f.sch.tail_checkpoint(400), (int64_t)-1);
CHECK_EQ(f.sch.tail_checkpoint(3000), (3000 - back) / Q * Q);
const int64_t t = (1000 - back) / Q * Q;
CHECK_EQ(f.sch.tail_checkpoint(1000), t);
f.submit(1000, 8);
const RadBatch* b = f.sch.step();
CHECK(b != nullptr);
CHECK_EQ(b->n_tok, 1000);
CHECK_EQ(b->n_checkpoints, 1);
CHECK_EQ(b->checkpoint_tok[0], t - 1);
Fixture g;
g.build(4096, 64, /*max_tok=*/2048, 4096, /*windowed=*/true, /*linear=*/false);
g.cfg.checkpoint_interval = 256;
CHECK_OK(g.start());
const int64_t I = g.sch.geometry().checkpoint_interval;
CHECK_EQ(I, (int64_t)256);
CHECK_EQ(g.sch.tail_checkpoint(I + back), I);
CHECK_EQ(g.sch.tail_checkpoint(I + back - 1), (int64_t)-1);
}
/* A prompt longer than the step budget takes its window snapshot inside its last chunk: the chunks
* before it are the budget's, and the last runs to the prompt's end with the snapshot at its tail
* row. */
TEST(a_long_prompt_takes_its_window_snapshot_inside_its_last_chunk) {
Fixture f;
f.build(4096, 64, /*max_tok=*/512, 4096, /*windowed=*/true, /*linear=*/false);
f.cfg.checkpoint_interval = 2048;
CHECK_OK(f.start());
const int64_t Q = f.sch.geometry().quantum, back = std::max<int64_t>(Q, 16);
const int64_t t = (1000 - back) / Q * Q;
f.submit(1000, 8);
const RadBatch* b = f.sch.step();
CHECK(b != nullptr);
CHECK_EQ(b->n_tok, 512);
CHECK_EQ(b->n_checkpoints, 0);
f.commit_plain();
b = f.sch.step();
CHECK(b != nullptr);
CHECK_EQ(b->n_tok, 1000 - 512);
CHECK_EQ(b->n_checkpoints, 1);
CHECK_EQ(b->checkpoint_tok[0], t - 512 - 1);
}
/* Under load a prompt's chunks are held back for the speculating decode rows behind it. Every prompt
* takes its window snapshot once, at its tail row, in whichever chunk carries that row: the final
* one, or a held-back one cut short of the prompt's end on a quantum. */
TEST(a_window_snapshot_under_load_lands_at_the_tail_whatever_chunk_carries_it) {
for (int64_t n = 600; n <= 1000; n += 24) {
Fixture f;
f.build(4096, 64, /*max_tok=*/256, 8192, /*windowed=*/true, /*linear=*/false);
f.cfg.checkpoint_interval = 2048;
f.cfg.n_spec = 7;
f.cfg.busy_prefill_chunk = -1;
CHECK_OK(f.start());
const int64_t Q = f.sch.geometry().quantum, back = std::max<int64_t>(Q, 16);
const int64_t t = (n - back) / Q * Q;
for (int d = 0; d < 4; ++d) f.submit(40, 4000);
for (int k = 0; k < 2; ++k) { CHECK(f.sch.step() != nullptr); f.commit_plain(11); }
const uint64_t p = f.submit(n, 8);
int snaps = 0;
for (int k = 0; k < 64 && f.sch.find(p) && f.sch.find(p)->n_computed < n; ++k) {
CHECK(f.sch.step() != nullptr);
for (const StepEntry& e : f.sch.plan().e) {
if (e.seq != p || e.ckpt_slot < 0) continue;
++snaps;
if (!(e.ctx_len < t && e.ctx_len + e.n_tokens >= t && e.ctx_len + e.ckpt_tok + 1 == t))
fprintf(stderr, " n %lld: chunk [%d, %d), snapshot at %d, tail %lld\n",
(long long)n, (int)e.ctx_len, (int)(e.ctx_len + e.n_tokens),
(int)(e.ctx_len + e.ckpt_tok + 1), (long long)t);
CHECK((int64_t)e.ctx_len < t && (int64_t)e.ctx_len + e.n_tokens >= t);
CHECK_EQ((int64_t)e.ctx_len + e.ckpt_tok + 1, t);
}
f.commit_plain(11);
}
if (snaps != 1) fprintf(stderr, " n %lld: %d snapshots\n", (long long)n, snaps);
CHECK_EQ(snaps, 1);
}
}
/* ================================================================== exact resume */
/* --prefix-resume exact (the default): a hit resumes only where an idle server's cold prefill of
* the same prompt starts a chunk, and a prompt's tail snapshot is where its last chunk starts. A
@@ -925,7 +1033,7 @@ TEST(an_exact_tail_snapshot_is_where_the_last_chunk_starts) {
/* One ending on the grid: the last chunk is [1536, 2048), and its end is an interval. */
c = cut_from(f.sch, 0, 2048, 512);
CHECK((c.ckpts == std::vector<int64_t>{ 1024, 1536, 2048 }));
/* Inside the first interval nothing (as before, cheap to prefill again). */
/* Inside the first interval nothing (as under nearest: cheap to prefill again). */
c = cut_from(f.sch, 0, 900, 512);
CHECK(c.ckpts.empty());
/* A step sharing its budget may straddle the tail: split there, the snapshot written. */
@@ -1366,8 +1474,7 @@ TEST(a_hit_on_a_model_with_a_windowed_group_reuses_nothing) {
/* The same model with the trunk's window in the checkpoint slot (KVGroupPlan::win_snap beside
* linear state, as DeepSeek-V4.1's sliding layers beside its compressor state): the hit resumes at
* the snapshot, which restores the linear state and the window together, and the cached group's
* blocks are adopted. Before, a model with linear state never put its window in the slot, so this
* clamp refused every hit on it. */
* blocks are adopted. */
TEST(a_hit_on_a_hybrid_whose_slot_carries_the_window_resumes_at_the_snapshot) {
Fixture f;
f.build(4096, 64, 512, 4096, /*windowed=*/true);
@@ -1405,8 +1512,7 @@ TEST(a_hit_on_a_hybrid_whose_slot_carries_the_window_resumes_at_the_snapshot) {
}
/* A trunk group the cache does not index and no slot carries is a hole no snapshot fills: a full
* group left out (as a group at another block size was before the cache took every block size)
* refuses the hit even where the window is in the slot. */
* group left out refuses the hit even where the window is in the slot. */
TEST(a_trunk_group_neither_cached_nor_in_the_slot_refuses_the_hit) {
Fixture f;
f.build(4096, 64, 512, 4096, /*windowed=*/true);
@@ -1958,6 +2064,28 @@ RefillRun refill_run(int n_prompt, int32_t seeded, int64_t ckpt_lo = 0) {
}
} /* namespace */
TEST(the_refill_window_is_the_retention_policys_drafter_floor) {
/* tip-only keeps a snapshot this deep below the tip, or a refill-capped hit has nothing to end
* on and the request decodes without drafts (KeepTipOnly). Without a refill the floor is 0. */
for (int spec : { 7, 0 }) {
Fixture f;
f.build(/*blocks=*/4096, /*states=*/64, /*max_tok=*/512, /*max_ctx=*/8192);
f.cfg.n_spec = spec;
f.prog.drafter.kind = RAD_DRAFT_BLOCK;
f.prog.drafter.window = 512;
KVGroupInfo w;
w.name = "draft";
w.decl.kind = RAD_KV_WINDOW;
w.decl.window = 512;
w.block_size = 16;
f.prog.kv_groups.push_back(w);
f.kv.setup(f.prog.kv_groups, f.cfg.max_ctx, 4096, 64);
f.pc.groups = { 0 };
CHECK_OK(f.start());
CHECK_EQ(f.pc.drafter_floor, spec ? (int64_t)512 : (int64_t)0);
}
}
TEST(a_prefix_hit_ends_a_drafter_window_before_the_prompt_and_the_drafter_drafts_at_once) {
const RefillRun r = refill_run(/*prompt=*/1100, /*seeded=*/1024);
/* The cap is 1100 - 512 = 588: attention 576, and the checkpoint under it 512. */
@@ -1985,6 +2113,51 @@ TEST(a_prefix_hit_with_no_checkpoint_near_the_cap_is_kept_whole) {
CHECK_EQ(r.rows, 0);
}
/* A Gemma-like model: a full-attention trunk with a sliding window and no linear state, so a hit
* resumes from the window snapshot taken at an earlier prompt's tail (ChunkGeometry::window_ckpt),
* and a windowed block drafter. When that snapshot carries the trunk's window only, draft refill
* cannot cut the hit (no snapshot a window back), the whole hit stands and the drafter waits for
* its window; when it carries the drafter's window too (a block drafter on the card's driver,
* KVManager::set_drafter_window_snapshot), there is no hole, no refill, and the drafter drafts from
* the first decode. */
TEST(a_prefix_hit_whose_window_snapshot_carries_the_drafters_window_drafts_at_once) {
for (int with_drafter = 0; with_drafter < 2; ++with_drafter) {
Fixture f;
f.build(/*blocks=*/4096, /*states=*/64, /*max_tok=*/512, /*max_ctx=*/8192,
/*windowed=*/true, /*linear=*/false);
f.cfg.n_spec = 7;
f.prog.drafter.kind = RAD_DRAFT_BLOCK;
f.prog.drafter.window = 512;
KVGroupInfo w;
w.name = "draft";
w.decl.kind = RAD_KV_WINDOW;
w.decl.window = 512;
w.block_size = 16;
f.prog.kv_groups.push_back(w);
f.kv.setup(f.prog.kv_groups, f.cfg.max_ctx, 4096, 64);
const int32_t swa = 1, draft = 2;
f.kv.snap = with_drafter ? std::vector<int32_t>{ swa, draft } : std::vector<int32_t>{ swa };
f.pc.groups = { 0 };
f.pc.ckpt_lo = 2048; /* the earlier prompt's tail snapshot, none below it */
CHECK_OK(f.start());
CHECK(f.sch.geometry().window_ckpt);
f.pc.seed(2048); f.pc.lin = 2048; f.pc.src = 3;
const uint64_t a = f.submit(2200, 64);
Scheduler::BlockRow rows[4];
int n_rows = -1;
for (int st = 0; st < 40; ++st) {
CHECK(f.sch.step() != nullptr);
if (st == 0) CHECK_EQ(f.sch.find(a)->n_computed, (int64_t)2048);
f.commit_plain(11);
const int n = f.sch.block_begin(8, 7, 512, 99, rows, 4);
f.sch.block_end();
if (!f.sch.find(a)->output.empty()) { n_rows = n; break; }
}
CHECK_EQ(f.sch.metrics().draft_refills, (int64_t)0);
CHECK_EQ(n_rows, with_drafter ? 1 : 0);
}
}
/* z-lab's DFlash on the Gemma 4 31B: a full-attention block drafter (no window), whose own group the
* prefix cache indexes like the trunk's full layers. A hit resumes the trunk's window from the
* window snapshot, so no paged group is left with a hole and the drafter drafts from the first
@@ -2028,6 +2201,23 @@ TEST(a_full_attention_drafter_drafts_at_once_after_a_hit_the_window_snapshot_res
}
}
/* The short block's switch (--draft-short-from): on from the threshold, off again two below, and
* off at one decoding sequence whatever the threshold, where the long block pays. From 2 (a tree's
* auto) a load of 2, 1, 1 runs it, then not; from 8, 8 then 7 keeps it and 6 drops it. */
TEST(the_short_block_switches_off_at_one_sequence) {
bool on = false;
on = Scheduler::short_block_on(on, 2, 2); CHECK(on);
on = Scheduler::short_block_on(on, 1, 2); CHECK(!on);
on = Scheduler::short_block_on(on, 1, 2); CHECK(!on);
on = Scheduler::short_block_on(on, 0, 2); CHECK(!on);
on = Scheduler::short_block_on(false, 8, 8); CHECK(on);
on = Scheduler::short_block_on(on, 7, 8); CHECK(on);
on = Scheduler::short_block_on(on, 6, 8); CHECK(!on);
on = Scheduler::short_block_on(on, 7, 8); CHECK(!on);
CHECK(Scheduler::short_block_on(false, 1, 1)); /* from 1: every sequence runs it */
CHECK(!Scheduler::short_block_on(true, 0, 1));
}
TEST(no_prefix_hit_gives_nothing_back) {
const RefillRun r = refill_run(1100, 0);
CHECK_EQ(r.m.draft_refills, (int64_t)0);