radiance 1.7.0

- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves
  every shipped container
- Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime
- /v1/messages works with Claude Code as it ships (gearwave00001)
- a long agent conversation keeps its cached history when the client rewrites its last turn
  (manueloverride)
- a stream's first event goes out with the first token, so llama-benchy measures prefill right
- opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42)
- four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b)
- NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA
  adapters (baKon)
- many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool
  arguments and the CPU's vision and audio encoders
- plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
This commit is contained in:
Deadcode committed 2026-10-16 18:25:18 +02:00
1 parent b068190326
commit 1e968f6e1d
739 files changed
+128447 -84632

No files matched your search

+52 -42
View File
@@ -1,27 +1,40 @@
/* bands.cpp -- the bucket table. spec.md §2.2.
*
* A parameter may be declared as a range rather than a value, because some of them are properties
* of the batch and not of the model. M is the obvious one: a GEMM sees one row at decode,
* sixty-four at a speculative verify and thousands in a prefill chunk, and libr4d has a different
* kernel for each band. Resolving once at M = max_tok would pick the prefill kernel and then run
* it at M = 1, which is exactly the loss that skinny-GEMM specialisation exists to recover.
* A parameter may be declared as a range, because some parameters belong to the batch rather
* than the model. M is the main one: a GEMM sees one row at decode, 64 at a speculative verify
* and thousands in a prefill chunk, and libr4d has a different kernel for each band. Resolving
* once at M = max_tok would run the prefill kernel at M = 1.
*
* THE BUCKET BOUNDARIES ARE THE CONSTRAINT VALUES THEMSELVES. Nothing here picks a policy, a
* power-of-two ladder or a bucket count: the kernels already said where their bands end, and this
* file only collects what they said. A kernel whose fast band sits at an odd boundary gets that
* boundary, because it said so.
* The bucket boundaries are the candidate kernels' own constraint values. There is no
* power-of-two ladder or bucket-count policy here.
*/
#include "registry.h"
#include <algorithm>
#include <cstdlib>
#include <string>
namespace rad {
namespace {
/* "M <= 64" for the first band, "M in (16, 64]" for a later one -- the half-open form is what a
* band actually is, and a reader who sees only "<= 64" on the second row will read the table as
* overlapping. */
/* The DIV a row places on the ranged parameter, or the least common multiple of several; 0 when
* it places none. */
int64_t ranged_div(const KernelRow* r, std::string_view key) {
if (!r || !r->info || key.empty()) return 0;
int64_t d = 0;
for (int i = 0; i < r->info->n_constraints; ++i) {
const RadConstraint& c = r->info->constraints[i];
if (c.op != RAD_C_DIV || !c.key || key != c.key || c.ival <= 1) continue;
int64_t a = d ? d : 1, b = c.ival;
while (b) { const int64_t t = a % b; a = b; b = t; }
d = (d ? d : 1) / a * c.ival;
}
return d;
}
/* "M <= 64" for the first band, "M in (16, 64]" for a later one, so the printed table does not
* read as overlapping. */
std::string band_span(std::string_view key, int64_t lo_excl, int64_t hi, bool first) {
if (hi == INT64_MAX) return std::string("any shape"); /* the op has no ranged parameter */
if (first) return fmt("%.*s <= %lld", (int)key.size(), key.data(), (long long)hi);
@@ -36,9 +49,8 @@ std::vector<Band> Registry::build_bands(std::string_view op, std::string_view ra
const RowFilter* accept) {
std::vector<Band> out;
/* No ranged parameter: one band covering everything. hi is INT64_MAX rather than the declared
* value so the issue path's band scan finds it for any issue count -- an op with no range has no
* value to index by, and a table that can miss on an op that cannot miss is a trap. */
/* No ranged parameter: one band covering everything. hi is INT64_MAX, not the declared value,
* so the issue path's band scan finds it for any issue count. */
if (ranged_key.empty()) {
lo = 0;
hi = INT64_MAX;
@@ -49,11 +61,13 @@ std::vector<Band> Registry::build_bands(std::string_view op, std::string_view ra
hi = lo;
}
/* The union of the LE, GE and EQ values candidate kernels place on the ranged parameter, from
* EVERY plugin and BOTH domains -- the boundaries are a property of the op's candidate set,
* not of whichever kernel happens to win a given band. DIV and IN cut nothing: a kernel that
* wants K divisible by 128 wants it at every value in the range, and set membership is not an
* interval, so neither can be a band edge. */
/* The union of the LE, GE and EQ values that candidate kernels from every plugin and both
* domains place on the ranged parameter: boundaries belong to the candidate set, not to the
* kernel that wins a band. An IN on the ranged parameter lists its values, each an EQ with a
* band of its own, so the row wins only values it serves. A DIV is not an interval and cuts no
* edge: a row with one is resolved at a band's upper bound, which it divides, and the band
* records the divisor so the issue path refuses a value inside it the row does not serve
* (Resolved::ranged_div). */
std::vector<int64_t> bounds;
auto add = [&](int64_t b) {
if (b >= lo && b < hi) bounds.push_back(b); /* clamped to the declared range; hi closes
@@ -67,12 +81,18 @@ std::vector<Band> Registry::build_bands(std::string_view op, std::string_view ra
if (!c.key || ranged_key != c.key) continue;
switch (c.op) {
case RAD_C_LE: add(c.ival); break;
/* A kernel that starts at v ends the band below it at v-1, so the band it
* serves begins exactly where it said it does. */
/* A kernel that starts at v ends the band below it at v-1. */
case RAD_C_GE: add(c.ival - 1); break;
/* An EQ needs both edges, or the single value it serves would share a band
* with values it does not. */
/* An EQ needs both edges, so its value gets a band of its own. */
case RAD_C_EQ: add(c.ival - 1); add(c.ival); break;
case RAD_C_IN:
for (std::string_view tok : split_ws(c.sval ? c.sval : "")) {
const std::string t(tok);
char* end = nullptr;
const long long v = std::strtoll(t.c_str(), &end, 10);
if (end && *end == '\0' && end != t.c_str()) { add(v - 1); add(v); }
}
break;
default: break;
}
}
@@ -83,9 +103,8 @@ std::vector<Band> Registry::build_bands(std::string_view op, std::string_view ra
bounds.erase(std::unique(bounds.begin(), bounds.end()), bounds.end());
bounds.push_back(hi);
/* Each band is resolved AT ITS UPPER BOUND, in both domains. The upper bound is the worst case
* in the band, so a kernel that serves it serves the whole band; resolving at the lower bound
* would hand a band to a kernel that cannot run its largest value. */
/* Each band is resolved at its upper bound, in both domains: the upper bound is the band's
* worst case, so a kernel that serves it serves the whole band. */
int64_t prev = lo - 1;
for (size_t i = 0; i < bounds.size(); ++i) {
Band b;
@@ -98,31 +117,22 @@ std::vector<Band> Registry::build_bands(std::string_view op, std::string_view ra
for (int dom = 0; dom < RAD_N_DOMAINS; ++dom) {
b.dom[dom] = resolve(op, g, dom, &t, accept);
if (!b.dom[dom]) b.miss[dom] = t.reason;
else b.dom[dom].ranged_div = ranged_div(b.dom[dom].row, ranged_key);
}
b.span = band_span(ranged_key, prev, b.hi, i == 0);
if (!b.dom[RAD_DOMAIN_DEVICE]) {
/* Fatal, but not here: declare always completes, and the caller reports every miss at
* the end rather than the first one at the top (§3.1). A range with a hole in it is
* reported as that band, not as the whole op. */
RAD_DEBUG("op '%s' %s: no device kernel -- %s", std::string(op).c_str(),
b.span.c_str(), b.miss[RAD_DOMAIN_DEVICE].c_str());
}
if (!b.dom[RAD_DOMAIN_HOST])
b.miss[RAD_DOMAIN_HOST] += "; site 'host' is unavailable for this band";
out.push_back(std::move(b));
prev = bounds[i];
}
/* Absence is asymmetric. No device kernel is fatal and the caller says so; no host kernel
* removes one placement option -- host-site execution needs a RAD_DOMAIN_HOST kernel, and
* where none resolves the planner may not put this op's arithmetic on the host. The host
* and SSD TIERS are untouched: a weight can still live there and stage to the device (§5.1).
/* No device kernel is fatal. No host kernel only removes host-site execution for this op;
* its weights may still live in the host and SSD tiers and stage to the device (§5.1).
*
* NEITHER IS REPORTED HERE. This function runs once per DECLARED OP, so a 64-layer model
* calls it 64 times for the same op name, and a warning emitted here would print one line
* per (layer, band) -- hundreds of identical sentences at startup. The band's miss string is
* the record instead; Builder collects them and reports once, over the whole graph. */
* Neither is reported here: this runs once per declared op (64 times for the same op on a
* 64-layer model). Declare always completes, and Builder collects the bands' miss strings and
* reports once per graph (§3.1), a hole in a range as that band. */
return out;
}