Archived
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.
160 lines
6.8 KiB
C++
160 lines
6.8 KiB
C++
/* Derived from libr4d/r4d_f32_tile.h by the libhalo rename transform (2026-10-26);
|
|
* see libhalo/README.md. Op schemas, row names and stored weight layouts are
|
|
* shared with libr4d by design. Everything else in this file is libhalo's own
|
|
* and diverges as it is measured on gfx1151. */
|
|
// halo_f32_tile.h -- the register-blocked f32 GEMM tile under libhalo's f32 GEMM (gemm_nt_bias at
|
|
// f32) and its f32 convolutions (conv1d and conv_t1d as implicit GEMMs, halo_audio.hip).
|
|
//
|
|
// One 256-thread workgroup computes a BM x BN block (BM = 16 TM, BN = 16 TN) of C = A . W^T over
|
|
// K. Both operands are staged through LDS k-major, sixteen K a slab and two slabs of LDS, so the
|
|
// next slab's global loads are in flight under the current slab's FMAs and one barrier a slab
|
|
// suffices. A thread owns TM x TN accumulators and reads its operands from LDS as float4 (or
|
|
// float2) rows; every product is a fused multiply-add in ascending K, one rounding a product and
|
|
// sum, against libref's separate multiply and add in the same order.
|
|
//
|
|
// The operands come from loader policies: a thread stages rows `r0 + 16 j` of A (j < TM) and of W
|
|
// (j < TN) at one K column a slab, `kk = 16 slab + (tid % 16)`, so a GEMM reads rows in place and
|
|
// a convolution gathers the input row a tap reads, with its sequence's zero padding, from the same
|
|
// slot. A row or column past the operand reads zero. The epilogue is the caller's: it receives
|
|
// each run of contiguous columns a thread owns, in registers.
|
|
//
|
|
// Thread (tx, ty) = (tid % 16, tid / 16) owns rows g 16 RW + ty RW + r and columns
|
|
// g 16 CW + tx CW + c, RW = run_of(TM) and CW = run_of(TN): a wave's sixteen tx read 16 CW
|
|
// contiguous floats of W's slab row, conflict-free, and the two ty values of a wave read two A
|
|
// vectors, each broadcast. The LDS pitch is padded by four floats, which spreads the staging
|
|
// stores (a wave's 16 K columns of one row) over distinct banks.
|
|
#pragma once
|
|
|
|
#include <hip/hip_runtime.h>
|
|
#include <cstdint>
|
|
|
|
namespace halo_f32 {
|
|
|
|
constexpr int kThr = 256;
|
|
constexpr int kBK = 16; // K a staged slab
|
|
|
|
// The run a thread owns along an axis of `t` values: four where `t` is whole fours, else two (a
|
|
// tile of 6 columns is three runs of two, so a 96-wide output fills its tile exactly).
|
|
constexpr int run_of(int t) { return t % 4 == 0 ? 4 : 2; }
|
|
|
|
// A plain row-major f32 operand: row r, column k at p[r * ld + k], zero past `rows` or `K`. Every
|
|
// load is issued, at an address clamped into the operand, and the zero selected after it: a load
|
|
// guarded by a branch serialises the slab's loads behind one another. Offsets are 32-bit, so the
|
|
// operand spans fewer than 2^32 elements (the shims check).
|
|
template <int CNT>
|
|
struct RowsLoader {
|
|
const float* p;
|
|
int ld, rows, K;
|
|
int k = 0;
|
|
uint32_t off[CNT];
|
|
bool live[CNT];
|
|
__device__ void init(int first_row, int kk) {
|
|
k = kk;
|
|
#pragma unroll
|
|
for (int j = 0; j < CNT; ++j) {
|
|
const int r = first_row + 16 * j;
|
|
live[j] = r < rows;
|
|
off[j] = (uint32_t)(r < rows ? r : rows - 1) * (uint32_t)ld;
|
|
}
|
|
}
|
|
__device__ void fetch(float (&v)[CNT]) const {
|
|
const bool kl = k < K;
|
|
const uint32_t kc = (uint32_t)(kl ? k : K - 1);
|
|
#pragma unroll
|
|
for (int j = 0; j < CNT; ++j) {
|
|
const float x = p[off[j] + kc];
|
|
v[j] = (live[j] && kl) ? x : 0.0f;
|
|
}
|
|
}
|
|
__device__ void advance() { k += kBK; }
|
|
};
|
|
|
|
template <int TM, int TN, class LA, class LW, class EP>
|
|
__device__ __forceinline__ void tile(LA& la, LW& lw, int K, EP& ep) {
|
|
constexpr int BM = 16 * TM, BN = 16 * TN;
|
|
constexpr int AP = BM + 4, WP = BN + 4;
|
|
constexpr int RW = run_of(TM), RG = TM / RW;
|
|
constexpr int CW = run_of(TN), CG = TN / CW;
|
|
static_assert(RW * RG == TM && CW * CG == TN && (RW == 2 || RW == 4) && (CW == 2 || CW == 4),
|
|
"a thread's rows and columns are whole runs of two or four");
|
|
__shared__ __attribute__((aligned(16))) float sA[2][kBK][AP];
|
|
__shared__ __attribute__((aligned(16))) float sW[2][kBK][WP];
|
|
|
|
const int tid = threadIdx.x, tx = tid & 15, ty = tid >> 4;
|
|
|
|
float acc[TM][TN];
|
|
#pragma unroll
|
|
for (int i = 0; i < TM; ++i)
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; ++j) acc[i][j] = 0.0f;
|
|
|
|
float ra[TM], rw[TN];
|
|
la.fetch(ra);
|
|
lw.fetch(rw);
|
|
const int ns = (K + kBK - 1) / kBK;
|
|
for (int s = 0; s < ns; ++s) {
|
|
const int b = s & 1;
|
|
#pragma unroll
|
|
for (int j = 0; j < TM; ++j) sA[b][tx][ty + 16 * j] = ra[j];
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; ++j) sW[b][tx][ty + 16 * j] = rw[j];
|
|
__syncthreads();
|
|
if (s + 1 < ns) {
|
|
la.advance();
|
|
lw.advance();
|
|
la.fetch(ra);
|
|
lw.fetch(rw);
|
|
}
|
|
#pragma unroll
|
|
for (int k = 0; k < kBK; ++k) {
|
|
float a[TM], w[TN];
|
|
#pragma unroll
|
|
for (int g = 0; g < RG; ++g) {
|
|
const float* src = &sA[b][k][g * 16 * RW + ty * RW];
|
|
if constexpr (RW == 4) {
|
|
const float4 q = *(const float4*)src;
|
|
a[g * 4] = q.x; a[g * 4 + 1] = q.y; a[g * 4 + 2] = q.z; a[g * 4 + 3] = q.w;
|
|
} else {
|
|
const float2 q = *(const float2*)src;
|
|
a[g * 2] = q.x; a[g * 2 + 1] = q.y;
|
|
}
|
|
}
|
|
#pragma unroll
|
|
for (int g = 0; g < CG; ++g) {
|
|
const float* src = &sW[b][k][g * 16 * CW + tx * CW];
|
|
if constexpr (CW == 4) {
|
|
const float4 q = *(const float4*)src;
|
|
w[g * 4] = q.x; w[g * 4 + 1] = q.y; w[g * 4 + 2] = q.z; w[g * 4 + 3] = q.w;
|
|
} else {
|
|
const float2 q = *(const float2*)src;
|
|
w[g * 2] = q.x; w[g * 2 + 1] = q.y;
|
|
}
|
|
}
|
|
#pragma unroll
|
|
for (int i = 0; i < TM; ++i)
|
|
#pragma unroll
|
|
for (int j = 0; j < TN; ++j) acc[i][j] = __builtin_fmaf(a[i], w[j], acc[i][j]);
|
|
}
|
|
/* One barrier a slab: the next slab goes to the other buffer, which every thread finished
|
|
* reading before it passed this slab's barrier. */
|
|
}
|
|
|
|
/* A run of CW columns as one float4 (the last two lanes unused at CW 2), so the accumulators
|
|
* stay in registers through the caller's store; `gj` says which of the thread's CG runs it
|
|
* is, for state the caller keeps per run. */
|
|
#pragma unroll
|
|
for (int gi = 0; gi < RG; ++gi)
|
|
#pragma unroll
|
|
for (int r = 0; r < RW; ++r)
|
|
#pragma unroll
|
|
for (int gj = 0; gj < CG; ++gj) {
|
|
const float* q = acc[gi * RW + r] + gj * CW;
|
|
float4 v;
|
|
if constexpr (CW == 4) v = make_float4(q[0], q[1], q[2], q[3]);
|
|
else v = make_float4(q[0], q[1], 0.0f, 0.0f);
|
|
ep(gi * 16 * RW + ty * RW + r, gj * 16 * CW + tx * CW, CW, v, gj);
|
|
}
|
|
}
|
|
|
|
} // namespace halo_f32
|