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

+48 -17
View File
@@ -79,8 +79,13 @@ __device__ __forceinline__ float rdv(const float*, float v) { return v; }
constexpr int kRmChunks = 4; // 8-wide chunks a thread keeps: n <= kT * 8 * 4 = 8192
// QMODE: 0 writes the bf16 chain to `z`, 1 also quantises it to E4M3 (q, scale), 2 to int8, the
// two differing only in r4d_q8.h's `q8_top` and `q8_pack4`.
template <bool GATED, int QMODE>
// two differing only in r4d_q8.h's `q8_top` and `q8_pack4`. 3 is rms_mod_had_quant_i8g,
// had_quant_act_i8g's quantiser: the bf16-rounded chain rotated by the 128-wide Hadamard where it
// lies, eight columns a lane and sixteen lanes a block (strides 1, 2, 4 in the lane, then 8 to 64
// across lanes, r4d_fwht_wave's order, so the sums are the standalone kernel's), then int8 codes
// under one scale per (row, 128 * SUB): SUB 2 is IQ8R's 256-wide group, a whole wave. `z` receives
// the unrotated chain.
template <bool GATED, int QMODE, int SUB = 1>
__global__ __launch_bounds__(kT) void rms_mod_kernel(
const uint16_t* __restrict__ yd, const uint16_t* __restrict__ g, const uint16_t* __restrict__ s,
const uint16_t* __restrict__ w, const int* __restrict__ cu, uint16_t* __restrict__ x,
@@ -159,6 +164,23 @@ __global__ __launch_bounds__(kT) void rms_mod_kernel(
}
if (z) st8(z + (size_t)r * z_ld + i, o);
if (QMODE) {
if constexpr (QMODE == 3) {
#pragma unroll
for (int h = 1; h < 8; h <<= 1) {
#pragma unroll
for (int j = 0; j < 8; ++j)
if ((j & h) == 0) {
const float a = o[j], b = o[j + h];
o[j] = a + b;
o[j + h] = a - b;
}
}
const int lane = (int)threadIdx.x & 31;
r4d_fwht_xstage<8, 1>(o, lane);
r4d_fwht_xstage<8, 2>(o, lane);
r4d_fwht_xstage<8, 4>(o, lane);
r4d_fwht_xstage<8, 8>(o, lane);
}
float m = 0.0f;
#pragma unroll
for (int j = 0; j < 8; ++j) m = fmaxf(m, fabsf(o[j]));
@@ -166,12 +188,13 @@ __global__ __launch_bounds__(kT) void rms_mod_kernel(
m = fmaxf(m, r4d_xor_lane<4>(m));
m = fmaxf(m, r4d_xor_lane<2>(m));
m = fmaxf(m, r4d_xor_lane<1>(m));
const float sc = m > 0.0f ? m * (1.0f / q8_top<QMODE == 2>()) : 1.0f;
if constexpr (SUB == 2) m = fmaxf(m, r4d_xor_lane<16>(m));
const float sc = m > 0.0f ? m * (1.0f / q8_top<QMODE >= 2>()) : 1.0f;
const float inv = 1.0f / sc;
if ((threadIdx.x & 15) == 0) qs[(size_t)r * qs_ld + i / 128] = sc;
if ((threadIdx.x & (16 * SUB - 1)) == 0) qs[(size_t)r * qs_ld + i / (128 * SUB)] = sc;
*(uint2*)(q + (size_t)r * q_ld + i) =
make_uint2(q8_pack4<QMODE == 2>(o[0], o[1], o[2], o[3], inv),
q8_pack4<QMODE == 2>(o[4], o[5], o[6], o[7], inv));
make_uint2(q8_pack4<QMODE >= 2>(o[0], o[1], o[2], o[3], inv),
q8_pack4<QMODE >= 2>(o[4], o[5], o[6], o[7], inv));
}
}
}
@@ -610,7 +633,8 @@ int parse_f32_list(const char* s, float* out, int max) {
// ============================================================== the plugin ABI entry points
// rms_mod (QUANT false: y, g, s, w, cu, x, z) and rms_mod_quant_fp8 (y, g, s, w, cu, x, q, scale,
// z), one shim.
// z), one shim. qmode 2 is rms_mod_quant_i8 and 3 rms_mod_had_quant_i8g, whose `group` is 128 or
// 256 with n whole groups.
static int rms_mod_launch(const RadArgs* a, RadStream st, int qmode) {
const RadTensor *y = r4d_opt(a, 0), *g = r4d_opt(a, 1), *sc = r4d_opt(a, 2);
const RadTensor *w = r4d_opt(a, 3), *cu = r4d_opt(a, 4), *x = r4d_opt(a, 5);
@@ -625,11 +649,12 @@ static int rms_mod_launch(const RadArgs* a, RadStream st, int qmode) {
if (gated && (!y || !g)) return R4D_NO(RAD_E_INVAL);
if (!is_bf16(x) || !is_bf16(sc) || (w && !is_bf16(w)) || !is_i32(cu) ||
(gated && (!is_bf16(y) || !is_bf16(g))) || (z && !is_bf16(z)) ||
(qmode && (q->dtype != (qmode == 2 ? RAD_I8 : RAD_F8E4M3) || qs->dtype != RAD_F32)))
(qmode && (q->dtype != (qmode >= 2 ? RAD_I8 : RAD_F8E4M3) || qs->dtype != RAD_F32)))
return R4D_NO(RAD_E_DTYPE);
const long long n = r4d_geti_or(a, "n", 0);
const long long grp = qmode ? r4d_geti_or(a, "group", 0) : 128;
if (n <= 0 || (n & 7) || n > (long long)kT * 8 * kRmChunks ||
(qmode && (n % 128 || r4d_geti_or(a, "group", 0) != 128)))
(qmode && (n % grp || (grp != 128 && !(qmode == 3 && grp == 256)))))
return R4D_NO(RAD_E_SHAPE);
long long rx = 0, xl = 0, ry = 0, yl = 0, rg = 0, gl = 0, rs = 0, sl = 0, rz = 0, zl = 0;
long long rq = 0, rqs = 0, ql = 0, qsl = 0;
@@ -640,7 +665,7 @@ static int rms_mod_launch(const RadArgs* a, RadStream st, int qmode) {
return R4D_NO(RAD_E_STRIDE);
if (qmode) {
ql = r4d_rows_pitch(q, n, &rq);
qsl = r4d_rows_pitch(qs, n / 128, &rqs);
qsl = r4d_rows_pitch(qs, n / grp, &rqs);
if (ql < 0 || (ql & 7) || ((uintptr_t)q->data & 7) || qsl < 0) return R4D_NO(RAD_E_STRIDE);
}
const long long n_seq = r4d_numel(cu) - 1, rows = qmode ? rq : rz;
@@ -658,8 +683,8 @@ static int rms_mod_launch(const RadArgs* a, RadStream st, int qmode) {
const int layer = nk && !std::strcmp(nk, "layer");
const int none = nk && !std::strcmp(nk, "none");
if ((nk && !layer && !none && std::strcmp(nk, "rms")) || (none && w)) return R4D_NO(RAD_E_INVAL);
#define R4D_RMQ(G, Q) \
hipLaunchKernelGGL((rms_mod_kernel<G, Q>), dim3((unsigned)rows), dim3(kT), 0, \
#define R4D_RMQ(G, Q, ...) \
hipLaunchKernelGGL((rms_mod_kernel<G, Q, ##__VA_ARGS__>), dim3((unsigned)rows), dim3(kT), 0, \
(hipStream_t)st, G ? (const uint16_t*)y->data : nullptr, \
G ? (const uint16_t*)g->data : nullptr, (const uint16_t*)sc->data, \
w ? (const uint16_t*)w->data : nullptr, (const int*)cu->data, \
@@ -668,7 +693,13 @@ static int rms_mod_launch(const RadArgs* a, RadStream st, int qmode) {
z ? (uint16_t*)z->data : nullptr, (int)n, (int)n_seq, eps, (int)yl, \
(int)gl, (int)sl, (int)xl, (int)ql, (int)qsl, (int)zl, wadd, once, layer, \
none, cm ? (const int*)cm->data : nullptr)
if (qmode == 2) {
if (qmode == 3 && grp == 256) {
if (gated) R4D_RMQ(true, 3, 2);
else R4D_RMQ(false, 3, 2);
} else if (qmode == 3) {
if (gated) R4D_RMQ(true, 3);
else R4D_RMQ(false, 3);
} else if (qmode == 2) {
if (gated) R4D_RMQ(true, 2);
else R4D_RMQ(false, 2);
} else if (qmode == 1) {
@@ -684,14 +715,14 @@ static int rms_mod_launch(const RadArgs* a, RadStream st, int qmode) {
extern "C" int r4d_rad_rms_mod(const RadArgs* a, RadStream s) { return rms_mod_launch(a, s, 0); }
extern "C" int r4d_rad_rms_mod_quant_fp8(const RadArgs* a, RadStream s) {
return rms_mod_launch(a, s, 1);
}
extern "C" int r4d_rad_rms_mod_quant_i8(const RadArgs* a, RadStream s) {
return rms_mod_launch(a, s, 2);
}
extern "C" int r4d_rad_rms_mod_had_quant_i8g(const RadArgs* a, RadStream s) {
return rms_mod_launch(a, s, 3);
}
extern "C" int r4d_rad_flow_x0_step(const RadArgs* a, RadStream s) {
const RadTensor *v = r4d_opt(a, 0), *t = r4d_opt(a, 1), *sg = r4d_opt(a, 2);
const RadTensor *sgn = r4d_opt(a, 3), *x = r4d_opt(a, 4);