radiance 1.12.0

New models:
- Fish Audio drama-3: speech with speaker tags and inline direction, voices cloned from reference
  clips (the `references` field of /v1/audio/speech and the streaming session), two cards
- Gemma 4 E2B/E4B (KV-shared layers, per-layer embeddings, clipped vision linears), with
  NVIDIA-Nemotron-3.5-Bolt-E4B in bf16 with DFlash and vision on one card, and E4B recipes

Speed:
- MXFP4 GEMMs for one to 64 rows and a tiled prefill GEMM at TN=4 from 1024 rows: the 27B MXFP4
  with DFlash2 decodes about 1% faster at c1, 5% at c4 and 14% at c16
- The fp8 and int8 LM heads read their weight once for 65 to 128 rows
- A prefill step of one sequence runs in two pieces on a second lane at two ranks (qwen35_fp8,
  gemma3): a 45K-token prompt on the 27B fp8 in 15.1 s instead of 16.2 s
- Gemma 3's fused all-reduce junctions also under a lossy wire
- --draft-short-from N: a block drafter runs its shorter block from N decoding sequences on
  (off by default; with 8 on the 27B MXFP4: c8 +12%, c16 +18%, c64 +32%, c1 unchanged)
- --tp-attn-split rows: GLM-5.3-Flash's MLA attention split by rows over the ranks, 18 to 21%
  faster prefill; lossy, `heads` stays the default
- --draft-coupling on: Qwen3.8-Flash-Next's MTP drafter samples its proposals from its reranked
  top-8 and the target's draw is coupled to it; pays at high temperatures (c1 at T 1.0: 155 ->
  178 tok/s), costs at low ones; off by default

Features:
- Edited prompts on windowed models (Gemma 4) reuse their prefix: periodic window snapshots, and
  snapshot-backed prefix KV kept across recomputes (an edited tail on Gemma 4 31B: 96 s -> 2.6 s)
- DELETE /sessions/<label> and DELETE /sessions?id=<id> forget one stored conversation
- --state-cache-dtype f16: the delta-net state cache at half the memory (qwen35 plugins; lossy)

Fixes:
- A browser's CORS preflight allows DELETE

Changes: Plugin ABI 27: out-of-tree plugins must be rebuilt. The environment switches the PRs
added are flags now (--tp-attn-split, --draft-coupling, --state-cache-dtype).
This commit is contained in:
137 files changed
+12959 -1126

No files matched your search

+186 -3
View File
@@ -11,6 +11,7 @@
#include "gbnf_oracle.h"
#include "sample/grammar.h"
#include "sample/host_ref.h"
#include "sample/mtp_couple_evidence.h"
#include "sample/sampler.h"
#include "sample/vocab_view.h"
#include "text/tokenizer.h"
@@ -1496,6 +1497,7 @@ struct HostChain {
int64_t nv = 0;
bool ok = false;
int st = RAD_OK;
int64_t step_no = 0; /* the engine step the next step() stages for */
static inline HostChain* cur = nullptr;
static void trampoline(RadCtx* c, const RadBatch*) {
@@ -1503,11 +1505,15 @@ struct HostChain {
}
HostChain(int64_t n_vocab, int64_t max_seqs, int max_spec, const VocabView* vocab = nullptr,
int64_t max_candidates = 8)
int64_t max_candidates = 8, const char* second_plugin = nullptr,
bool draft_coupling = false)
: nv(n_vocab) {
/* libref alone: it is the implementation under test, and a directory scan would also
* pick up whatever else was built beside it. */
if (reg.load_plugin(home() + "/kernels/libref.so", 0) < 0) return;
/* A second library by name, for an op libref does not carry (the coupling's verify op is
* the spechub plugin's, host row included). */
if (second_plugin && reg.load_plugin(home() + "/kernels/" + second_plugin, 0) < 0) return;
RadModelMeta meta{};
meta.arch_id = "sampler_chain";
meta.name = "sampler_chain";
@@ -1542,6 +1548,7 @@ struct HostChain {
cfg.max_spec = max_spec;
cfg.max_hist = 64;
cfg.max_candidates = max_candidates;
cfg.draft_coupling = draft_coupling;
if (s.declare(&b, cfg) < 0) return;
if (b.finish() < 0) return;
prog = std::move(b.program());
@@ -1570,7 +1577,7 @@ struct HostChain {
const int b = s.begin_request(r->id, r->sp, &err);
if (b < 0) return b;
}
const int bs = s.build_step(reqs);
const int bs = s.build_step(reqs, step_no++);
if (bs < 0) return bs;
int64_t n = 0;
s.staged_params(&n);
@@ -1610,6 +1617,27 @@ Request make_req(uint64_t id, std::vector<int32_t> prompt, const SamplingParams&
return r;
}
/* The per-round states the engine binds after a live commit: `rounds` sampled states of `id`,
* each at `first_pos + rd - 1`, proposing the matching draft token. */
void couple_states(uint64_t id, uint64_t seed, const int32_t* draft, int rounds,
uint64_t first_pos, RadMtpCoupleState* out) {
for (int rd = 1; rd <= rounds; ++rd) {
RadMtpCoupleState& c = out[rd - 1];
c = RadMtpCoupleState{};
c.draw.seq = id;
c.draw.seed = seed;
c.draw.mode = 1;
c.round = rd;
c.status = 1;
c.count = 1;
c.x = draft[rd - 1];
for (int i = 0; i < 8; ++i) c.ids[i] = -1;
c.ids[0] = c.x;
c.q[0] = 1.0;
c.pos = first_pos + (uint64_t)(rd - 1);
}
}
SamplingParams greedy_params() {
SamplingParams sp;
sp.temp = 0.0f;
@@ -3291,4 +3319,159 @@ TEST(a_dry_row_with_breakers_has_its_raw_logprob) {
CHECK_NEAR(lp.logprob, 5.0 - log_sum_exp(lg), 1e-5);
}
RAD_TEST_MAIN()
/* ================================================== the coupled verify row */
/* THE COUPLED STATE AT THE SAMPLER'S OWN BUILD.
*
* The engine binds a round's state at `n_out + (round - 1)` (core/sched/mtp_couple_bind.h, through
* rad_mtp_couple_verify_pos), and build_step stages row k of the request at `n_out + k`, taking the
* state only when it names that exact row (rad_mtp_couple_binds). This drives the REAL build_step
* with the coupling on: the bound rounds become the draft rows' states, the bonus row stays
* unbound, and a state one position ahead -- what the engine's old `base + n_acc` formula produced
* once a commit came up short -- is refused. A refused row is deliberately silent in production;
* here it is the assertion.
*
* The verify op is declared by the spechub plugin, whose host row (ref_mtp_couple_verify) is what
* makes the declaration succeed here; build_step alone is driven, so the op never runs. */
TEST(the_coupled_state_is_staged_only_at_the_row_it_was_bound_for) {
HostChain ch(64, 2, 3, nullptr, 8, "spechub.so", true);
if (!ch.ok) {
fprintf(stderr, " SKIP %s: libref/spechub did not load from %s/kernels\n",
::radtest::current(), home().c_str());
return;
}
SamplingParams sp;
sp.temp = 1.0f;
const int32_t draft[3] = { 21, 22, 23 };
Request r = make_req(7, { 1, 2, 3 }, sp);
r.draft = draft;
r.n_draft = 3;
std::string err;
CHECK_OK(ch.s.begin_request(r.id, r.sp, &err));
/* The states the engine binds after a live commit, at the positions it writes them. */
const uint64_t n_out = r.output.size();
auto states_at = [&](uint64_t first_pos, RadMtpCoupleState* out) {
couple_states(r.id, r.sp.seed, draft, 3, first_pos, out);
};
RadMtpCoupleState bound[3];
states_at(rad_mtp_couple_verify_pos(n_out, 1), bound);
CHECK_OK(ch.s.set_mtp_couple(r.id, bound, 3));
std::vector<Request*> reqs = { &r };
CHECK_OK(ch.s.build_step(reqs));
int64_t n = 0;
const DeviceSampleParams* p = ch.s.staged_params(&n);
CHECK_EQ(n, 4); /* three draft rows and the bonus row */
CHECK(ch.s.staged_any_couple());
for (int k = 0; k < 3; ++k) {
CHECK_EQ(ch.s.staged_couple(k).round, k + 1);
CHECK_EQ(ch.s.staged_couple(k).x, draft[k]);
CHECK_EQ(ch.s.staged_couple(k).pos, rad_mtp_couple_verify_pos(n_out, k + 1));
/* The row is sampled at the position its state names -- asserted against the row itself,
* not through the formula, so a drifted formula cannot move both sides together. */
CHECK_EQ(p[k].pos, n_out + (uint64_t)k);
CHECK_EQ(ch.s.staged_couple(k).pos, p[k].pos);
}
CHECK_EQ(ch.s.staged_couple(3).round, 0); /* the bonus row carries no law */
/* A position one ahead of the row: every row is refused, so the batch issues no verify. */
RadMtpCoupleState ahead[3];
states_at(rad_mtp_couple_verify_pos(n_out, 1) + 1, ahead);
CHECK_OK(ch.s.set_mtp_couple(r.id, ahead, 3));
CHECK_OK(ch.s.build_step(reqs));
CHECK(!ch.s.staged_any_couple());
for (int k = 0; k < 4; ++k) CHECK_EQ(ch.s.staged_couple(k).round, 0);
/* REUSE: an ended request's binding is gone, and a new one starts unbound. */
ch.s.end_request(r.id);
CHECK_EQ(ch.s.set_mtp_couple(r.id, bound, 3), RAD_E_NOTFOUND);
Request r2 = make_req(8, { 1, 2, 3 }, sp);
r2.draft = draft;
r2.n_draft = 3;
CHECK_OK(ch.s.begin_request(r2.id, r2.sp, &err));
CHECK_OK(ch.s.build_step({ &r2 }));
CHECK(!ch.s.staged_any_couple());
}
/* THE SNAPSHOT THE EVIDENCE READS.
*
* In the coupled serial path build_step stages the bound rows, then the drafter's build_greedy
* clears any_couple_ and replaces the staged rows before collect_step's wait returns. An evidence
* line gated on staged_any_couple() therefore never fires -- and forced, it would list the greedy
* pass's rows. This drives the real chain for two requests: build_step, run() issuing the verify
* op, build_greedy (where issue_serial_drafter calls it), then the evidence decision over the
* frozen snapshot. The negatives are what the line must not count: a terminal request, another
* step's snapshot, and a host row. */
TEST(the_coupled_evidence_survives_the_drafters_greedy_build) {
HostChain ch(64, 2, 3, nullptr, 8, "spechub.so", true);
if (!ch.ok) {
fprintf(stderr, " SKIP %s: libref/spechub did not load from %s/kernels\n",
::radtest::current(), home().c_str());
return;
}
SamplingParams sp;
sp.temp = 1.0f;
const int32_t draft[3] = { 21, 22, 23 };
Request a = make_req(7, { 1, 2, 3 }, sp);
Request b = make_req(8, { 4, 5, 6 }, sp);
a.draft = b.draft = draft;
a.n_draft = b.n_draft = 3;
std::string err;
for (Request* r : { &a, &b }) {
CHECK_OK(ch.s.begin_request(r->id, r->sp, &err));
RadMtpCoupleState bound[3];
couple_states(r->id, r->sp.seed, draft, 3, rad_mtp_couple_verify_pos(r->output.size(), 1),
bound);
CHECK_OK(ch.s.set_mtp_couple(r->id, bound, 3));
}
std::vector<float> lg(8 * 64, 0.0f); /* two requests, 3 draft rows + bonus each */
for (int row = 0; row < 8; ++row) lg[(size_t)row * 64 + 5] = 5.0f;
std::vector<int32_t> tok;
CHECK_OK(ch.step({ &a, &b }, lg, &tok));
const int64_t step = ch.step_no - 1;
const Sampler::CoupleBuild& cb = ch.s.couple_build();
CHECK_EQ(cb.step, step);
CHECK_EQ(cb.rows, (int64_t)6);
REQUIRE_EQ(cb.seqs.size(), (size_t)2);
CHECK_EQ(cb.seqs[0].first, (uint64_t)7);
CHECK_EQ(cb.seqs[0].second, (int64_t)3);
CHECK_EQ(cb.seqs[1].first, (uint64_t)8);
CHECK_EQ(cb.seqs[1].second, (int64_t)3);
/* run() issued the verify op for THIS build, not merely staged rows for it. */
CHECK_EQ(ch.s.staged_couple_issued_step(), step);
/* The drafter's greedy passes, where issue_serial_drafter runs them: after the build, before
* the wait. The old gate is false now; the snapshot is not the greedy pass's. */
CHECK_OK(ch.s.build_greedy(4));
CHECK(!ch.s.staged_any_couple());
CHECK_EQ(ch.s.couple_build().step, step);
CHECK_EQ(ch.s.couple_build().rows, (int64_t)6);
auto all_live = [](uint64_t) { return true; };
MtpCoupleEvidence ev = mtp_couple_evidence(cb, step, RAD_DOMAIN_DEVICE, all_live);
CHECK_EQ(ev.rows, (int64_t)6);
CHECK(ev.device);
CHECK_EQ(ev.seqs, std::string("7,8"));
/* A terminal request is not counted: b finished while the step ran. */
ev = mtp_couple_evidence(cb, step, RAD_DOMAIN_DEVICE, [](uint64_t s) { return s == 7; });
CHECK_EQ(ev.rows, (int64_t)3);
CHECK_EQ(ev.seqs, std::string("7"));
/* Nothing live, or another step's snapshot: no evidence. */
CHECK_EQ(mtp_couple_evidence(cb, step, RAD_DOMAIN_DEVICE, [](uint64_t) { return false; }).rows,
(int64_t)0);
CHECK_EQ(mtp_couple_evidence(cb, step + 1, RAD_DOMAIN_DEVICE, all_live).rows, (int64_t)0);
/* A host row is reported as host, not read as a device verify. */
ev = mtp_couple_evidence(cb, step, RAD_DOMAIN_HOST, all_live);
CHECK(!ev.device);
CHECK_EQ(ev.rows, (int64_t)6);
}
RAD_TEST_MAIN()