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.
123 lines
6.1 KiB
Plaintext
123 lines
6.1 KiB
Plaintext
/* Derived from libr4d/r4d_qsa_tail_store_bf16.hip by the libhalo rename transform (2026-10-26),
|
|
* then ported to gfx1151; see libhalo/README.md. */
|
|
// The QSA indexer's tail: raw index keys of tokens that have not yet completed a block (a block key
|
|
// needs all `ratio` raw keys, and at decode most of them come from earlier steps).
|
|
//
|
|
// The tail is a per-layer linear KV state owned by the sequence (allocated zeroed, kept for the
|
|
// sequence's life, checkpointed with the linear state), not a plane indexed by the step-local batch
|
|
// row (arch/common/rad_qsa.h's Wire). `state` is one layer's cache, [slots, 1, ring, n]; `sidx`
|
|
// names the sequence's slot; position p lands at row p % ring.
|
|
//
|
|
// The ring is ratio + n_spec, not ratio: the next step restarts at the first rejected position, so
|
|
// a step may still owe positions back to p0 - ratio + 1 while writing up to p0 + n_spec. With that
|
|
// ring length a row is only overwritten by a position past any step that could still need it.
|
|
//
|
|
// A token's sequence comes from cu_seqlens (slot_mapping is a flat KV slot and does not identify
|
|
// the sequence); a linear scan suffices for a handful of sequences.
|
|
//
|
|
// Only the last `ring` tokens of a sequence's chunk write: positions p and p + ring share a row, so
|
|
// writing all of a prefill chunk would race. The last `ring` positions hit distinct rows, giving
|
|
// what a token-by-token loop would leave; older tokens' blocks are built from the chunk itself.
|
|
//
|
|
// Returns a RAD status rather than throwing, for the reason given in halo_gemm_fp8a8.hip.
|
|
|
|
#include "halo.h"
|
|
#include "halo_args.h"
|
|
#include "halo_emit.h"
|
|
|
|
#include <hip/hip_runtime.h>
|
|
#include <cstdint>
|
|
|
|
namespace {
|
|
|
|
constexpr int kThreads = 256;
|
|
|
|
__global__ __launch_bounds__(kThreads) void qsa_tail_store_kernel(
|
|
const uint16_t* __restrict__ k, const int32_t* __restrict__ pos,
|
|
const int32_t* __restrict__ cu, const int32_t* __restrict__ sidx,
|
|
uint16_t* __restrict__ state,
|
|
int T, int n, int ring, int seqs, int k_ld, int s_slot, int s_row, int sidx_ld) {
|
|
|
|
const int t = (int)blockIdx.x;
|
|
if (t >= T) return;
|
|
|
|
/* This token's sequence, by a linear scan in every thread (cheaper than LDS plus a barrier). */
|
|
int s = -1;
|
|
for (int i = 0; i < seqs; ++i)
|
|
if (t >= cu[i] && t < cu[i + 1]) { s = i; break; }
|
|
if (s < 0) return;
|
|
|
|
/* Only the last `ring` tokens of this sequence's chunk -- see the header. */
|
|
if (t < cu[s + 1] - ring) return;
|
|
|
|
/* Column 0 is the committed slot; -1 marks a sequence with no state. */
|
|
const int si = sidx[(size_t)s * sidx_ld];
|
|
if (si < 0) return;
|
|
|
|
const int row = pos[t] % ring;
|
|
const size_t src = (size_t)t * k_ld;
|
|
const size_t dst = (size_t)si * s_slot + (size_t)row * s_row;
|
|
for (int d = (int)threadIdx.x; d < n; d += kThreads) state[dst + d] = k[src + d];
|
|
}
|
|
|
|
} // namespace
|
|
|
|
// k [T][n] bf16, `k_ld` elements a row (0 = n)
|
|
// pos [T] i32, each token's position in its sequence
|
|
// cu [seqs + 1] i32, cu_seqlens
|
|
// sidx [seqs][sidx_ld] i32, the tail group's state row; column 0 is the committed slot
|
|
// state [slots][ring][n] bf16, this layer's tail cache; written only, untargeted rows
|
|
// keep their contents
|
|
static int halo_qsa_tail_store_bf16_emit(long k, long pos, long cu, long sidx, long state, int T,
|
|
int n, int ring, int seqs, int k_ld, int s_slot, int s_row,
|
|
int sidx_ld, RadStream stream) {
|
|
if (!k || !pos || !cu || !sidx || !state) return HALO_NO(RAD_E_INVAL);
|
|
if (T <= 0 || n <= 0 || ring <= 0 || seqs <= 0) return HALO_NO(RAD_E_SHAPE);
|
|
if (!k_ld) k_ld = n;
|
|
if (!s_row) s_row = n;
|
|
if (!sidx_ld) sidx_ld = 1;
|
|
return HALO_EMIT(stream, qsa_tail_store_kernel, dim3((unsigned)T), dim3(kThreads), 0,
|
|
(const uint16_t*)k, (const int32_t*)pos, (const int32_t*)cu,
|
|
(const int32_t*)sidx, (uint16_t*)state, T, n, ring, seqs, k_ld, s_slot, s_row,
|
|
sidx_ld);
|
|
}
|
|
|
|
// ============================================================== the plugin ABI entry point
|
|
|
|
enum { QT_K = 0, QT_POS = 1, QT_CU = 2, QT_STATE = 3, QT_SIDX = 4 };
|
|
|
|
extern "C" int halo_rad_qsa_tail_store(const RadArgs* a, RadStream stream) {
|
|
const RadTensor* k = halo_opt(a, QT_K);
|
|
const RadTensor* po = halo_opt(a, QT_POS);
|
|
const RadTensor* cu = halo_opt(a, QT_CU);
|
|
const RadTensor* st = halo_opt(a, QT_STATE);
|
|
const RadTensor* sx = halo_opt(a, QT_SIDX);
|
|
if (!k || !po || !cu || !st || !sx) return HALO_NO(RAD_E_INVAL);
|
|
if (k->rank != 2) return HALO_NO(RAD_E_SHAPE);
|
|
/* The state arrives as the group declared it: [slots, heads, ring, n], heads 1
|
|
* (core/engine_bringup.cpp). */
|
|
if (st->rank != 4 || st->shape[1] != 1) return HALO_NO(RAD_E_SHAPE);
|
|
if (st->stride[3] != 1) return HALO_NO(RAD_E_STRIDE);
|
|
const long long n = halo_geti_or(a, "n", 0);
|
|
const long long ratio = halo_geti_or(a, "ratio", 0);
|
|
const long long ring = halo_geti_or(a, "ring", 0);
|
|
if (n <= 0 || ratio <= 0 || ring < ratio) return HALO_NO(RAD_E_INVAL);
|
|
const long long T = k->shape[0];
|
|
if (T < 1 || k->shape[1] != n) return HALO_NO(RAD_E_SHAPE);
|
|
if (st->shape[2] < ring || st->shape[3] != n) return HALO_NO(RAD_E_SHAPE);
|
|
/* The sequence count comes from cu_seqlens, not the state's slot count (the declared
|
|
* max_seqs). */
|
|
const long long seqs = halo_numel(cu) - 1;
|
|
if (seqs < 1 || halo_numel(po) < T) return HALO_NO(RAD_E_SHAPE);
|
|
const long long sxp = sx->rank >= 2 ? halo_row_pitch(sx) : 1;
|
|
if (sxp < 1 || halo_dim(sx, 0) < seqs) return HALO_NO(RAD_E_SHAPE);
|
|
const long long kp = halo_row_pitch(k);
|
|
if (kp < 0) return HALO_NO(RAD_E_STRIDE);
|
|
if (k->dtype != RAD_BF16 || st->dtype != RAD_BF16) return HALO_NO(RAD_E_DTYPE);
|
|
return halo_qsa_tail_store_bf16_emit(halo_addr(k), halo_addr(po), halo_addr(cu), halo_addr(sx),
|
|
halo_addr(st), (int)T, (int)n, (int)ring, (int)seqs,
|
|
(int)kp, (int)st->stride[0], (int)st->stride[2],
|
|
(int)sxp, stream);
|
|
}
|
|
|