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

+55 -13
View File
@@ -13,6 +13,7 @@
#include "r4d.h"
#include "r4d_args.h"
#include "r4d_common.h"
#include "r4d_fwht.h"
#include "r4d_gdn_wmma.h"
#include "r4d_q8.h"
#include "rad_philox.h"
@@ -184,9 +185,16 @@ __global__ __launch_bounds__(kT) void chan_stats_kernel(
// ln_mod_kernel's order through the same block_sum, the norm output is rounded to bf16 before
// quantising, and the codes are r4d_q8.h's. A 128-column group is sixteen consecutive lanes, so its
// amax is a half-wave reduction.
//
// HI8 is ln_mod_had_quant_i8g: had_quant_act_i8g's quantiser in place of quant_act_fp8's. The
// bf16-rounded norm output is 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, the order
// r4d_fwht_wave takes them in, 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 norm output. Byte-identical to gate_add, ln_mod and had_quant_act_i8g.
constexpr int kLnqChunks = 4; // 8-wide chunks a thread keeps: n <= kT * 8 * 4 = 8192
template <bool GATED>
template <bool GATED, bool HI8 = false, int SUB = 1>
__global__ __launch_bounds__(kT) void ln_mod_quant_kernel(
const uint16_t* __restrict__ yd, const uint16_t* __restrict__ g, const uint16_t* __restrict__ s,
const int* __restrict__ cu, uint16_t* __restrict__ x, uint8_t* __restrict__ q,
@@ -237,6 +245,23 @@ __global__ __launch_bounds__(kT) void ln_mod_quant_kernel(
#pragma unroll
for (int j = 0; j < 8; ++j) o[j] = bfr(bfr((v[k][j] - mean) * rs) * bfr(1.0f + gs[j]));
if (z) st8(z + (size_t)r * z_ld + i, o);
if constexpr (HI8) {
#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]));
@@ -244,12 +269,13 @@ __global__ __launch_bounds__(kT) void ln_mod_quant_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<false>()) : 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<HI8>()) : 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<false>(o[0], o[1], o[2], o[3], inv),
q8_pack4<false>(o[4], o[5], o[6], o[7], inv));
make_uint2(q8_pack4<HI8>(o[0], o[1], o[2], o[3], inv),
q8_pack4<HI8>(o[4], o[5], o[6], o[7], inv));
}
}
@@ -999,7 +1025,9 @@ extern "C" int r4d_rad_ln_mod(const RadArgs* a, RadStream s) {
return st_of(hipGetLastError());
}
extern "C" int r4d_rad_ln_mod_quant_fp8(const RadArgs* a, RadStream s) {
/* ln_mod_quant_fp8 (E4M3 codes, group 128) and with `hi8` ln_mod_had_quant_i8g (rotated int8
* codes, group 128 or 256). */
static int ln_mod_quant_launch(const RadArgs* a, RadStream s, bool hi8) {
const RadTensor *y = r4d_opt(a, 0), *g = r4d_opt(a, 1), *sc = r4d_opt(a, 2);
const RadTensor *cu = r4d_opt(a, 3), *x = r4d_opt(a, 4), *q = r4d_opt(a, 5);
const RadTensor *qs = r4d_opt(a, 6), *z = r4d_opt(a, 7);
@@ -1007,10 +1035,11 @@ extern "C" int r4d_rad_ln_mod_quant_fp8(const RadArgs* a, RadStream s) {
const bool gated = r4d_geti_or(a, "gated", 0) != 0;
if (gated && (!y || !g)) return R4D_NO(RAD_E_INVAL);
if (!is_bf16(x) || !is_bf16(sc) || (gated && (!is_bf16(y) || !is_bf16(g))) ||
(z && !is_bf16(z)) || q->dtype != RAD_F8E4M3 || qs->dtype != RAD_F32)
(z && !is_bf16(z)) || q->dtype != (hi8 ? RAD_I8 : RAD_F8E4M3) || qs->dtype != RAD_F32)
return R4D_NO(RAD_E_DTYPE);
const long long n = r4d_geti_or(a, "n", 0);
if (n <= 0 || n % 128 || r4d_geti_or(a, "group", 0) != 128 ||
const long long grp = r4d_geti_or(a, "group", 0);
if (n <= 0 || (grp != 128 && !(hi8 && grp == 256)) || n % grp ||
n > (long long)kT * 8 * kLnqChunks)
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;
@@ -1019,26 +1048,39 @@ extern "C" int r4d_rad_ln_mod_quant_fp8(const RadArgs* a, RadStream s) {
(gated && (!rows8(y, n, &ry, &yl) || !rows8(g, n, &rg, &gl))) ||
(z && !rows8(z, n, &rz, &zl)))
return R4D_NO(RAD_E_STRIDE);
const long long ql = r4d_rows_pitch(q, n, &rq), qsl = r4d_rows_pitch(qs, n / 128, &rqs);
const long long ql = r4d_rows_pitch(q, n, &rq), 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 = rq;
if (rows <= 0 || n_seq <= 0 || rx < rows || rqs < rows || rs < n_seq ||
(gated && (ry < rows || rg < n_seq)) || (z && rz < rows))
return R4D_NO(RAD_E_SHAPE);
const float eps = (float)r4d_getf(a, "eps", 1e-6);
#define R4D_LNQ(G) \
hipLaunchKernelGGL(ln_mod_quant_kernel<G>, dim3((unsigned)rows), dim3(kT), 0, (hipStream_t)s, \
#define R4D_LNQ(G, ...) \
hipLaunchKernelGGL((ln_mod_quant_kernel<G, ##__VA_ARGS__>), dim3((unsigned)rows), dim3(kT), 0, \
(hipStream_t)s, \
G ? (const uint16_t*)y->data : nullptr, \
G ? (const uint16_t*)g->data : nullptr, (const uint16_t*)sc->data, \
(const int*)cu->data, (uint16_t*)x->data, (uint8_t*)q->data, \
(float*)qs->data, 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)
if (gated) R4D_LNQ(true);
else R4D_LNQ(false);
if (!hi8) {
if (gated) R4D_LNQ(true);
else R4D_LNQ(false);
} else if (grp == 256) {
if (gated) R4D_LNQ(true, true, 2);
else R4D_LNQ(false, true, 2);
} else {
if (gated) R4D_LNQ(true, true, 1);
else R4D_LNQ(false, true, 1);
}
#undef R4D_LNQ
return st_of(hipGetLastError());
}
extern "C" int r4d_rad_ln_mod_had_quant_i8g(const RadArgs* a, RadStream s) {
return ln_mod_quant_launch(a, s, true);
}
extern "C" int r4d_rad_gate_add(const RadArgs* a, RadStream s) {
const RadTensor *y = r4d_opt(a, 0), *g = r4d_opt(a, 1), *cu = r4d_opt(a, 2), *x = r4d_opt(a, 3);
if (!y || !g || !cu || !x) return R4D_NO(RAD_E_INVAL);