radiance 1.1.0

- The VRAM split has no ratio: --expert-vs-cache-ratio is gone (now an unknown option). The
  experts keep what the pinned host pool cannot hold, the KV cache takes the rest and lends idle
  blocks to the experts. Flash-Next at tp2: 7.9 GiB of KV a card, up from 4.7. Startup, /stats,
  /metrics and the dashboard report the most the cache can hold.
- Linear-state snapshots live in pinned host memory, not VRAM (--checkpoint-slots sizes the
  store). Prefix-cache misses on agent sessions fixed; a published conversation is no longer
  trimmed away.
- Any world size from the shipped container (baKon): --tp 3 on Flash-Next with no padded
  checkpoint -- the attention world, uneven delta-net heads, the fill op.
- Kernels (keptn42): moe_gemm_q decode loads and one-trip run search, hc_read's prefill form
  (+3.7% prefill at 18K), hc_up row groups up to eight, the fused router launch. Each is the rule
  where it was measured faster; no environment switches.
- Tool calls: a typed argument is always JSON (Python True/None no longer leak into arguments --
  Codeberg #21); nine further reply-parser fixes; the reply path inside a call is ~12x cheaper on
  the host.
- The kernel changes: prefill +2-3% and decode -2% a step on 2x R9700 at tp2, identical text.
This commit is contained in:
Deadcode committed 2026-10-06 14:04:49 +02:00
1 parent 9f5feb24ee
commit 82b5835c02
101 files changed
+5105 -3767

No files matched your search

+26 -2
View File
@@ -20,6 +20,7 @@
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
namespace rad {
@@ -101,6 +102,17 @@ int64_t weight_bytes(const WeightInfo& w) {
/* See planner.h. Planner::resolve_sites, Planner::build_units and Planner::pin_mapped, run over
* the same program without allocating a Plan -- the budget resolver calls this before a Planner
* exists. Kept adjacent to the three so a change to any of them has this in the same diff. */
int64_t file_stage_reserve(int64_t widest, bool routed) {
return (int64_t)RAD_PLACE_FILE_STAGE_SLOTS * widest +
(routed ? (int64_t)RAD_PLACE_FILE_WINDOWS * RAD_PLACE_FILE_WINDOW_BYTES : 0);
}
int64_t expert_vram_floor(const WeightFootprint& wf, int64_t host_room) {
if (wf.experts <= 0) return 0;
const int64_t all = wf.experts + wf.expert_spare;
return std::min(all, std::max<int64_t>(all + 2 * wf.expert_unit_max - host_room, 0));
}
void weight_footprint(const Program& prog, WeightFootprint* out, TablePlacement embedding,
TablePlacement ngram) {
if (!out) return;
@@ -166,6 +178,7 @@ void weight_footprint(const Program& prog, WeightFootprint* out, TablePlacement
* align_up(static_need, RAD_ALIGN_UNIT)` before every unit it places. A budget that summed raw
* bytes would be short by one alignment per unit, which on a 512-expert MoE is real. */
std::map<int32_t, int64_t> layer_experts;
std::set<int64_t> expert_strides;
bool ngram_host = true;
for (const U& mu : units) if (mu.ngram && !mu.host) ngram_host = false;
for (const U& mu : units) {
@@ -178,9 +191,20 @@ void weight_footprint(const Program& prog, WeightFootprint* out, TablePlacement
* placed in VRAM. */
if (mu.mapped || (mu.ngram && ngram != TablePlacement::Vram)) out->mapped += b;
else if (mu.emb && embedding == TablePlacement::Ram) out->hosted += b;
else if (mu.expert >= 0) { out->experts += b; layer_experts[mu.layer] += b; }
else if (mu.expert >= 0) {
out->experts += b;
layer_experts[mu.layer] += b;
out->expert_unit_max = std::max(out->expert_unit_max, b);
expert_strides.insert(b);
}
else out->statics += b;
if (mu.layer >= 0 && !mu.mapped) out->layer_unit_max = std::max(out->layer_unit_max, b);
if (mu.expert >= 0 && mu.layer >= 0) out->routed = true;
}
/* build_classes: one expert slab class a stride. */
for (int64_t s : expert_strides)
out->expert_spare += (int64_t)(RAD_PLACE_SHADOW_SLOTS + RAD_PLACE_STAGE_RING) * s +
RAD_ALIGN_UNIT;
for (const auto& le : layer_experts)
out->expert_layer_max = std::max(out->expert_layer_max, le.second);
out->ngram_host = out->ngram > 0 && ngram_host;
@@ -1157,7 +1181,7 @@ int Planner::plan(Plan* out) {
}
const int64_t windows = routed ? (int64_t)RAD_PLACE_FILE_WINDOWS *
RAD_PLACE_FILE_WINDOW_BYTES : 0;
const int64_t need = (int64_t)RAD_PLACE_FILE_STAGE_SLOTS * widest + windows;
const int64_t need = file_stage_reserve(widest, routed);
if (need > 0) {
if (need >= out->host_budget) {
RAD_ERR("placement: the file tier needs %s of pinned staging (%d slots of %s%s) "
+21 -3
View File
@@ -361,9 +361,8 @@ int64_t weight_bytes(const WeightInfo& w);
* order: how much room is there, and only then what goes in it. And the split matters more than
* the total. A model's static weights -- everything that is not an expert -- have to be resident
* for the model to run at a sensible speed at all, so they come off the top; the expert plane is
* the only thing that trades against the KV cache, and it is what --expert-vs-cache-ratio divides.
* Applying a ratio to the two together would let a 0.3 setting demote the attention projections to
* host memory to make room for a cache nothing will fill.
* the only thing that trades against the KV cache. Dividing the two together would let the cache's
* side demote the attention projections to host memory to make room for blocks nothing will fill.
*
* The three answers are per RANK, and under tensor parallel that is already the even split across
* devices: declare runs once per rank with every dimension ALREADY DIVIDED (spec §9), so summing
@@ -377,6 +376,13 @@ struct WeightFootprint {
int64_t statics = 0; /* non-expert and device-readable -- the floor under any budget */
int64_t experts = 0; /* the elastic plane: what streams from host when it does not fit */
int64_t expert_layer_max = 0; /* the most expert bytes any one routed layer holds */
int64_t expert_unit_max = 0; /* the largest expert unit's slot */
/* THE SLAB'S SPARE SLOTS beside the residents of an expert-tiered plan, at their most: per
* expert slab class, the shadow slots and the staging ring and the tail pad
* (Planner::assign_expert_tiered). They come out of the same weight budget as the residents. */
int64_t expert_spare = 0;
int64_t layer_unit_max = 0; /* the widest per-layer unit's slot: the file tier's staging */
bool routed = false; /* a layer has experts: the file tier's read windows */
int64_t mapped = 0; /* no device kernel can read them; they never enter a pool at all */
int64_t hosted = 0; /* --embedding-placement ram: in the pinned host pool, off the card */
/* The tables the two placement flags move, wherever the buckets above count them: `embedding`
@@ -398,6 +404,18 @@ struct WeightFootprint {
void weight_footprint(const Program& prog, WeightFootprint* out, TablePlacement embedding,
TablePlacement ngram);
/* THE PINNED STAGING THE FILE TIER TAKES OUT OF --host-pool-mib before any unit is placed in it:
* RAD_PLACE_FILE_STAGE_SLOTS of the widest per-layer unit, and the read windows when a routed
* layer can stream from the container. Planner::plan spends it; the budget counts it the same. */
int64_t file_stage_reserve(int64_t widest, bool routed);
/* THE EXPERT BYTES THE CARD MUST HOLD when `host_room` bytes of the pinned host pool are free for
* experts: everything the pool cannot take, the slab's spare slots beside them, and one unit of
* first-fit slack on each side -- the resident fill and the pool fill each skip a unit that does
* not fit and can leave up to one unit's room unspent. At most every expert and the spare slots.
* A weight budget of the statics and this much places every expert in VRAM or the host pool. */
int64_t expert_vram_floor(const WeightFootprint& wf, int64_t host_room);
/* THE TABLES THE PLACEMENT FLAGS MOVE, by what reads them and not by name: a model-level weight
* that at least one op reads and that only `embed_lookup` reads is a token embedding table, and
* one only `embed_lookup_q` reads is an n-gram table. A lookup reads M rows a step, which is what