Archived
radiance 1.15.0
New models and formats: - IQR for Qwen3.8-27B: weights on the int8 grid under GPTQ, a trellis down each GPTQ column (IQR-V2), and IQR-V3, a computed trellis code under one scale a row, kept at its codes' width in VRAM and decoded in the GEMM; 15 IQR-V3 recipes from ~2 to ~7 bits a weight (data/recipes/q38-27b-*-v3.recipe, docs/IQR.md) - libhalo: a kernel library for Strix Halo (gfx1151), preferred there over libr3d - Nemotron 3.5 Embed 1B and 8B (nemotron35_embed): text and image embeddings through a Pixtral tower, on the card and on the CPU - Nemotron 3.5 Rerank 8B - /v1/systemone: Cloudflare's clef and clef-flash, Convai Innovations' Laya and Mica beside LiquidAI d1; scored steps read the candidates' logits from the head table with no lm_head pass - LFM2's 8-bit trunk: block-fp8 or int8 linears with the fused producers, and the d1-3B recipe - DeepSeek-V4.1's reply format with DSML tool calls and typed argument tags Weights on the drive: - The file tier reads only the experts the pass routes rows to; the draft head's weights stay in the host pool - A hot VRAM cache for routed experts read off the drive, reads deposited straight into free host pool slots, and copyless evictions; the file tier's counters are now ssd_* - GLM-5 Next shards its routed experts by expert, not by width, so they can live on the drive - The stall watch counts drive reads as progress, and the DMA lane's room check reads the lane's own completion fence Quantisation tooling: - --calib-corpus, --calib-dir and --calib-layers record each linear's input Hessian; beside --kld-record the reference's own run records them - --kld-top N records a sparse KL reference (the N most likely tokens and the tail's mass) - GPTQ in a third of the time with the same codes, trellis GPTQ on the card, vector codebooks with coordinate descent, and rad-convert --reuse repeated, each container supplying what the earlier ones lack Speculation: - Prompt lookup alone (--spec-ngram K, --spec-ngram-min/-max): each sequence keeps an index of its n-grams, and a proposal is verified only when its measured step cost says it pays; --draft-window adaptive follows it Speed: - IQR decode: the narrow tile splits K for four times the int8 tile's waves and folds each 128-K block once; at 8 tokens down and the output projections run in 0.61-0.82x and 0.70-0.92x FP8's time (2-6 bits); IQ6R-S-V3 with its DFlash2 drafter steps in 26.3 ms at TP2, against 29.4 ms before and FP8's 27.3 - Qwen MXFP4 feed-forward: the gated fold up to 16 rows, not 8 - libr4d: the gated prefill fold, the short-prompt split row, and the rows forms of rmsnorm and rope; KLATE again for the head-256 gqa6 paged prefill; gram_accum on the matrix cores Features: - /health, /v1/health and /ping answer 503 with "status": "stuck" once the device has advanced nothing for a minute or a queue has faulted, so a supervisor can restart a wedged server (#356) - --image-gen-max-pixels and --image-gen-max-refs size an image generator's buffers (#344) - The startup report lists only the options not at their default, with a count; -v lists all (#250) - --preempt-wait-ms bounds how long a preempted prefill waits for its whole-recompute room - --placement layer_offload spills dense layers so one --max-model-len sequence fits - Startup refuses amdgpu with CWSR off and says how to fix it; --proceed-with-incompatible-configuration starts anyway under an UNSUPPORTED banner Fixes: - The n-gram read-ahead hands each row to the reader once and reads only as far ahead as the row cache holds, and pauses while decode reads: about one drive read a row instead of two (#355) - A file-tier window reads each of its runs once, not once a run per run - The decode split law's verify floor is bounded by the batch's workgroups: max_seqs 256 no longer declares 64x the scratch (#342) - A prefetch DMA list's mark stays out of the signal pool until the engine has read it, and a prefill stage copies only the blocks its own tables name (#343) - The split-KV row sum is read with fetch-inactive (#328) - LFM2 on the host backend: libref and libavx serve the row-form ops it declares (#348) - The preempted-prefill gate skips a KV group that holds no blocks (#352) - Every request entry point bounded, gated and sanitised (JSON depth, invalid UTF-8, control bytes in the log, the dashboard's CSP, cross-origin browsers on the loopback-only routes); a prompt id outside the vocabulary refused at admission; --api-key "" refused at startup - The telemetry the HTTP thread reads is atomic - An RMS norm row no longer depends on how many rows its launch carries; prefill attention's rescale is decided by live rows only - A --kld-record prefill chunk that finishes no sequence gets its logits on a tied-head model - A kernel's lazily made counter block is zeroed outside the lock other ranks take (a TP2 first-step hang) Changes: Plugin ABI 32. Every plugin exports a layout fingerprint of the ABI structs and the loader refuses a plugin without it or with another (#302), so out-of-tree plugins must be rebuilt. Appended: RadBuildCtx calib_* and gen_max_*, RadArchProbe gen_max_*, RadBatch score_only and plugin_words, RadDeviceProps::unified, RadChatFormat arg_json_value_prefix.
This commit is contained in:
commit
9ed3ef7a7b
452 files changed
+167762
-1346
No files matched your search
@@ -17,10 +17,11 @@
|
||||
// * every intermediate the chain stores in bf16 is rounded to bf16 here and the next stage reads
|
||||
// the rounded value: the post-norm output, the residual sum, the scaled residual and the norm
|
||||
// output the quantiser reduces over;
|
||||
// * both sums of squares use the standalone norm's partition: the width r4d_act_threads(M, n)
|
||||
// picks, thread t folding columns t, t+THR, ... in order, then r4d_wave_sum and the waves in
|
||||
// order through LDS (copied from r4d_model_bf16.hip's rmsnorm_kernel and block_sum, which live
|
||||
// in another unit);
|
||||
// * both sums of squares use the standalone norm's partition (kR4dSumLanes, r4d_common.h): lane
|
||||
// v < 256 folds columns v, v+256, ... in order, the lanes past it add nothing, then r4d_wave_sum
|
||||
// and the waves in order through LDS (copied from r4d_model_bf16.hip's rmsnorm_kernel and
|
||||
// block_sum, which live in another unit). At 256 threads a thread's own columns are that
|
||||
// partition; a wider block stages the row in LDS and its first 256 lanes fold it there;
|
||||
// * each element's arithmetic matches the standalone kernels (`x * s * (g + wadd)`,
|
||||
// `a + b`, `x * scalar`, `fmaxf(m, 1e-8f) / 127.f`), under -ffp-contract=off.
|
||||
//
|
||||
@@ -58,6 +59,17 @@ __device__ __forceinline__ float block_sum(float v, float* lds) {
|
||||
return s;
|
||||
}
|
||||
|
||||
// A row's sum of squares in the standalone norm's partition (kR4dSumLanes): lane v < 256 adds
|
||||
// columns v, v + 256, ... of `row` in order, the lanes past it add nothing, so a row's bits do not
|
||||
// depend on the block's width. `row` holds the row's bf16 values; when the block's threads wrote
|
||||
// it, the caller issues the barrier first.
|
||||
__device__ __forceinline__ float lanes_sumsq(const uint16_t* row, uint32_t n) {
|
||||
float ss = 0.0f;
|
||||
if (threadIdx.x < kR4dSumLanes)
|
||||
for (uint32_t i = threadIdx.x; i < n; i += kR4dSumLanes) { const float f = bf2f(row[i]); ss += f * f; }
|
||||
return ss;
|
||||
}
|
||||
|
||||
__device__ __forceinline__ float gain(const void* w, uint32_t i, bool f32) {
|
||||
return f32 ? ((const float*)w)[i] : bf2f(((const uint16_t*)w)[i]);
|
||||
}
|
||||
@@ -86,9 +98,10 @@ __device__ __forceinline__ void junction_row(
|
||||
if (SCL) v = f32_to_bf16(bf2f(v) * sv);
|
||||
rr[i] = v;
|
||||
}
|
||||
const float f = bf2f(v);
|
||||
ss2 += f * f;
|
||||
if constexpr (THR == kR4dSumLanes) { const float f = bf2f(v); ss2 += f * f; }
|
||||
else ybuf[i] = v;
|
||||
}
|
||||
if constexpr (THR != kR4dSumLanes) { __syncthreads(); ss2 = lanes_sumsq(ybuf, n); }
|
||||
ss2 = block_sum<THR / kWave>(ss2, l2);
|
||||
const float s2 = rsqrtf(ss2 / (float)n + eps);
|
||||
|
||||
@@ -164,7 +177,10 @@ __global__ __launch_bounds__(THR) void rmsnorm_quant_i8_kernel(
|
||||
float s1 = 0.0f;
|
||||
if (POST) {
|
||||
float ss = 0.0f;
|
||||
for (uint32_t i = threadIdx.x; i < n; i += THR) { const float v = bf2f(xr[i]); ss += v * v; }
|
||||
if constexpr (THR == kR4dSumLanes)
|
||||
for (uint32_t i = threadIdx.x; i < n; i += THR) { const float v = bf2f(xr[i]); ss += v * v; }
|
||||
else
|
||||
ss = lanes_sumsq(xr, n); // the branch output, read-only here
|
||||
ss = block_sum<THR / kWave>(ss, l1);
|
||||
s1 = rsqrtf(ss / (float)n + eps);
|
||||
}
|
||||
@@ -177,11 +193,11 @@ __global__ __launch_bounds__(THR) void rmsnorm_quant_i8_kernel(
|
||||
// The same kernel at decode heights (THR 1024, n <= 1024 * EPT), with every operand of the row
|
||||
// loaded in one go before the first reduction. The kernel above reads the row again in each pass,
|
||||
// each read behind a barrier, so a row costs three dependent memory round trips; on gfx1201 at
|
||||
// 1 to 16 rows of 5376 that is 11 us a launch against 8.2 us for this form. Every pass partitions
|
||||
// the row the same way (thread t takes columns t, t+THR, ...), so each thread keeps its own
|
||||
// columns in registers and none needs another's; only the fragment-order store crosses threads,
|
||||
// through `ybuf`. The sums, their order and every element's arithmetic are junction_row's, so the
|
||||
// output bytes are the same. One row of it, for this kernel and for the all-reduce's tail
|
||||
// 1 to 16 rows of 5376 that is 11 us a launch against 8.2 us for this form. Every elementwise pass
|
||||
// partitions the row the same way (thread t takes columns t, t+THR, ...), so each thread keeps its
|
||||
// own columns in registers; the sums and the fragment-order store cross threads through `ybuf`,
|
||||
// which holds the row each sum folds in the standalone norm's partition. The sums, their order and
|
||||
// every element's arithmetic are junction_row's, so the output bytes are the same. One row of it, for this kernel and for the all-reduce's tail
|
||||
// (ar_rmsnorm_quant_i8_tail_kernel).
|
||||
template <bool WF32, bool RES, bool POST, bool SCL, uint32_t THR, uint32_t EPT>
|
||||
__device__ __forceinline__ void junction_reg_row(
|
||||
@@ -211,7 +227,11 @@ __device__ __forceinline__ void junction_reg_row(
|
||||
float ss = 0.0f;
|
||||
#pragma unroll
|
||||
for (uint32_t e = 0; e < EPT; ++e)
|
||||
if (tid + e * THR < n) { const float v = bf2f(xv[e]); ss += v * v; }
|
||||
if (tid + e * THR < n) {
|
||||
if constexpr (THR == kR4dSumLanes) { const float v = bf2f(xv[e]); ss += v * v; }
|
||||
else ybuf[tid + e * THR] = xv[e];
|
||||
}
|
||||
if constexpr (THR != kR4dSumLanes) { __syncthreads(); ss = lanes_sumsq(ybuf, n); }
|
||||
s1 = rsqrtf(block_sum<THR / kWave>(ss, l1) / (float)n + eps);
|
||||
}
|
||||
|
||||
@@ -229,10 +249,11 @@ __device__ __forceinline__ void junction_reg_row(
|
||||
rr[i] = v;
|
||||
}
|
||||
xv[e] = v;
|
||||
const float f = bf2f(v);
|
||||
ss2 += f * f;
|
||||
if constexpr (THR == kR4dSumLanes) { const float f = bf2f(v); ss2 += f * f; }
|
||||
else ybuf[i] = v;
|
||||
}
|
||||
}
|
||||
if constexpr (THR != kR4dSumLanes) { __syncthreads(); ss2 = lanes_sumsq(ybuf, n); }
|
||||
const float s2 = rsqrtf(block_sum<THR / kWave>(ss2, l2) / (float)n + eps);
|
||||
|
||||
// ---- the norm output, rounded to bf16 as the standalone norm stores it, and its absmax
|
||||
@@ -360,8 +381,13 @@ __global__ __launch_bounds__(THR) void ar_rmsnorm_quant_i8_kernel(
|
||||
for (uint32_t i = tid; i < n; i += THR) {
|
||||
const uint16_t a = f32_to_bf16(bf2f(xr[i]) + bf2f(pr[i]));
|
||||
xr[i] = a;
|
||||
if (POST) { const float v = bf2f(a); ss += v * v; }
|
||||
if (POST) {
|
||||
if constexpr (THR == kR4dSumLanes) { const float v = bf2f(a); ss += v * v; }
|
||||
else ybuf[i] = a;
|
||||
}
|
||||
}
|
||||
if constexpr (THR != kR4dSumLanes)
|
||||
if (POST) { __syncthreads(); ss = lanes_sumsq(ybuf, n); }
|
||||
float s1 = 0.0f;
|
||||
if (POST) s1 = rsqrtf(block_sum<THR / kWave>(ss, l1) / (float)n + eps);
|
||||
junction_row<WF32, RES, POST, SCL, THR>(
|
||||
@@ -382,8 +408,8 @@ __global__ __launch_bounds__(THR) void ar_rmsnorm_quant_i8_kernel(
|
||||
// * A block owns whole rows, the two-rank fused form's partition, since a post-norm's sum of
|
||||
// squares closes over one row. Every rank runs the same grid over the same M, so block b's
|
||||
// words are the same words on every rank and the per-block handshake pairs them.
|
||||
// * The reduce is element by element in the norm's partition (thread t folds columns t, t+THR,
|
||||
// ...), so the post-norm's sum of squares is the standalone norm's. Each element is ar_vsum's
|
||||
// * The reduce is element by element, stored back into `x`, and the post-norm's sum of squares
|
||||
// folds the stored row in the standalone norm's partition (lanes_sumsq). Each element is ar_vsum's
|
||||
// arithmetic exactly: fp32 from 0.0f, the ranks in ascending order, one rounding to bf16 as the
|
||||
// __hip_bfloat16 cast rounds (bf16_hi_rne_nan). So the reduced row is the standalone exact
|
||||
// all-reduce's to the bit, and what follows is rmsnorm_quant_i8's junction over it.
|
||||
@@ -445,15 +471,15 @@ __global__ __launch_bounds__(THR) void ar_rmsnorm_quant_i8_wide_kernel(
|
||||
uint16_t* __restrict__ xr = x + o;
|
||||
/* The fold a 16-byte word a thread, every source's word in flight at once (the peers' are
|
||||
* in fine-grained memory, a round trip each), stored back into `x`; then the post-norm's
|
||||
* sum of squares over the stored row in the norm's partition. Per element it is the fold
|
||||
* fold_word8 documents, and the sum reads the same rounded values in the same order, so
|
||||
* the bytes are those of the fold and the sum taken in one pass. */
|
||||
* sum of squares over the stored row in the standalone norm's partition. Per element it is
|
||||
* the fold fold_word8 documents, and the sum reads the rounded values the standalone
|
||||
* all-reduce stores, so the bytes are those of the all-reduce and the norm taken apart. */
|
||||
for (int k = (int)tid; k < wpr; k += (int)THR)
|
||||
((int4*)xr)[k] = fold_word8<WS>(src4, (size_t)row * wpr + k);
|
||||
float ss = 0.0f;
|
||||
if (POST) {
|
||||
__syncthreads(); /* the folded row, read across the block's threads */
|
||||
for (uint32_t i = tid; i < n; i += THR) { const float v = bf2f(xr[i]); ss += v * v; }
|
||||
ss = lanes_sumsq(xr, n);
|
||||
}
|
||||
float s1 = 0.0f;
|
||||
if (POST) s1 = rsqrtf(block_sum<THR / kWave>(ss, l1) / (float)n + eps);
|
||||
@@ -635,8 +661,8 @@ __global__ __launch_bounds__(1024) void r4dchain_ar_rmsnorm_quant_i8_tail(R4D_AR
|
||||
// the two-shot's first hop) and takes the handshake;
|
||||
// 2. on its own row it folds the four partials in rank order -- r4d_ar_to_f, f32, rank 0 first,
|
||||
// r4d_ar_from_f, the standalone exact all-reduce's fold, so the same bf16 sum -- and runs the
|
||||
// junction on it in the register form at the standalone norm's width (r4d_act_threads), each
|
||||
// thread holding the columns the standalone's does, so every sum is the standalone's; it
|
||||
// junction on it in the register form, each sum folded in the standalone norm's partition
|
||||
// (lanes_sumsq), so every sum is the standalone's; it
|
||||
// stores the residual row and pushes the row's int8 codes and scale (and with `gres` the
|
||||
// residual row) into every peer's slot past the first hop's region, then takes the handshake;
|
||||
// 3. it copies the peers' local row b of codes and scales (and residual) into place.
|
||||
@@ -719,7 +745,11 @@ __device__ __forceinline__ void ar_rmsnorm_quant_i8_sp_body(
|
||||
float ss = 0.0f;
|
||||
#pragma unroll
|
||||
for (uint32_t e = 0; e < EPT; ++e)
|
||||
if (tid + e * THR < n) { const float v = bf2f(xv[e]); ss += v * v; }
|
||||
if (tid + e * THR < n) {
|
||||
if constexpr (THR == kR4dSumLanes) { const float v = bf2f(xv[e]); ss += v * v; }
|
||||
else ybuf[tid + e * THR] = xv[e];
|
||||
}
|
||||
if constexpr (THR != kR4dSumLanes) { __syncthreads(); ss = lanes_sumsq(ybuf, n); }
|
||||
const float s1 = rsqrtf(block_sum<THR / kWave>(ss, l1) / (float)n + eps);
|
||||
float ss2 = 0.0f;
|
||||
#pragma unroll
|
||||
@@ -731,10 +761,11 @@ __device__ __forceinline__ void ar_rmsnorm_quant_i8_sp_body(
|
||||
if (sc) v = f32_to_bf16(bf2f(v) * sv);
|
||||
rr[i] = v;
|
||||
xv[e] = v;
|
||||
const float f = bf2f(v);
|
||||
ss2 += f * f;
|
||||
if constexpr (THR == kR4dSumLanes) { const float f = bf2f(v); ss2 += f * f; }
|
||||
else ybuf[i] = v;
|
||||
}
|
||||
}
|
||||
if constexpr (THR != kR4dSumLanes) { __syncthreads(); ss2 = lanes_sumsq(ybuf, n); }
|
||||
const float s2 = rsqrtf(block_sum<THR / kWave>(ss2, l2) / (float)n + eps);
|
||||
float m = 0.0f;
|
||||
#pragma unroll
|
||||
@@ -878,8 +909,8 @@ extern "C" int r4d_rad_rmsnorm_quant_i8(const RadArgs* a, RadStream stream) {
|
||||
const size_t lds = (size_t)n * sizeof(uint16_t);
|
||||
if (lds > 60 * 1024) return R4D_NO(RAD_E_SHAPE);
|
||||
|
||||
// The same width rmsnorm_bf16 and quant_act_i8 pick, from the same function: it decides which
|
||||
// columns a thread folds into each sum of squares, hence the byte-identity.
|
||||
// The same width rmsnorm_bf16 and quant_act_i8 pick, from the same function. The sums fold in
|
||||
// kR4dSumLanes' partition at any width, so the width changes speed, not bytes.
|
||||
const int thr = r4d_act_threads((int)M, (int)n);
|
||||
const float eps = (float)r4d_getf(a, "eps", 1e-6);
|
||||
const float wadd = (float)r4d_getf(a, "wadd", 0.0);
|
||||
|
||||
Reference in new issue
Block a user