Archived
d0fd4aa1bb413bd75f5467daf6c8ae274c8a3d7d
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
87c604370d |
libr3d: add 8 kernels — MoE GEMM (w4a8, w4a4, mod4), dequant_w4, row_topk_merge, ngram_ids, gemm_nt_q_bias, gemm_nt_q_short
moe_gemm_q w4a8: the 2-class MoE GEMM with bf16 weight scale and bf16 output. E4M3 activation codes, bf16 weight scale (not f32), single 16x128-block i32 wave-matrix config. The w4a8 dtype row is folded into the existing moe_gemm_q op as a dtype variant, not a separate op. moe_gemm_w4a4: the 2-class MoE GEMM with int4 activation codes and int4 weight codes. i32 wave-matrix core (no E4M3 decode table), symmetric int4 x int4 multiply-accumulate. Single fixed 16x128-block config. moe_gemm_q_mod4: the 4-class MoE GEMM. Experts route to class e%4 (entry e/4 within the class). Same E4M3 wave-matrix core as moe_gemm_q_e4m3, with 8 individual R3dTab parameters (4 weight + 4 scale tables) to stay within the gfx1102 kernel parameter limit. dequant_w4: packed int4 weight to row-major bf16. Each 32-bit word holds 8 int4 codes; the scale is f16 in the low 16 bits, the zero point is -(1024+zero) as f16 in the high 16 bits. One warp per 32 output elements. row_topk_merge: top-R of gathered per-rank candidate sets. Each rank contributes a sorted candidate list; the merge selects the top-R global candidates by score. int32 ids are bit patterns in an f32 plane (memcpy, not cast). ngram_ids: hashed n-gram row ids for PLE (Per-Layer Embedding). Computes the row index for each n-gram in the sequence using a FNV-1a hash folded into the embedding table size. gemm_nt_q_bias: narrow fp8 GEMM (M <= 16) with per-column bf16 bias fused into the epilogue. The bias is added to the f32 accumulator before the single bf16 narrowing at the store. Extends r3d_gemm_nt_q_fp8_ex with a bias parameter. gemm_nt_q_short: narrow fp8 GEMM (M <= 16) for short-prompt decode, unsplit K. Forces sk=1 (no K-split) in r3d_gemm_nt_q_fp8_ex. The short-prompt path avoids the K-split overhead when K is small. The two narrow fp8 rows carry the tGemmM16 tune matrix (sk 0/1/2/4/8/16, wv 1/2/4/8, nt, the two E4M3 decode impls, 16-row tiles) like the other gemm_nt_q rows, measured per card by rad-tune. The six new ops adopt the canonical op schemas. The engine enforces schema identity across kernel libraries: the first library to declare an op fixes its schema, and a disagreeing plugin is refused whole at load. libavx loads first, so the specs match the canonical registries: - moe_gemm_q_mod4: 15 params / 13 operands (the eight weight tables at the RAD_OPD_WTAB role); the launcher reads a_order (token/sorted), requires group = 128, checks the activation's row count against the output, and refuses unequal class shapes (N_1..K_3 differ from N/K) as moe_gemm_q does with N_odd/K_odd. - ngram_ids: 4 params / 11 operands under the canonical names; state required; per, W and the ids pitch derive from the operand shapes. - row_topk_merge: 4 params (+dtype) / 3 operands. - gemm_nt_q_short: the family's four optional params (pb1, pb2, split_n, w_rb) and two optional operands (a_sum, b_ref). - gemm_nt_q_bias: a_scale required, not optional. - dequant_w4: the dtype param, twos required, the scale operand named ws; the launcher refuses zero rows with RAD_E_SHAPE like every other op. A kernel audit found five launcher param reads the engine can never populate (the spec's params plus the row's tune axes are the only sources): pb1/pb2 in the gemm_nt_q_bias launcher, splits in the decode attention path, and nt/kb/sk in the tiled rows that tune only impl. Each always took its default; the reads are deleted, behavior- identical. All 8 verified bit-exact on gfx1102 (RX 7600, box card 2). Selftest: 117 rows clean, 0 failed. rad-schemas over libavx, libr3d, libr4d and libref: 244 shared ops, 0 disagree. |
||
|
|
34c52ebe96 |
libr3d: the RDNA3 (gfx11) wave-matrix kernel plugin
A self-contained HIP kernel plugin for gfx11 (RDNA3) that exposes the
libref-declared ops as device rows the engine can tune and dispatch:
* GEMMs (bf16, f16, int8-activation, vocab) retiled to 16x128 on the
wave-matrix (WMMA) builtins. The retile removes the 8x wave
redundancy of the naive tile and stages the activation once per
16x128 block; the 16-row and 64-row forms share the stage. The k-walk
double-buffers the 128-deep tile (the next tile stages while the
current one multiplies), on the m64 and tiled forms.
* Quantised GEMMs: fp8-e4m3 x e4m3 (tiled and ALU), mxfp4 x a8, w2a8,
w4a16, w5a16, w8a8 (the prefill heights 17..127 on the wave matrix),
and the gated (swiglu) form. E4M3 decodes exactly to f16 through a
256-entry LDS table; the WMMA fragments bit-cast the staged halfs
(a uint16-to-_Float16 assignment is a value conversion, not a
reinterpret).
* Half-precision-accumulate arms (acc = 1) on the m64 wave matrix:
the f16/bf16 16x16x16 builtins with the compile-time opsel half
select.
* Grouped MoE GEMMs (bf16, e4m3 with F32 block scales, mxfp4a8, w4a8),
retiled the same way, over the run-walk / gather structure.
* Normalisation (layernorm / rmsnorm) and the quantisation ops.
* GDN linear-attention, the QSA/KV state ops, and the MoE
router/scatter/gather family (router_topk_scatter, router_sigmoid_topk
with the correction bias, moe_gather, moe_gather_inv; the top-k
router runs to n_expert 512).
Every row implements an op libref declares; the selector (tune) picks
the implementation and the NOTUNE rows carry the untuned default.
Selftest-clean (121 rows, schema + finiteness); values verified against
CPU references per op.
|
||
|
|
4a61d7296b |
radiance 1.14.0
New models and formats: - libr3d: a kernel library for RDNA3 (gfx11) cards - nomic-embed-text-v2-moe (the nomicbert plugin) - Gemma 4 E2B with its per-layer MLP width, and Google's unmodified E2B/E4B directories in bf16 - DeepSeek-V4.1-Flash converted straight from its release: the Engram tables, the fused imatrix and rad-convert --chat-template for a release that ships no template - GGUF Q8_0, Q4_K and Q6_K tensors import as their planes; rad-convert writes them without a recipe - Qwen3.8-Flash-Next-FP8 converts and serves through qwen4exp_fp8 Speed: - hc_read's decode kernels as one grid (34.7 -> 25.2 us at 4 rows) and its tiled up-mix pipelined - gemm_fp8a8: the narrow form's scales staged through LDS (Flash-Next int8 at 32 rows 83.6 -> 68.3 us), the gated three-tile form at 8 waves (gate_up at 48 rows 272.9 -> 180.6 us) - Qwen3.8-27B: the delta net's out-projection read beside its decode recurrent update (x1 19.40 -> 19.10 ms a step), and the verify's split-KV attention sized by context depth (x3 at 180K 42.4 -> 40.3 ms a step) - Hy-Memory (HYV3) decode: fused QK norm, RoPE and KV store, residual adds folded into the norms, coalesced one-token expert GEMMs - spechub: the coupled verify walks the live candidates only (151 -> 31 us a launch) Speculation: - DFlash2: lossless coupled acceptance at T > 0 (--draft-coupling on) - A block drafter's proposals verified as a tree, on by default for the Gemma 4 31B's DFlash2, with a block-16 tree that runs its short block under load Features: - Decode-hot residency: --draft-expert-placement host, --expert-profile, --expert-pin-top, and --expert-stats FILE for the routed experts each layer selects - --ngram-placement ram=DIR: one n-gram table shared by engines on separate cards - Prefix cache: --prefix-resume exact (default) resumes a hit on the cold run's own chunk grid, so it answers bit-identically; snapshots at a head other prompts share, from 528-token prompts, and for tip-only one drafter window below the tip; hits on models whose KV groups have different block sizes; the snapshot store keeps a floor of 8 ahead of --host-headroom-mib - Typed tool-call argument tags; rad-chatparse --request renders and reads back one request as the server does - MiniMax-H3: keyframes ride a latent upscale - Gemma 3's fused all-reduce junction on the lossy wire Fixes: - A speculative step shorter than its band (an MTP step of 4 rows at gqa 8) no longer stops the engine with a scratch refusal at issue (#293) - --p2p off: prefill back to 1.12.0's rate; 1.13.0's push check read a host-memory slot over the link twice (#323) - A chat template that cannot render a conversation is refused at load, not mid-request - imatrix entries found under llama.cpp's spelling; the W4A8 prefill's tail scale read; the GDN conv kernels on an f32 weight; dense integer rows at the group they compute (a Q8_0 weight at group 32) - --expert-profile refuses a profile recorded on another model - hc_read's one-grid wait traps past its deadline instead of reading a stale value Changes: Plugin ABI 31, unchanged. RADIANCE_DRAFT_TREE, DFLASH2_TREE_NODES, DFLASH2_TREE_TEMP and DFLASH_Q_TEMP are gone (trees run where the probe says they pay; temperatures 1.25 / 0.6). |
||
|
|
6cb9826975 |
libr3d: the gfx11 (RDNA3) kernel library
A complete row set for the gfx11 family (1100/1101/1102/1103/1150/1151 plus gfx11-generic), mirroring libr4d's structure: the quantised GEMM rows (m16, tiled, gated, the bf16 logits gemm), the paged and ragged attention for decode and prefill, the KV store, the sampler spine and the spec rows, with the recorded-fixture, board, selftest and comparison-driver gates for each. The gates are the record. Every row is measured against libref on the shape matrix: the recorded fixture at 1153 cases with worst rel_l2 1.362e-03, the board's five modes with bit-identical decision lines, the selftest at 74 rows, and the 233-case served-shape pairing at 0 divergent against the tree libref. End-to-end on a 2B fp8 checkpoint served on the card, coherent through prefix-cache adoption. Two platform laws each shape the design. A kernel that calls device printf takes the implicit hidden_hostcall_buffer argument and is undispatchable by the AQL backend, so the trace records are plain stores behind a budget. And a plugin-owned __device__ global is not a channel into the engine's dispatch path: in a dlopened plugin the runtime's symbol stub is not the address the kernel's module writes, so the served trace channel is a hipMalloc'd record slot passed as a kernel argument, with the device-global ring kept for the board. kv_store bounds its slots at the pool's own plane (n_blocks x block_size), the span the cache operand declares, not at the step's own span: a request that adopts a cached prefix writes its new tokens at the allocator's global block indices, which sit past any bound built from the step's token count, and a slot lost there is KV that attention then reads stale. A corrupt slot map is dropped at the same bound. |