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

+45
View File
@@ -606,6 +606,51 @@ void IdleTiers::drop_session(uint64_t id) {
sessions_.erase(it);
}
void IdleTiers::find_sessions(const std::string& label, uint64_t id,
std::vector<SessionChain>* out) const {
out->clear();
std::lock_guard lk(mu_);
for (const auto& kv : sessions_) {
const bool hit = id != 0 ? kv.first == id : (!label.empty() && kv.second.label == label);
if (!hit) continue;
SessionChain c;
c.id = kv.first;
c.label = kv.second.label;
c.chain = kv.second.chain;
out->push_back(std::move(c));
}
}
int64_t IdleTiers::shared_prefix_blocks(const std::vector<BlockHash>& chain,
const std::vector<uint64_t>& except) const {
if (chain.empty()) return 0;
std::lock_guard lk(mu_);
auto ro = roots_.find(chain[0]);
if (ro == roots_.end()) return 0;
int64_t most = 0;
for (uint64_t sid : ro->second) {
if (std::find(except.begin(), except.end(), sid) != except.end()) continue;
auto it = sessions_.find(sid);
if (it == sessions_.end()) continue;
const std::vector<BlockHash>& other = it->second.chain;
size_t n = 0;
while (n < chain.size() && n < other.size() && chain[n] == other[n]) ++n;
if ((int64_t)n > most) most = (int64_t)n;
}
return most;
}
void IdleTiers::cut_session(uint64_t id, int64_t keep_blocks, int64_t keep_tokens) {
std::lock_guard lk(mu_);
if (keep_blocks <= 0) { drop_session(id); return; }
auto it = sessions_.find(id);
if (it == sessions_.end()) return;
Session& s = it->second;
if ((int64_t)s.chain.size() <= keep_blocks) return;
s.chain.resize((size_t)keep_blocks);
s.n_tokens = keep_tokens;
}
std::vector<IdleTiers::SessionInfo> IdleTiers::sessions(Occupancy* occ) const {
/* One slice's hold on the lock (YieldingMutex). */
struct Slice {
+25
View File
@@ -246,6 +246,31 @@ public:
* microseconds apart. */
std::vector<SessionInfo> sessions(Occupancy* occ = nullptr) const;
/* ---------------- a release names a session ----------------
*
* The cache keys by block and knows no conversation; the rows here are what a client can
* name. PrefixCache::release_session asks for the rows, walks their chains itself and
* reports back what is left of each. */
struct SessionChain {
uint64_t id = 0;
std::string label;
std::vector<BlockHash> chain;
};
/* Every row carrying `label`, or with `id` nonzero the one row of that id. A label is the
* client's and may stand on several leaves (a conversation branched and both ends were
* served); a release by label means all of them. */
void find_sessions(const std::string& label, uint64_t id,
std::vector<SessionChain>* out) const;
/* How many blocks at the start of `chain` another stored session walks too: the longest
* common prefix with any row at the same root whose id is not in `except`. Those blocks
* belong to the other conversation as much as to this one. */
int64_t shared_prefix_blocks(const std::vector<BlockHash>& chain,
const std::vector<uint64_t>& except) const;
/* The release is done: the row keeps its first `keep_blocks` (covering `keep_tokens`),
* which is the kept prefix or, beyond it, the deepest block a live request held back; it
* goes when that is zero. A kept stub is a leaf again until a later turn extends it. */
void cut_session(uint64_t id, int64_t keep_blocks, int64_t keep_tokens);
struct Stats {
/* `to_host` counts copies to host memory (link traffic); `dropped` counts VRAM copies
* then given up. An entry can be copied and never dropped. */
+88 -7
View File
@@ -368,14 +368,16 @@ int PrefixCache::insert(uint64_t session,
for (int64_t b = 0; b < n_full; ++b) {
const BlockHash& h = hs[(size_t)b];
auto it = map_.find(h);
/* A snapshot-backed prefix keeps its first bytes even in the host tier: a short
* recompute can round the KV differently, while older conversations' recurrent snapshots
* still depend on the original attention KV. Non-stateful caches may rebind below. */
if (it != map_.end() && (it->second.in_lru || has_linear_)) continue; /* touched below */
/* With snapshots (recurrent state or a sliding window) an existing entry keeps the bytes
* it was published with, wherever it is held: a snapshot deeper in the chain was computed
* from them, and a recompute in another step shape can round the KV differently. The
* recomputed blocks go with the request's sequence; a later hit restores the tier copy. */
if (it != map_.end() && (it->second.in_lru || has_linear_)) continue; /* touched below */
if (it != map_.end()) {
/* An off-device entry this request recomputed (a restore that did not fit, or a chain
* cut short). Its blocks become the entry's device copy and the tier copy goes
* (IdleTiers::rebound). An entry with a promotion in flight is left alone. */
/* Without snapshots, an off-device entry this request recomputed (a restore that did
* not fit, or a chain cut short): its blocks become the entry's device copy and the
* tier copy goes (IdleTiers::rebound). An entry with a promotion in flight is left
* alone. */
if (!tiers_ || !tiers_->resident_off_device(h)) continue;
std::vector<int32_t> mine(groups_.size(), -1);
size_t held = 0;
@@ -989,4 +991,83 @@ int64_t PrefixCache::expire(uint64_t now_ns, uint64_t ttl_ns) {
stats_.ckpt_expired += (int64_t)gone.size();
return n;
}
/* ------------------------------------------------------------------ release on request */
int PrefixCache::release_session(const std::string& label, uint64_t id, int64_t keep_tokens,
SessionRelease* out) {
if (!out) return RAD_E_INVAL;
*out = SessionRelease{};
if (!enabled_ || !tiers_ || block_size_ <= 0) return RAD_E_UNSUPPORTED;
if (label.empty() && id == 0) return RAD_E_INVAL;
if (keep_tokens < 0) return RAD_E_INVAL;
std::vector<IdleTiers::SessionChain> rows;
tiers_->find_sessions(label, id, &rows);
if (rows.empty()) return RAD_E_NOTFOUND;
std::vector<uint64_t> ids;
for (const IdleTiers::SessionChain& r : rows) ids.push_back(r.id);
/* A kept token keeps its whole block: the block holding it is what the next turn hits. */
const int64_t keep_blocks = (keep_tokens + block_size_ - 1) / block_size_;
int64_t entry_bytes = 0;
for (int32_t g : groups_) {
const KVGroupPlan* p = kv_->plan(g);
if (p) entry_bytes += p->bytes_per_block;
}
for (const IdleTiers::SessionChain& row : rows) {
const int64_t n = (int64_t)row.chain.size();
const int64_t shared = tiers_->shared_prefix_blocks(row.chain, ids);
const int64_t floor = std::max(keep_blocks, shared);
++out->sessions;
out->kept_tokens += std::min(keep_blocks, n) * block_size_;
out->kept_shared += std::max<int64_t>(0, std::min(shared, n) - keep_blocks);
/* Tip inwards, as expire() and the host tier's pressure do: what is left is still a
* prefix a lookup reaches. `live_upto` is one past the deepest block a request kept:
* the row is cut there, not at the kept prefix, so a later release reaches it. */
int64_t live_upto = 0;
for (int64_t b = n - 1; b >= floor; --b) {
const BlockHash& h = row.chain[(size_t)b];
auto it = map_.find(h);
if (it != map_.end()) {
Entry& e = it->second;
/* A sequence reads it, or a waiting request restored it and holds it against
* drop_clean: releasing would free nothing and lose the entry under them. Its
* snapshot stays with it; that request most likely resumes from it. */
if (e.in_lru && (shared_with_live(e) || held_.count(h) > 0)) {
++out->kept_live;
if (live_upto == 0) live_upto = b + 1;
continue;
}
if (e.in_lru) {
lru_.erase(e.lru);
e.in_lru = false;
release_blocks(e);
out->device_bytes += entry_bytes;
}
/* The host copy goes with the entry (forget), so count it before. */
if (tiers_->resident_off_device(h) || tiers_->droppable(h))
out->host_bytes += tiers_->entry_bytes();
tiers_->forget(h);
map_.erase(it);
++out->entries;
}
auto ck = ck_by_prefix_.find(h);
if (ck != ck_by_prefix_.end() && ck->second.valid && !handed(h) && !reserved(h)) {
const uint64_t session = ck->second.session;
retire_ckpt(ck);
unindex_ckpt(session, h);
++out->snapshots;
}
}
const int64_t cut = std::min(n, std::max(keep_blocks, live_upto));
tiers_->cut_session(row.id, cut, cut * block_size_);
}
out->tokens = out->entries * block_size_;
stats_.released += out->entries;
stats_.ckpt_released += out->snapshots;
return RAD_OK;
}
} /* namespace rad */
+34
View File
@@ -174,6 +174,23 @@ CheckpointSlots checkpoint_slots_auto(const CheckpointPolicy& policy, int64_t ma
int64_t ctx, int64_t interval, int64_t slot_bytes,
int64_t share_bytes, int64_t room_bytes);
/* ------------------------------------------------------------------ a release */
/* What PrefixCache::release_session took out and what it left. Blocks are left for three
* reasons, counted apart so a caller can tell a half-shared conversation from a busy one: the
* caller asked for them (`keep_tokens`), another stored session's chain runs through them (a
* system prompt two conversations open with belongs to both), or a live sequence holds them. */
struct SessionRelease {
int64_t sessions = 0; /* rows the label or id named */
int64_t entries = 0; /* blocks forgotten, from VRAM or the host tier */
int64_t tokens = 0; /* entries x block size */
int64_t device_bytes = 0; /* pool bytes given back */
int64_t host_bytes = 0; /* host-tier slots given back */
int64_t snapshots = 0;
int64_t kept_tokens = 0; /* the chain's start, as asked, whole blocks */
int64_t kept_shared = 0; /* blocks beyond that on another stored session's chain */
int64_t kept_live = 0; /* blocks a running or waiting request holds */
};
/* ------------------------------------------------------------------ the cache */
class PrefixCache {
public:
@@ -314,6 +331,21 @@ public:
* than what follows it: conversations expire from the tip inwards and a shared system prompt
* outlives its readers. Returns how many entries went. */
int64_t expire(uint64_t now_ns, uint64_t ttl_ns);
/* ---------------- release on request ----------------
*
* Forget one stored conversation now instead of at the TTL: a client that deleted it, or
* replaced everything past a prefix (a compaction) and knows the rest is dead. `label` names
* every row carrying it, `id` (nonzero) one row by its engine id (IdleTiers::SessionInfo).
* The chain goes from the tip inwards like expire(): VRAM blocks to the pool, the host copy
* with them, the session's snapshots on the released blocks to the store. `keep_tokens`
* leaves the chain's first blocks standing (rounded up to whole blocks), so the prefix the
* client kept still hits. A block another stored session's chain shares stays, as does one a
* live sequence holds or a waiting request has restored; snapshots handed out or reserved
* this step stay too. RAD_E_NOTFOUND when nothing matches, RAD_E_UNSUPPORTED without the
* session table (no tiers attached). */
int release_session(const std::string& label, uint64_t id, int64_t keep_tokens,
SessionRelease* out);
/* ---------------- linear checkpoints ---------------- */
/* The next position strictly after `pos` at which the scheduler must split a chunk so that a
* checkpoint lands on a boundary (spec §7.1, §7.3). */
@@ -356,6 +388,8 @@ public:
int64_t drops = 0;
/* Entries and snapshots removed by --prefix-cache-ttl, from any tier. */
int64_t expired = 0, ckpt_expired = 0;
/* Entries and snapshots a client released (release_session). */
int64_t released = 0, ckpt_released = 0;
};
const Stats& stats() const { return stats_; }