radiance 1.15.0

New models and formats:
- IQR for Qwen3.8-27B: weights on the int8 grid under GPTQ, a trellis down each GPTQ column
  (IQR-V2), and IQR-V3, a computed trellis code under one scale a row, kept at its codes' width in
  VRAM and decoded in the GEMM; 15 IQR-V3 recipes from ~2 to ~7 bits a weight
  (data/recipes/q38-27b-*-v3.recipe, docs/IQR.md)
- libhalo: a kernel library for Strix Halo (gfx1151), preferred there over libr3d
- Nemotron 3.5 Embed 1B and 8B (nemotron35_embed): text and image embeddings through a Pixtral
  tower, on the card and on the CPU
- Nemotron 3.5 Rerank 8B
- /v1/systemone: Cloudflare's clef and clef-flash, Convai Innovations' Laya and Mica beside
  LiquidAI d1; scored steps read the candidates' logits from the head table with no lm_head pass
- LFM2's 8-bit trunk: block-fp8 or int8 linears with the fused producers, and the d1-3B recipe
- DeepSeek-V4.1's reply format with DSML tool calls and typed argument tags

Weights on the drive:
- The file tier reads only the experts the pass routes rows to; the draft head's weights stay in
  the host pool
- A hot VRAM cache for routed experts read off the drive, reads deposited straight into free host
  pool slots, and copyless evictions; the file tier's counters are now ssd_*
- GLM-5 Next shards its routed experts by expert, not by width, so they can live on the drive
- The stall watch counts drive reads as progress, and the DMA lane's room check reads the lane's
  own completion fence

Quantisation tooling:
- --calib-corpus, --calib-dir and --calib-layers record each linear's input Hessian; beside
  --kld-record the reference's own run records them
- --kld-top N records a sparse KL reference (the N most likely tokens and the tail's mass)
- GPTQ in a third of the time with the same codes, trellis GPTQ on the card, vector codebooks
  with coordinate descent, and rad-convert --reuse repeated, each container supplying what the
  earlier ones lack

Speculation:
- Prompt lookup alone (--spec-ngram K, --spec-ngram-min/-max): each sequence keeps an index of its
  n-grams, and a proposal is verified only when its measured step cost says it pays;
  --draft-window adaptive follows it

Speed:
- IQR decode: the narrow tile splits K for four times the int8 tile's waves and folds each 128-K
  block once; at 8 tokens down and the output projections run in 0.61-0.82x and 0.70-0.92x FP8's
  time (2-6 bits); IQ6R-S-V3 with its DFlash2 drafter steps in 26.3 ms at TP2, against 29.4 ms
  before and FP8's 27.3
- Qwen MXFP4 feed-forward: the gated fold up to 16 rows, not 8
- libr4d: the gated prefill fold, the short-prompt split row, and the rows forms of rmsnorm and
  rope; KLATE again for the head-256 gqa6 paged prefill; gram_accum on the matrix cores

Features:
- /health, /v1/health and /ping answer 503 with "status": "stuck" once the device has advanced
  nothing for a minute or a queue has faulted, so a supervisor can restart a wedged server (#356)
- --image-gen-max-pixels and --image-gen-max-refs size an image generator's buffers (#344)
- The startup report lists only the options not at their default, with a count; -v lists all
  (#250)
- --preempt-wait-ms bounds how long a preempted prefill waits for its whole-recompute room
- --placement layer_offload spills dense layers so one --max-model-len sequence fits
- Startup refuses amdgpu with CWSR off and says how to fix it;
  --proceed-with-incompatible-configuration starts anyway under an UNSUPPORTED banner

Fixes:
- The n-gram read-ahead hands each row to the reader once and reads only as far ahead as the row
  cache holds, and pauses while decode reads: about one drive read a row instead of two (#355)
- A file-tier window reads each of its runs once, not once a run per run
- The decode split law's verify floor is bounded by the batch's workgroups: max_seqs 256 no longer
  declares 64x the scratch (#342)
- A prefetch DMA list's mark stays out of the signal pool until the engine has read it, and a
  prefill stage copies only the blocks its own tables name (#343)
- The split-KV row sum is read with fetch-inactive (#328)
- LFM2 on the host backend: libref and libavx serve the row-form ops it declares (#348)
- The preempted-prefill gate skips a KV group that holds no blocks (#352)
- Every request entry point bounded, gated and sanitised (JSON depth, invalid UTF-8, control bytes
  in the log, the dashboard's CSP, cross-origin browsers on the loopback-only routes); a prompt id
  outside the vocabulary refused at admission; --api-key "" refused at startup
- The telemetry the HTTP thread reads is atomic
- An RMS norm row no longer depends on how many rows its launch carries; prefill attention's
  rescale is decided by live rows only
- A --kld-record prefill chunk that finishes no sequence gets its logits on a tied-head model
- A kernel's lazily made counter block is zeroed outside the lock other ranks take (a TP2 first-step
  hang)

Changes: Plugin ABI 32. Every plugin exports a layout fingerprint of the ABI structs and the loader
refuses a plugin without it or with another (#302), so out-of-tree plugins must be rebuilt.
Appended: RadBuildCtx calib_* and gen_max_*, RadArchProbe gen_max_*, RadBatch score_only and
plugin_words, RadDeviceProps::unified, RadChatFormat arg_json_value_prefix.
This commit is contained in:
Deadcode committed 2026-10-30 22:01:01 +01:00
commit 9ed3ef7a7b
452 files changed
+167762 -1346

No files matched your search

+58 -12
View File
@@ -14,9 +14,11 @@
namespace rad {
/* Steps of the following prompt a prefill batch carries for the PLE read-ahead queue
* (RadBatch::n_ahead), whose rows the arch's reader thread prefetches off the step path. Keep in
* step with rad_block_ple.h's kAheadChunks, which clamps to the buffer it declared. */
static constexpr int64_t k_ahead_chunks = 8;
* (RadBatch::n_ahead), whose rows the arch's reader thread prefetches off the step path. Two: the
* reader needs to run one chunk ahead of the gather, and libavx hands it at most a quarter of its
* row cache (avx_ngram.cpp, kAheadRows), two chunks of 4096 tokens at 16 rows each. Keep in step
* with rad_block_ple.h's kAheadChunks, which clamps to the buffer it declared. */
static constexpr int64_t k_ahead_chunks = 2;
/* Alignment of each staging array carved from a set's slab. One slab per set means a couple of
* allocations at init instead of two dozen, with every array sharing one mapping. */
@@ -136,6 +138,9 @@ void BatchBuilder::carve(Set& s, char* h) {
/* Each row's adapter slot, carved only when the engine serves adapters, so an engine without
* them lays the slab out as if the array did not exist. */
pair(&s.h_lora, &s.d_lora, lora_on_ ? T : 0);
/* Each sequence's words for the plugin, carved only when the program declared a bound. */
pair(&s.h_pw, &s.d_pw, pw_cap_ ? S * pw_cap_ : 0);
pair(&s.h_pwcu, &s.d_pwcu, pw_cap_ ? S + 1 : 0);
/* Host-only (derived metadata is copied into the planned arena), but carved on both sides to
* keep device offsets equal to host offsets. */
{
@@ -240,6 +245,9 @@ int BatchBuilder::alloc_set(Set& s, const std::vector<KVGroupInfo>& groups) {
o.kv.assign(ranks_.size(), std::vector<RadKVGroupBatch>(s.groups.size()));
o.stream.assign(ranks_.size(), std::vector<RadKVStream>(s.groups.size()));
o.batch.assign(ranks_.size(), RadBatch{});
o.seqs.clear();
o.seqs.reserve((size_t)max_seqs_); /* a build fills it without allocating */
o.has_seqs = false;
}
pitch_.assign(s.groups.size(), 1);
bt_mirror_.assign(s.groups.size(), BtMirror{});
@@ -473,6 +481,7 @@ int BatchBuilder::layout(Program& prog, const Config& cfg) {
mm_on_ = prog.encoder.modalities != 0 || prog.audio_encoder.modalities != 0;
lora_on_ = cfg.lora.enabled();
pw_cap_ = prog.plugin_words;
return RAD_OK;
}
@@ -909,6 +918,9 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
RAD_TRY_NULL(reserve(need, &off));
carve(s, ring_.host + off);
Out& o = out_[out_next_];
o.has_seqs = true;
o.seqs.clear();
for (const StepEntry& e : plan.e) o.seqs.push_back(e.seq);
const int64_t n_tok = plan.n_tok;
@@ -923,6 +935,8 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
int64_t n_mm = 0;
bool lora_rows = false;
int32_t cvec_rows = 0;
int64_t n_pw = 0;
if (pw_cap_) s.h_pwcu[0] = 0;
s.h_cu[0] = 0;
for (int64_t i = 0; i < n_seq; ++i) {
const StepEntry& e = plan.e[(size_t)i];
@@ -1023,9 +1037,25 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
const int32_t nr = e.hidden_n > 0 ? e.hidden_n : e.n_tokens;
for (int32_t j = 0; j < nr; ++j) s.h_out[n_out++] = e.hidden_row + j;
} else if (e.produces_token) {
/* The request's words for the plugin ride the trunk step that samples its prompt's
* first token (RadBatch::plugin_words); word 0 is that row's index in `out_ids`. */
if (pw_cap_ && e.is_prefill && plan.draft_pass == 0 && e.req &&
!e.req->plugin_words.empty()) {
const std::vector<int32_t>& w = e.req->plugin_words;
if ((int64_t)w.size() > pw_cap_) {
RAD_ERR("step batch: sequence %llu carries %zu words for the plugin, past the "
"%lld it declared", (unsigned long long)e.seq, w.size(),
(long long)pw_cap_);
return nullptr;
}
std::memcpy(s.h_pw + n_pw, w.data(), w.size() * sizeof(int32_t));
s.h_pw[n_pw] = (int32_t)n_out;
n_pw += (int64_t)w.size();
}
const int32_t first = (int32_t)(k + e.n_tokens) - 1 - e.n_spec;
for (int32_t j = 0; j <= e.n_spec; ++j) s.h_out[n_out++] = first + j;
}
if (pw_cap_) s.h_pwcu[i + 1] = (int32_t)n_pw;
if (e.draft_out) s.h_dout[n_dout++] = (int32_t)(k + e.n_tokens - 1);
/* RADIANCE_DFLASH_TRACE logs each drafter pass's kind, positions and token ids. A wrong
* anchor, mask id or position base shows only as near-zero acceptance with correct
@@ -1150,18 +1180,18 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
}
/* A scored step (RadBatch::score_only): every sampled row is a scored request's first row, on
* one rank, in a program that told the core where its hidden rows and head table are. */
* one rank, in a program that told the core where its hidden rows and head table are. Each
* such entry gives one row, so the step is scored only when they account for all n_out: a
* mid-prefill chunk's KLD rows or an entry's own hidden rows still need the lm_head. */
int32_t score_only = 0;
if (n_out > 0 && n_dout == 0 && !plan.draft_pass && ranks_.size() == 1 &&
prog_->score_hidden != RAD_NULL_HANDLE && prog_->score_table != RAD_NULL_HANDLE) {
score_only = 1;
for (const StepEntry& e : plan.e) {
if (!e.produces_token) continue;
if (!e.req || !e.req->token_scores || !e.req->output.empty() || e.n_spec > 0) {
score_only = 0;
break;
}
}
int64_t scored = 0;
for (const StepEntry& e : plan.e)
if (e.produces_token && e.hidden_row < 0 && e.req && e.req->token_scores &&
e.req->output.empty() && e.n_spec == 0)
++scored;
score_only = scored == n_out;
}
/* ---------------------------------------------------------- the batch, one per rank */
@@ -1209,6 +1239,11 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
* runs the same pass as an engine serving no adapters. */
B.lora_slot = lora_rows ? on_rank(base, b0, s.d_lora) : nullptr;
B.control_vector = cvec_rows;
B.n_plugin_words = n_pw;
B.plugin_words = n_pw ? on_rank(base, b0, s.d_pw) : nullptr;
B.plugin_cu = n_pw ? on_rank(base, b0, s.d_pwcu) : nullptr;
B.plugin_words_h = n_pw ? s.h_pw : nullptr;
B.plugin_cu_h = n_pw ? s.h_pwcu : nullptr;
B.enc = 0;
B.enc_n_patch = 0;
B.enc_pixels = nullptr;
@@ -1245,6 +1280,14 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
return &o.batch[0];
}
const std::vector<uint64_t>* BatchBuilder::step_seqs(const RadBatch* b) const {
if (!b) return nullptr;
for (const Out& o : out_)
for (const RadBatch& rb : o.batch)
if (&rb == b) return o.has_seqs ? &o.seqs : nullptr;
return nullptr;
}
const RadBatch* BatchBuilder::batch_for(int rank) const {
if (out_last_ < 0) return nullptr;
const Out& o = out_[out_last_];
@@ -1346,6 +1389,9 @@ const RadBatch* BatchBuilder::build_encoder(const std::vector<EncoderPart>& part
}
}
Out& o = out_[out_next_];
/* An encoder pass runs no sequence's KV. */
o.has_seqs = false;
o.seqs.clear();
for (size_t r = 0; r < ranks_.size(); ++r) {
RadBatch& B = o.batch[r];
B = RadBatch{};
+14
View File
@@ -140,6 +140,11 @@ public:
* round, slot state and inputs (advance.h). */
AdvanceArgs advance_args(int rank) const;
/* The sequences of `b`, a batch build() returned that is still valid (any rank's), in row
* order; null for another batch (an encoder pass). What a streamed group's prefill stage
* copies is read from their tables (kvstream/stage.h, "Volume"). */
const std::vector<uint64_t>* step_seqs(const RadBatch* b) const;
/* Longest sequence a batch can describe, in tokens, as sized into the block-table rows at
* init. A position at or past it cannot be addressed. */
int64_t max_ctx() const { return max_ctx_; }
@@ -224,6 +229,10 @@ private:
/* [n_tok] each row's runtime LoRA adapter slot (RadBatch::lora_slot): carved only when the
* engine serves adapters, empty otherwise. */
int32_t *h_lora = nullptr, *d_lora = nullptr;
/* [max_seqs * plugin_words] and [max_seqs + 1]: each sequence's words for the plugin
* (RadBatch::plugin_words), carved only when the program declared a bound. */
int32_t *h_pw = nullptr, *d_pw = nullptr;
int32_t *h_pwcu = nullptr, *d_pwcu = nullptr;
/* [n_kv_groups][max_seqs]: every conv group's state slot per sequence (see init()). */
int32_t* h_convslot = nullptr;
@@ -256,6 +265,9 @@ private:
/* Per rank and group, the RadKVStream a batch names: each rank's own copy, outside the slab. */
std::vector<std::vector<RadKVStream>> stream;
std::vector<RadBatch> batch;
/* The build's sequences in row order (step_seqs); none for an encoder pass. */
std::vector<uint64_t> seqs;
bool has_seqs = false;
};
struct Derived {
@@ -334,6 +346,8 @@ private:
bool mm_on_ = false;
/* The engine serves runtime LoRA adapters (Config::lora): the batch carries each row's slot. */
bool lora_on_ = false;
/* Program::plugin_words: the words a sequence may carry, 0 for none. */
int64_t pw_cap_ = 0;
int64_t n_embd_ = 0;
std::vector<void*> mm_dev_;
uint16_t* mm_host_ = nullptr;
+1 -1
View File
@@ -310,7 +310,7 @@ int Scheduler::add_locked(std::unique_ptr<Request> r) {
if (r->embed && (int64_t)r->prompt.size() > cfg_.max_tok) return RAD_E_INVAL;
/* Every prompt id, tokenised or client-supplied, names a real vocabulary row: an id past the
* embedding table is refused at admission, never staged into a pass. Raw id arrays reach here
* straight from the request body, and an op failing mid-step is a device fault (spec §17) —
* straight from the request body, and an op failing mid-step is a device fault (spec §17) --
* the whole engine would die for one bad number. Same bound as the scored-prompt check below.
*/
for (int32_t t : r->prompt)
+2
View File
@@ -178,6 +178,8 @@ public:
/* The batch the last build produced for one rank; see BatchBuilder::batch_for. */
const RadBatch* batch_for(int rank) const { return builder_.batch_for(rank); }
/* See BatchBuilder::step_seqs. */
const std::vector<uint64_t>* step_seqs(const RadBatch* b) const { return builder_.step_seqs(b); }
/* The advance's view of that build on one rank; see BatchBuilder::advance_args. Also carries
* the serial head's shape, which only the draft passes' modes read. */
AdvanceArgs advance_args(int rank) const {