radiance 2.0.0

Radiance becomes a multi-model engine: one process serves several models behind one port, loads
each when a request names it, parks it in host memory or restores it from its container, and
shares the cards between them (docs/MULTIMODEL.md). The configuration is one YAML file; the
command line flags are gone (`radiance --config FILE`, hot reload on SIGHUP).

Formats. IQ8R (rotated int8) and IQR-V4 replace FP8 and MXFP4 as whole-model formats, with an
int8 KV cache (`kv-cache-dtype: i8`) in place of the fp8 one. Containers whose weights are block
FP8, MXFP4, M2XFP4, NVFP4 or ParoQuant are refused at startup by the name of the first such
weight. Not served until they have int8 containers: GLM-5.3-Flash, Ornith-1.5, Sage-A1.5,
Nemotron-3.5-Bolt-74B, Ling-3.0-flash, drama-3 and Anima's FP8 container; Nemotron-3.5-Bolt-E4B,
the Gemma 4 31B DFlash containers and MiniCPM5-2B bf16 serve without their drafter. 1.17.0
serves all of them.

Speed. Chained launches for Qwen3.8-27B, Gemma 4, Gemma 3 and the small bf16 models, a new
Qwen3.8-Flash-Next container (IQR-V4 experts, int8 trunk) with its decode step and prefill
reworked, and a reworked adaptive draft window.

Deployment. deploy/compose has two fleet files, tp1.yaml and tp2.yaml, each with its
configuration beside it, in place of the per-model files. `host-pool-mib` is a model's host pool
in all, split among its ranks. The dashboard is rebuilt: an hour of history kept by the server,
each accelerator's memory by model, model states over time.

Merged since 1.17.0: Nemotron-3.5-Bolt-74B-A9B by keptn42 (#339); GLM-5.3-Flash on four cards by
AnimusNull (#397); chained launches for Flash-Next's decode step (#396) and preempted requests
keeping their prefix and place (#405) by mici81; --prefill-interleave auto by Code000 (#410);
eight more libr3d kernels and the w4a4 reference by RikshaDriver (#403, #407, #408); libr3d
large-BAR and E4M3 decode fixes by neuromanMD (#438, #439); int4/int5 decode tiles by Kezi
(#426); attention for Nanbeige 4.3 33B by everplays (#417); expert_stats_report.py by baKon
(#431). Fixed: #398, #402, #419, #437 (dschmitz's patch); added the metrics of #392, and
multi-model serving as asked for in #367 and #109.

Plugin ABI 39: out-of-tree plugins need to be rebuilt.

Thanks to @keptn42, @AnimusNull, @mici81, @Code000, @RikshaDriver, @neuromanMD, @Kezi, @everplays, @baKon and @dschmitz.
This commit is contained in:
Deadcode committed 2026-11-14 22:32:28 +01:00
1 parent b4c04b6042
commit ddcb9c69bb
696 files changed
+120770 -56596

No files matched your search

+92 -2
View File
@@ -560,6 +560,7 @@ int Mover::start_stage(int32_t unit, int64_t slab_slot) {
if (!src) return RAD_E_STATE;
RAD_TRY(rad_event_wait(mover_, gate_));
dev_page_invalidate(dst, us.bytes);
RAD_TRY(rad_memcpy_async(dst, src, us.bytes, mover_));
RAD_TRY(rad_event_record(moves_[(size_t)rec].ev, mover_));
@@ -1048,7 +1049,10 @@ int Mover::stage_file_units(const std::vector<int32_t>& units, char* dst, int64_
}
stats_.ssd_read_ns += (uint64_t)std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::steady_clock::now() - t0).count();
for (const Cp& c : cps) RAD_TRY(rad_memcpy_async(c.dst, win + c.wo, c.bytes, mover_));
for (const Cp& c : cps) {
dev_page_invalidate(c.dst, c.bytes);
RAD_TRY(rad_memcpy_async(c.dst, win + c.wo, c.bytes, mover_));
}
RAD_TRY(rad_event_record(win_ev_[(size_t)w], mover_));
win_rec_[(size_t)w] = 1;
}
@@ -1167,7 +1171,8 @@ int Mover::issue(const Swap& s, HeatEngine* heat) {
/* ------------------------------------------------------------------ the loan */
static const char* lender_name(int lender) {
return lender == Mover::kLendKV ? "KV cache" : "activation arena";
return lender == Mover::kLendKV ? "KV cache" : lender == Mover::kLendArena ? "activation arena"
: "fleet's free VRAM";
}
static char* align_down_ptr(char* p) {
@@ -1274,6 +1279,21 @@ int Mover::lend_from(int lender, const std::vector<LoanStrip>& strips) {
return RAD_OK;
}
int64_t Mover::lendable_bytes() const {
if (!plan_ || !plan_->dynamic) return 0;
std::vector<int64_t> n(pools_.size(), 0);
for (size_t u = 0; u < unit_.size(); ++u) {
const UnitState& us = unit_[u];
if (us.klass < 0 || us.tier != Tier::HostPinned || us.pool_slot < 0) continue;
if (!plan_->units[u].movable) continue;
++n[(size_t)us.klass];
}
int64_t b = 0;
for (size_t c = 0; c < pools_.size(); ++c)
if (pools_[c].stride > 0) b += n[c] * (pools_[c].stride + (int64_t)RAD_ALIGN_UNIT);
return b > 0 ? b + 2 * (int64_t)RAD_ALIGN_UNIT : 0;
}
int Mover::set_loan(int lender, int64_t amount) {
if (lender < 0 || lender >= kLenders) return RAD_E_INVAL;
loan_[lender] = amount > 0 ? amount : 0;
@@ -1709,6 +1729,7 @@ int Mover::reclaim(int lender, int64_t amount, HeatEngine* heat) {
}
const int64_t g = to < 0 ? cp.pool.take() : -1;
if (to >= 0) {
dev_page_invalidate(cp.slot_ptr(to), us.bytes);
RAD_TRY(rad_memcpy_async(cp.slot_ptr(to), cp.slot_ptr(from), us.bytes, mover_));
us.slab_slot = to;
} else if (g >= 0) {
@@ -1790,7 +1811,70 @@ int Mover::reclaim(int lender, int64_t amount, HeatEngine* heat) {
return RAD_OK;
}
int Mover::drop_slab(HeatEngine* heat, std::vector<std::pair<const void*, int64_t>>* free_ranges) {
if (pools_.empty()) return RAD_OK;
if (!compute_ || !mover_) return RAD_OK; /* nothing ever moved: the slab is as loaded */
RAD_TRY(flush_moves());
RAD_TRY(rad_stream_sync(mover_));
RAD_TRY(retire(heat));
RAD_TRY(rad_stream_sync(compute_));
RAD_TRY(retire(heat));
std::vector<std::pair<size_t, int64_t>> freed;
for (int32_t u = 0; u < (int32_t)unit_.size(); ++u) {
UnitState& us = unit_[(size_t)u];
if (us.klass < 0 || us.slab_slot < 0) continue;
ClassPools& cp = pools_[(size_t)us.klass];
if (cp.is_flex(us.slab_slot)) continue; /* the loans were recalled; nothing is here */
if (us.pool_slot >= 0) {
us.tier = Tier::HostPinned;
us.site = Site::DeviceZeroCopy;
} else if (us.hot || ((size_t)u < file_ok_.size() && file_ok_[(size_t)u])) {
/* The container is its copy, and the file stager reads it back when routing needs it
* (a hot-cache unit, or one the stager covers). */
us.tier = Tier::SSD;
us.hot = false;
} else {
continue; /* its only copy is this slot */
}
freed.push_back({ (size_t)us.klass, us.slab_slot });
us.slab_slot = -1;
republish(u);
++stats_.dropped;
if (heat) {
heat->set_tier(u, us.tier);
heat->set_busy(u, false);
}
}
for (const auto& f : freed) pools_[f.first].slab.add_free(f.second);
{
int64_t kept = 0, gone = 0;
for (const UnitState& us : unit_)
if (us.slab_slot >= 0 && us.klass >= 0 && !pools_[(size_t)us.klass].is_flex(us.slab_slot)) kept += us.bytes;
for (const auto& f : freed) gone += pools_[f.first].stride;
RAD_INFO("mover: the slab gave back %s for a park; %s stays (units with no other copy)",
humanb(gone).c_str(), humanb(kept).c_str());
}
/* What stays in a budgeted slot, per class; every other slot's stretch is free. */
for (size_t k = 0; k < pools_.size(); ++k) {
ClassPools& cp = pools_[k];
if (!cp.slab_base || cp.stride <= 0 || cp.n_fixed <= 0) continue;
std::vector<char> used((size_t)cp.n_fixed, 0);
for (const UnitState& us : unit_)
if ((size_t)us.klass == k && us.slab_slot >= 0 && us.slab_slot < cp.n_fixed) used[(size_t)us.slab_slot] = 1;
for (int64_t a = 0; a < cp.n_fixed;) {
if (used[(size_t)a]) { ++a; continue; }
int64_t b = a;
while (b < cp.n_fixed && !used[(size_t)b]) ++b;
free_ranges->push_back({ (char*)cp.slab_base + a * cp.stride, (b - a) * cp.stride });
a = b;
}
}
count_flex();
return RAD_OK;
}
void Mover::queue_move_copy(void* dst, const void* src, int64_t bytes, int rec) {
dev_page_invalidate(dst, bytes); /* a parked copy of that slot is stale from here */
move_segs_.push_back(RadCopySeg{ src, dst, bytes });
move_recs_.push_back((int32_t)rec);
}
@@ -1822,6 +1906,12 @@ int Mover::retire(HeatEngine* heat) {
--copying_[(size_t)m.unit];
UnitState& us = unit_[(size_t)m.unit];
/* The copy has landed: a parked copy of the slot made while it ran is stale too. */
{
ClassPools& cp = pools_[(size_t)us.klass];
if (m.slab_slot >= 0) dev_page_invalidate(cp.slot_ptr(m.slab_slot), cp.stride);
if (m.to_slot >= 0) dev_page_invalidate(cp.slot_ptr(m.to_slot), cp.stride);
}
switch (m.kind) {
case Move::Kind::Promote:
us.slab_slot = m.slab_slot;
+24 -2
View File
@@ -499,9 +499,17 @@ public:
* segment, and they move independently, so every call names its lender.
*
* A unit in a lent slot keeps its host copy (weights never change), so giving the slot back
* is a change of address: a recall waits only for kernels to stop naming the slot. */
* is a change of address: a recall waits only for kernels to stop naming the slot.
*
* The fleet is the third lender (docs/MULTIMODEL.md §6.7): VRAM no model of the fleet holds,
* backed into a range the engine reserved for it and given back when the fleet needs it. */
enum Lender { kLendKV = 0, kLendArena = 1, kLenders = 2 };
enum Lender { kLendKV = 0, kLendArena = 1, kLendFleet = 2, kLenders = 3 };
/* The bytes one stretch must span for lend_from to cut a slot for every unit it would carve
* one for (each movable unit in the pinned pool), with each slot's alignment and the empty
* top unit. Sizes a lender whose memory is reserved for the purpose. */
int64_t lendable_bytes() const;
/* Registers the stretches a lender may ever lend; once per lender, after its memory is
* carved. Each stretch is cut into slots of each class's stride from the top down, so a small
@@ -521,6 +529,14 @@ public:
* in hand (a request larger than the cache's buffer, a step larger than the arena allows). */
int reclaim(int lender, int64_t amount, HeatEngine* heat);
/* Empties the budgeted slab for a park (docs/MULTIMODEL.md §7): every unit in a budgeted slot
* that has a host copy is published at that copy, and a hot-cache unit (the container is its
* copy) goes back to the file tier; units with no other copy stay. Every loan must already be
* recalled (reclaim to 0). Appends the slab's free stretches to `free_ranges`: their contents
* need not be kept, and the heat engine fills the slots again as routing touches the units.
* A host wait, like reclaim(). */
int drop_slab(HeatEngine* heat, std::vector<std::pair<const void*, int64_t>>* free_ranges);
/* Bytes the lent slots hold, bytes the loans offer, and bytes every carved slot could hold.
* The first two are stored because the HTTP thread reads them for the dashboard and only the
* rank thread may walk the slot pools. */
@@ -534,6 +550,12 @@ public:
for (const ClassPools& cp : pools_) n += cp.n_turn;
return n;
}
/* Their bytes. */
int64_t turnover_bytes() const {
int64_t n = 0;
for (const ClassPools& cp : pools_) n += cp.n_turn * cp.stride;
return n;
}
/* The loan that covers every slot carved from this lender; more would sit empty. Zero when
* nothing is carved. */
int64_t loan_ceiling(int lender) const;
+5 -5
View File
@@ -1,7 +1,7 @@
/* xstats.cpp -- the --expert-stats tally, its merge across ranks and its file. See xstats.h. */
#include "xstats.h"
#include <nlohmann/json.hpp>
#include "util/json.h"
#include <algorithm>
#include <cerrno>
@@ -259,7 +259,7 @@ void put_i32s(std::string& o, const std::vector<int32_t>& v) {
o += ']';
}
std::string jstr(const std::string& s) { return nlohmann::json(s).dump(); }
std::string jstr(const std::string& s) { return Json(s).dump(); }
/* {"prefill": f(0), "decode": f(1), ...} on one line. */
template <typename F>
@@ -499,9 +499,9 @@ int xs_profile_load(const std::string& path, std::vector<RadFileProfile>* out, i
RAD_ERR("--expert-profile: reading %s failed", path.c_str());
return RAD_E_IO;
}
nlohmann::json j;
try { j = nlohmann::json::parse(text); }
catch (const nlohmann::json::exception& e) {
Json j;
try { j = Json::parse(text); }
catch (const Json::exception& e) {
RAD_ERR("--expert-profile: %s is not JSON: %s", path.c_str(), e.what());
return RAD_E_INVAL;
}