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 -17
View File
@@ -77,6 +77,10 @@
// O_V4: the fp8_v4 cache, O_V4 | O_K6 the k6_v4 cache (see r4d_attn_decode_h256_gqa6.hip).
#define O_V4 33554432
#define O_K6 67108864
// O_I8 (with O_V4 | O_K6): the i8 cache (see r4d_attn_decode_h256_gqa6.hip).
#define O_I8 1073741824
// The int8 cache's bits together, for a launcher's option set.
#define O_KVI8 (O_V4 | O_K6 | O_I8)
// O_PSPLIT: a KV split for launches with too few workgroups to fill the card (r4d_prefill_splits
// in r4d_attn_prefill_split.h). blockIdx.x is qtile * a.splits + split, and the workgroup walks
// only its segment of the sequence's tiles, cut as r4d_attn_tps cuts them (the partition the
@@ -147,11 +151,14 @@ void r4d_attn_prefill_kernel(const R4DArgs a)
constexpr int BTS = (OPT & O_BTS) ? 1 : 0;
constexpr int V4 = ((OPT & O_V4) && !KVP) ? 1 : 0;
constexpr int K6 = ((OPT & O_K6) && V4) ? 1 : 0;
constexpr int I8 = ((OPT & O_I8) && K6) ? 1 : 0;
static_assert(!I8 || !(OPT & (O_QK8 | O_PV8)), "the i8 cache has no e4m3 legs");
// A token's row in a page, and where in it V's codes, V's scales and K's scales start.
constexpr int ROWB = K6 ? HEAD_DIM * 22 / 16 : V4 ? HEAD_DIM * 25 / 16 : 2 * HEAD_DIM;
constexpr int VOFF = K6 ? HEAD_DIM * 3 / 4 : HEAD_DIM;
constexpr int VSOFF = K6 ? HEAD_DIM * 21 / 16 : HEAD_DIM * 3 / 2;
constexpr int KSOFF = HEAD_DIM * 5 / 4;
constexpr int ROWB = I8 ? 2 * HEAD_DIM + 4
: K6 ? HEAD_DIM * 22 / 16 : V4 ? HEAD_DIM * 25 / 16 : 2 * HEAD_DIM;
constexpr int VOFF = I8 ? HEAD_DIM : K6 ? HEAD_DIM * 3 / 4 : HEAD_DIM;
constexpr int VSOFF = I8 ? 2 * HEAD_DIM + 2 : K6 ? HEAD_DIM * 21 / 16 : HEAD_DIM * 3 / 2;
constexpr int KSOFF = I8 ? 2 * HEAD_DIM : HEAD_DIM * 5 / 4;
constexpr int GPREV = ((OPT & O_GPREV) && !V4) ? 1 : 0;
constexpr int LDSB = (OPT & O_LDSB) ? 1 : 0;
constexpr int KWIDE = (OPT & O_KWIDE) ? 1 : 0;
@@ -186,7 +193,7 @@ void r4d_attn_prefill_kernel(const R4DArgs a)
constexpr float PSHIFT = D::SHIFT;
constexpr float PGROW = PV8 ? 8.0f : D::GROW; // e4m3 max is 448 = 2^8.8
static_assert(!KWIDE || KPASS == 1, "the wide K fetch is one straight-line pass");
static_assert(!K6 || KWIDE, "k6_v4 K is staged sixteen dims a thread");
static_assert(!K6 || I8 || KWIDE, "k6_v4 K is staged sixteen dims a thread");
static_assert((!QK8 && !PV8) || CTG, "the 8-bit fragment maps are written for CONTIG");
constexpr int KSTR8 = HEAD_DIM + 8, VSTR8 = TILE + 8;
@@ -294,6 +301,8 @@ void r4d_attn_prefill_kernel(const R4DArgs a)
// The split lets GPREV move the fetch out from between the barriers.
const int vg = lane >> 3, vj = lane & 7;
uint4 kreg[KREGS], vreg[VREGS];
// i8: the K scale of the key a pass stages.
uint32_t ksc8[I8 ? KPASS : 1];
// ---- fp8_v4 / k6_v4: V is int4 in groups of 32 with an f16 scale (absmax / 7): 16 bytes of
// codes a group at VOFF (dim d at bits 4*(d%8) of word d/8), the group scales at VSOFF. A thread stages one key pair's 8 dims: two code words and the pair's scale,
@@ -307,7 +316,9 @@ void r4d_attn_prefill_kernel(const R4DArgs a)
constexpr int U4 = V4 ? (NP4 + NTHR - 1) / NTHR : 1;
// The pair's two scales stay apart until storeV4 packs them: packed here, the prefetch a tile
// ahead would be waited on right after it is issued (fp8_v4 packs here, see KLATE).
uint32_t v4c[U4][2], v4s[U4][2];
// i8: V's codes are bytes, two words a key's 8 dims, and a key has one scale; the rest is the
// same with u = code ^ 0x80 and (x - 1152) * s.
uint32_t v4c[U4][I8 ? 4 : 2], v4s[U4][2];
auto fetchV4 = [&](int k0, const int* blks) {
#pragma unroll
for (int r = 0; r < U4; ++r) {
@@ -321,8 +332,15 @@ void r4d_attn_prefill_kernel(const R4DArgs a)
const int bk = BTS ? blks[(kk - k0) / BS] : bt[kk / BS];
const uint8_t* base = (const uint8_t*)a.kv + (size_t)bk * a.kv_block_stride
+ (size_t)kvh * a.kv_head_stride + (size_t)(kk % BS) * ROWB;
v4c[r][j] = *(const uint32_t*)(base + VOFF + o * 4);
sc[j] = *(const uint16_t*)(base + VSOFF + (o >> 2) * 2);
if constexpr (I8) {
const uint2 cw = *(const uint2*)(base + VOFF + o * 8);
v4c[r][2 * j] = cw.x;
v4c[r][2 * j + 1] = cw.y;
sc[j] = *(const uint16_t*)(base + VSOFF);
} else {
v4c[r][j] = *(const uint32_t*)(base + VOFF + o * 4);
sc[j] = *(const uint16_t*)(base + VSOFF + (o >> 2) * 2);
}
}
if constexpr (OLDV4) { v4s[r][0] = sc[0] | (sc[1] << 16); v4s[r][1] = 0; }
else { v4s[r][0] = sc[0]; v4s[r][1] = sc[1]; }
@@ -336,13 +354,18 @@ void r4d_attn_prefill_kernel(const R4DArgs a)
const int u = tid + r * NTHR;
if (NP4 % NTHR == 0 || u < NP4) {
const int kp = u % (TILE / 2), o = u / (TILE / 2);
// Codes are two's complement nibbles; ^ 8 makes them offset binary (value + 8).
const uint32_t n0 = (v4c[r][0] & 0x0F0F0F0Fu) ^ 0x08080808u;
const uint32_t m0 = ((v4c[r][0] >> 4) & 0x0F0F0F0Fu) ^ 0x08080808u;
const uint32_t n1 = (v4c[r][1] & 0x0F0F0F0Fu) ^ 0x08080808u;
const uint32_t m1 = ((v4c[r][1] >> 4) & 0x0F0F0F0Fu) ^ 0x08080808u;
// Codes are two's complement nibbles; ^ 8 makes them offset binary (value + 8). i8:
// bytes, ^ 0x80; `n` is a key's dims 0-3 of the octet and `m` its dims 4-7.
const uint32_t n0 = I8 ? v4c[r][0] ^ 0x80808080u
: (v4c[r][0] & 0x0F0F0F0Fu) ^ 0x08080808u;
const uint32_t m0 = I8 ? v4c[r][1] ^ 0x80808080u
: ((v4c[r][0] >> 4) & 0x0F0F0F0Fu) ^ 0x08080808u;
const uint32_t n1 = I8 ? v4c[r][I8 ? 2 : 1] ^ 0x80808080u
: (v4c[r][1] & 0x0F0F0F0Fu) ^ 0x08080808u;
const uint32_t m1 = I8 ? v4c[r][I8 ? 3 : 1] ^ 0x80808080u
: ((v4c[r][1] >> 4) & 0x0F0F0F0Fu) ^ 0x08080808u;
const h2 s2 = __builtin_bit_cast(h2, OLDV4 ? v4s[r][0] : (v4s[r][0] | (v4s[r][1] << 16)));
const h2 bias = { (_Float16)1032.0f, (_Float16)1032.0f };
const h2 bias = { (_Float16)(I8 ? 1152.0f : 1032.0f), (_Float16)(I8 ? 1152.0f : 1032.0f) };
uint16_t* dst = &sV16[(o * 8) * VSTR + 2 * kp];
uint8_t* dst8 = &sV8[(o * 8) * VSTR8 + 2 * kp];
#pragma unroll
@@ -361,8 +384,9 @@ void r4d_attn_prefill_kernel(const R4DArgs a)
*(uint16_t*)(dst8 + (2 * b + 1) * VSTR8) = (uint16_t)pk_fp8x2_h(__builtin_bit_cast(uint32_t, vh));
continue;
}
*(uint32_t*)(dst + (2 * b) * VSTR) = __builtin_bit_cast(uint32_t, vl);
*(uint32_t*)(dst + (2 * b + 1) * VSTR) = __builtin_bit_cast(uint32_t, vh);
// The octet's rows: nibbles interleave the dims (2b, 2b+1), bytes run b, 4+b.
*(uint32_t*)(dst + (I8 ? b : 2 * b) * VSTR) = __builtin_bit_cast(uint32_t, vl);
*(uint32_t*)(dst + (I8 ? 4 + b : 2 * b + 1) * VSTR) = __builtin_bit_cast(uint32_t, vh);
}
}
}
@@ -385,6 +409,17 @@ void r4d_attn_prefill_kernel(const R4DArgs a)
#pragma unroll
for (int q = 0; q < (KVP ? (KEL / 8) : 1); ++q)
kreg[p * (KEL / 8) + q] = *(const uint4*)(g + 8 * q);
} else if (I8) {
// i8: the chunk's codes (sixteen, or eight without the wide fetch) and the
// key's scale.
const uint8_t* rp = (const uint8_t*)a.kv + o;
if constexpr (KWIDE) {
kreg[p] = *(const uint4*)(rp + ch * 16);
} else {
const uint2 r = *(const uint2*)(rp + ch * 8);
kreg[p] = make_uint4(r.x, r.y, 0, 0);
}
ksc8[p] = *(const uint16_t*)(rp + KSOFF);
} else if (K6) {
// k6_v4: the chunk's sixteen low nibbles, its high-bit word, its group's scale.
const uint8_t* rp = (const uint8_t*)a.kv + o;
@@ -454,7 +489,10 @@ void r4d_attn_prefill_kernel(const R4DArgs a)
w4[2] = D::from_bf16w(r.z); w4[3] = D::from_bf16w(r.w);
} else {
const uint4 r = kreg[p];
if constexpr (K6) k6x8_to_f16x4w(q ? r.y : r.x, r.z, q, r.w | (r.w << 16), w4);
if constexpr (I8)
i8x8_to_f16x4w(q ? make_uint2(r.z, r.w) : make_uint2(r.x, r.y),
ksc8[p] | (ksc8[p] << 16), w4);
else if constexpr (K6) k6x8_to_f16x4w(q ? r.y : r.x, r.z, q, r.w | (r.w << 16), w4);
else fp8x8_to_16x4w<D>(q ? make_uint2(r.z, r.w) : make_uint2(r.x, r.y), w4);
}
*(uint2*)(kd + 8 * q) = make_uint2(w4[0], w4[1]);