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

+22 -21
View File
@@ -37,9 +37,12 @@ namespace rad {
namespace arch {
/* One thread per tensor-parallel rank in one process (spec §1), and declare runs once per rank,
* so declared handles are per-rank state; a single global would let rank 1 overwrite rank 0.
* libr4d all-reduces over 2/4/8 ranks, hence eight. */
enum { MAX_RANKS = 8 };
* so declared handles are per-instance state; a single global would let rank 1 overwrite rank 0.
* libr4d all-reduces over 2/4/8 ranks, hence eight ranks. Several engines may run in the process
* (docs/MULTIMODEL.md), each with its own ranks, so state is indexed by the instance's slot
* (rad_build_slot at declare, rad_slot in step), unique across all of them, never by the rank two
* engines share. */
enum { MAX_RANKS = 8, MAX_SLOTS = RAD_MAX_SLOTS };
/* ================================================================== a debug residual probe
*
@@ -220,13 +223,14 @@ inline bool calib_write(RadCtx* c, rad_buf b, int64_t k, long long rows, const c
return calib_write_host(h.data(), k, rows, what, domain, rad_rank(c));
}
/* A pinned host buffer of at least `bytes`, one per rank, held for the process lifetime, so a tap
* that copies a scratch back every pass runs at link speed. Null (and logged) on failure. */
/* A pinned host buffer of at least `bytes`, one per instance (slot), held for the process
* lifetime, so a tap that copies a scratch back every pass runs at link speed. Null (and logged)
* on failure. */
inline float* calib_staging(RadCtx* c, int64_t bytes) {
static std::mutex mu;
static std::map<int, std::pair<void*, int64_t>> per_rank;
static std::map<int, std::pair<void*, int64_t>> per_slot;
std::lock_guard<std::mutex> lk(mu);
std::pair<void*, int64_t>& s = per_rank[rad_rank(c)];
std::pair<void*, int64_t>& s = per_slot[rad_slot(c)];
if (s.second >= bytes) return (float*)s.first;
if (s.first) rad_dev_free(s.first, RAD_MEM_HOST_PINNED);
s.first = rad_dev_alloc(bytes, RAD_MEM_HOST_PINNED);
@@ -733,9 +737,6 @@ struct Geom {
/* Messages below this many bytes use the exact all-reduce even with a lossy wire. Passed as
* `all_reduce`'s `min_bytes`; 0 leaves the default to the kernel plugin. */
int64_t wire_min_bytes = 0;
/* RAD_ATTN_FP8_* bits: the attention products accepted in e4m3 (RadBuildCtx describes it).
* decl_attn passes it on as `attn_paged`'s `prefill_fp8`. */
int attn_prefill_fp8 = 0;
float eps = 1e-6f;
/* GemmaRMSNorm's `1 +`. Qwen3.5, Qwen3-Next and Gemma normalise with `x_hat * (1 + w)` and
* store `w` near 0.1, so reading it as a plain gain shrinks every normed activation 5-10x. An
@@ -771,6 +772,12 @@ struct Geom {
* setting because producers and consumers must agree; the plugin reads it off a trunk weight's
* encoding and every linear checks its own against it. */
bool w_bf16 = false;
/* The linears are rotated int8 (rad_fp8.h's linear_is_w8h: IQ8R, or the 128-group form) with
* one activation scale per `w_i8_group` columns, for a plugin whose producers are declared away
* from its probe: each then declares an int8 code pair (ActFP8::declare_pair). Model-wide as
* w_bf16 is. */
bool w_i8h = false;
int64_t w_i8_group = 128;
int64_t q_dim() const { return n_head * head_dim; }
int64_t kv_dim() const { return n_head_kv * head_dim; }
@@ -1007,7 +1014,6 @@ inline int geom_from(Geom& g, const RadModelMeta* m, const RadBuildCtx* c,
g.world = c->world_size ? c->world_size : 1;
g.wire_exact= c->tp_wire_lossy ? 0 : 1;
g.wire_min_bytes = c->tp_wire_min_bytes;
g.attn_prefill_fp8 = c->attn_prefill_fp8;
g.eps = m->rms_eps;
g.theta = m->rope_theta;
g.rope_scale= 1.0f; /* yarn_from reads the model's rotary scaling */
@@ -1324,16 +1330,6 @@ inline rad_op decl_rotary(RadBuilder* b, const Geom& g, const char* name,
return rad_decl_op(b, name, p.data(), (int)p.size(), weights, nw);
}
/* An `attn_paged` op with the deployment's `prefill_fp8` appended (docs/OPS.md). At 0 the
* parameters are passed unchanged, so op identities and tune keys do not change. */
inline rad_op decl_attn(RadBuilder* b, const Geom& g, const char* name,
const RadParam* params, int n, const rad_weight* weights, int nw) {
if (g.attn_prefill_fp8 == 0) return rad_decl_op(b, name, params, n, weights, nw);
std::vector<RadParam> p(params, params + n);
p.push_back(RAD_INT("prefill_fp8", g.attn_prefill_fp8));
return rad_decl_op(b, name, p.data(), (int)p.size(), weights, nw);
}
/* Reads a model's rotary scaling into `g.rope_scale` and `g.yarn`. Every architecture calls it
* after geom_from, for the target ("") and for a drafter with its own config ("draft."). Only the
* free-form keys are read; RadModelMeta::rope_scale is not, since a factor without its type would
@@ -1638,6 +1634,11 @@ inline int drafter_kv_group(RadBuilder* b, Names& nm, const RadBuildCtx* ctx, Ge
#define RAD_ARCH_SERVES_IMPORTS(V) \
extern "C" int rad_arch_serves_imports(void) { return V; }
/* RAD_ARCH_MULTI_INSTANCE() states that the plugin keeps all per-instance state by slot, so several
* engines in one process may run it at once (rad_builder.h, rad_arch_multi_instance). */
#define RAD_ARCH_MULTI_INSTANCE() \
extern "C" int rad_arch_multi_instance(void) { return 1; }
} /* namespace arch */
} /* namespace rad */