Archived
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:
1 parent
b4c04b6042
commit
ddcb9c69bb
696 files changed
+120770
-56596
No files matched your search
@@ -26,6 +26,8 @@
|
||||
* the bf16-rounded norm, a scale of amax * (1 / 448) per 128 columns (1 for an all-zero group),
|
||||
* value times reciprocal clamped to +-448, one v_cvt_pk_fp8_f32. Element i is thread i % 256 at
|
||||
* slot i / 256, so a group is four waves at one slot: a wave max, then the four.
|
||||
* norm_add_norm_route_i8g writes the experts' input as rmsnorm_had_quant_i8g does instead: int8
|
||||
* codes of the bf16-rounded norm rotated by a 128-wide Hadamard, a scale of amax * (1 / 127).
|
||||
*
|
||||
* One 256-thread block per row: a decode step is a handful of rows, so the row is latency bound
|
||||
* and three block reductions beat seven launches. Values a later stage reuses stay in registers
|
||||
@@ -42,6 +44,7 @@
|
||||
|
||||
#include "r4d_plugin.h"
|
||||
#include "r4d_launch.h"
|
||||
#include "r4d_q8.h" // norm_add_norm_route_i8g's rotated int8 codes
|
||||
#include "rad_plugin.h"
|
||||
|
||||
namespace r4d_join {
|
||||
@@ -114,11 +117,15 @@ struct NormArgs {
|
||||
};
|
||||
|
||||
/* t = norm(a) * w_a; x += t; y = norm(x) * w_y -- and with ROUTE, from the same norm of x, the
|
||||
* router's input norm(x) * w_r * mult and the experts' norm(x) * w_e as E4M3 codes and scales */
|
||||
template <int PER, bool ROUTE>
|
||||
* router's input norm(x) * w_r * mult and the experts' norm(x) * w_e as codes and scales: E4M3
|
||||
* (ROUTE 1), or at ROUTE 2 had_quant_act_i8g's rotated int8. The rotation's butterfly wants a
|
||||
* group in one wave, four columns a lane, where this kernel holds a column a thread, so the
|
||||
* experts' bf16 row goes through LDS to that mapping (r4d_q8.h, q8_row_had_i8g). */
|
||||
template <int PER, int ROUTE>
|
||||
__global__ __launch_bounds__(kThreads) void norm_add_norm_kernel(NormArgs A) {
|
||||
__shared__ float lds[kWaves];
|
||||
__shared__ float gmax[ROUTE ? PER * kWaves : 1];
|
||||
__shared__ float gmax[ROUTE == 1 ? PER * kWaves : 1];
|
||||
__shared__ uint16_t erow[ROUTE == 2 ? PER * kThreads : 1];
|
||||
const int tid = (int)threadIdx.x, n = A.n;
|
||||
const long long m = (long long)blockIdx.x;
|
||||
const uint16_t* ar = A.a + m * A.a_ld;
|
||||
@@ -164,13 +171,20 @@ __global__ __launch_bounds__(kThreads) void norm_add_norm_kernel(NormArgs A) {
|
||||
yr[i] = f2bf((xv[k] * sx) * wy[k]);
|
||||
if constexpr (ROUTE) {
|
||||
rr[i] = f2bf(((xv[k] * sx) * wr[k]) * A.mult);
|
||||
av[k] = rbf((xv[k] * sx) * we[k]); /* the experts' row, as quantised */
|
||||
const uint16_t he = f2bf((xv[k] * sx) * we[k]);
|
||||
av[k] = bf2f(he); /* the experts' row, as quantised */
|
||||
if constexpr (ROUTE == 2) erow[i] = he;
|
||||
}
|
||||
} else if constexpr (ROUTE) {
|
||||
av[k] = 0.0f;
|
||||
}
|
||||
}
|
||||
if constexpr (ROUTE) {
|
||||
if constexpr (ROUTE == 2) {
|
||||
__syncthreads();
|
||||
q8_row_had_i8g<kThreads>(erow, (signed char*)(A.q + m * A.q_ld), A.qs + m * A.qs_ld,
|
||||
(uint32_t)n);
|
||||
}
|
||||
if constexpr (ROUTE == 1) {
|
||||
/* group 2k + tid / 128 at slot k is waves 0..3 or 4..7: each wave's max, then its four */
|
||||
const int wave = tid >> 5, half = tid >> 7;
|
||||
#pragma unroll
|
||||
@@ -326,16 +340,19 @@ int r4d_rad_norm_add_norm_bf16(const RadArgs* a, RadStream stream) {
|
||||
P.w0 = (const float*)Wa->data; P.w1 = (const float*)Wy->data;
|
||||
P.n = (int)n; P.eps = eps;
|
||||
if (n <= (int64_t)kThreads * 12)
|
||||
R4D_KLAUNCH(R4D_KNAME(norm_add_norm_kernel<12, false>), dim3((unsigned)M), dim3(kThreads),
|
||||
R4D_KLAUNCH(R4D_KNAME(norm_add_norm_kernel<12, 0>), dim3((unsigned)M), dim3(kThreads),
|
||||
(hipStream_t)stream, P);
|
||||
else
|
||||
R4D_KLAUNCH(R4D_KNAME(norm_add_norm_kernel<kMaxPer, false>), dim3((unsigned)M),
|
||||
R4D_KLAUNCH(R4D_KNAME(norm_add_norm_kernel<kMaxPer, 0>), dim3((unsigned)M),
|
||||
dim3(kThreads), (hipStream_t)stream, P);
|
||||
return hipGetLastError() == hipSuccess ? RAD_OK : RAD_E_DEVICE;
|
||||
}
|
||||
|
||||
/* operands: a, w_a, x (inout), w_y, y, w_r, r, w_e, q, qs */
|
||||
int r4d_rad_norm_add_norm_route_bf16(const RadArgs* a, RadStream stream) {
|
||||
} /* extern "C" */
|
||||
|
||||
/* operands: a, w_a, x (inout), w_y, y, w_r, r, w_e, q, qs; `i8` is norm_add_norm_route_i8g, whose
|
||||
* q is int8 */
|
||||
static int norm_add_norm_route(const RadArgs* a, RadStream stream, bool i8) {
|
||||
using namespace r4d_join;
|
||||
if (!a || a->n_t < 10) return RAD_E_INVAL;
|
||||
int64_t n = 0;
|
||||
@@ -351,7 +368,7 @@ int r4d_rad_norm_add_norm_route_bf16(const RadArgs* a, RadStream stream) {
|
||||
int64_t ra = 0, la = 0, rx = 0, lx = 0, ry = 0, ly = 0, rr = 0, lr = 0, rq = 0, lq = 0,
|
||||
rs = 0, ls = 0;
|
||||
if (!rows_of(A_, n, &ra, &la) || !rows_of(X, n, &rx, &lx) || !rows_of(Y, n, &ry, &ly) ||
|
||||
!rows_of(R, n, &rr, &lr) || !rows_as(Q, RAD_F8E4M3, n, &rq, &lq) ||
|
||||
!rows_of(R, n, &rr, &lr) || !rows_as(Q, i8 ? RAD_I8 : RAD_F8E4M3, n, &rq, &lq) ||
|
||||
!rows_as(S, RAD_F32, n / 128, &rs, &ls))
|
||||
return RAD_E_SHAPE;
|
||||
const int64_t M = rx; /* the step's rows: the stream's view */
|
||||
@@ -368,15 +385,31 @@ int r4d_rad_norm_add_norm_route_bf16(const RadArgs* a, RadStream stream) {
|
||||
P.w2 = (const float*)Wr->data; P.w3 = (const float*)We->data;
|
||||
P.mult = (float)rad_args_getf_or(a, "mult", 1.0);
|
||||
P.n = (int)n; P.eps = eps;
|
||||
if (n <= (int64_t)kThreads * 12)
|
||||
R4D_KLAUNCH(R4D_KNAME(norm_add_norm_kernel<12, true>), dim3((unsigned)M), dim3(kThreads),
|
||||
const bool narrow = n <= (int64_t)kThreads * 12;
|
||||
if (narrow && i8)
|
||||
R4D_KLAUNCH(R4D_KNAME(norm_add_norm_kernel<12, 2>), dim3((unsigned)M), dim3(kThreads),
|
||||
(hipStream_t)stream, P);
|
||||
else if (narrow)
|
||||
R4D_KLAUNCH(R4D_KNAME(norm_add_norm_kernel<12, 1>), dim3((unsigned)M), dim3(kThreads),
|
||||
(hipStream_t)stream, P);
|
||||
else if (i8)
|
||||
R4D_KLAUNCH(R4D_KNAME(norm_add_norm_kernel<kMaxPer, 2>), dim3((unsigned)M),
|
||||
dim3(kThreads), (hipStream_t)stream, P);
|
||||
else
|
||||
R4D_KLAUNCH(R4D_KNAME(norm_add_norm_kernel<kMaxPer, true>), dim3((unsigned)M),
|
||||
R4D_KLAUNCH(R4D_KNAME(norm_add_norm_kernel<kMaxPer, 1>), dim3((unsigned)M),
|
||||
dim3(kThreads), (hipStream_t)stream, P);
|
||||
return hipGetLastError() == hipSuccess ? RAD_OK : RAD_E_DEVICE;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
int r4d_rad_norm_add_norm_route_bf16(const RadArgs* a, RadStream stream) {
|
||||
return norm_add_norm_route(a, stream, false);
|
||||
}
|
||||
int r4d_rad_norm_add_norm_route_i8g_bf16(const RadArgs* a, RadStream stream) {
|
||||
return norm_add_norm_route(a, stream, true);
|
||||
}
|
||||
|
||||
/* operands: d, w_d, r, w_r, w_j, x (inout), s, w_n?, y? -- the last two both or neither */
|
||||
int r4d_rad_join_add_scale_bf16(const RadArgs* a, RadStream stream) {
|
||||
using namespace r4d_join;
|
||||
|
||||
Reference in new issue
Block a user