Archived
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).
This commit is contained in:
1 parent
481fcd5df0
commit
4a61d7296b
160 files changed
+8790
-6819
No files matched your search
+24
-35
@@ -1,36 +1,26 @@
|
||||
/* r3d_fp8_dequant.h -- the E4M3 -> f16 decoder as a table, for the rows that read fp8 codes.
|
||||
/* r3d_fp8_dequant.h -- E4M3 -> f16 decode through a 256-entry LDS table.
|
||||
*
|
||||
* WHY THIS EXISTS, WITH THE MEASUREMENT THAT ASKED FOR IT
|
||||
* gfx11 has no E4M3-to-f16 instruction: `__builtin_amdgcn_cvt_pk_f16_fp8` compiles on gfx1102 but
|
||||
* emits no `v_cvt_pk_f16_fp8`, only the same software exponent work as `e4m3_to_f32`. The codec in
|
||||
* r3d_codecs.h costs about 25 instructions a pair, 100 an eight-code group. On the M=1 vocabulary
|
||||
* head (r3d_vocab_bf16.hip, gfx1102, 32 CU) that makes the row ALU-bound at about 8x its DRAM floor.
|
||||
*
|
||||
* gfx11 has no instruction that converts E4M3 to f16. clang lists `__builtin_amdgcn_cvt_pk_f16_fp8`
|
||||
* for the target, and a build that calls it on gfx1102 contains ZERO `v_cvt_pk_f16_fp8` in its ISA:
|
||||
* the builtin is software here, lowered to the same exponent work `e4m3_to_f32` does. r3d_codecs.h's
|
||||
* codec is two `e4m3_to_f32` (a dozen instructions of shifts, exponent bias and subnormal handling
|
||||
* each) plus a pack, about 25 instructions a pair, 100 an eight-code group. Measured on the
|
||||
* vocabulary head at M=1 (r3d_vocab_bf16.hip, RX 7600 / gfx1102 / 32 CU): 13.603 ms a token at
|
||||
* 19.6 GB/s of codes, 8x above the 1.64 ms the codes' 255 MiB floor at this row's own 163 GB/s, and
|
||||
* the ALU was the binding resource, not DRAM.
|
||||
* Every one of E4M3's 256 bit patterns has an exact f16 value (f16's exponent range covers E4M3's,
|
||||
* subnormals included, and NaN maps to NaN), so the decoder is a 512-byte table and eight LDS reads
|
||||
* replace about a hundred ALU instructions. The table lives in LDS, not __constant__: each lane
|
||||
* decodes a different code, and divergent constant indexes serialise.
|
||||
*
|
||||
* E4M3 has 256 bit patterns and every one of them has an f16 value (f16's exponent range covers
|
||||
* E4M3's, its subnormals included, and E4M3's NaN maps to an f16 NaN). So the decoder is a
|
||||
* 256-entry table of 512 bytes, and eight LDS reads replace the hundred ALU instructions. That is
|
||||
* the whole idea, and the table goes in LDS -- not __constant__, whose broadcast is a liability here
|
||||
* because every lane decodes a DIFFERENT code, and divergent constant indexes serialise.
|
||||
* Cost: 512 bytes of LDS a block and a 256-store fill plus a barrier at block start. Reads are
|
||||
* 16-bit loads at data-dependent addresses; random codes put about two lanes on each bank word, for
|
||||
* about two cycles a read.
|
||||
*
|
||||
* Cost: 512 bytes of LDS a block, one fill of 256 stores at block start plus a barrier. Conflict
|
||||
* behaviour on the reads: 16-bit loads at data-dependent addresses, so a wavefront's 32 lanes land
|
||||
* on 16 bank words; random codes give roughly two lanes per word, and measured cost is about two
|
||||
* cycles a read -- eight reads an eight-code group against the codec's hundred instructions.
|
||||
* The table is filled by calling the codec once per entry, so results are bit-identical to the
|
||||
* codec. Invariant: the table must be filled before any lane reads it; r3d_e4m3_f16_init contains
|
||||
* the barrier.
|
||||
*
|
||||
* The table is EXACT: it is built by calling the codec once per entry, so it is the codec, moved
|
||||
* from the loop to the block's start. Nothing about the arithmetic changes, and a row's rel_l2
|
||||
* against its reference is unchanged by this header. The one thing to keep: the table must be filled
|
||||
* before any lane reads it, so every use is `..._init` then the barrier it contains, then reads.
|
||||
* int8 codes need no table: `v_cvt_f32_i8` is a hardware instruction (r3d_codecs.h: i8x2_to_f16x2).
|
||||
*
|
||||
* int8 codes do NOT want a table: `v_cvt_f32_i8` is a hardware instruction, so
|
||||
* r3d_codecs.h's i8x2_to_f16x2 is two converts and a pack. This header serves the fp8 codes.
|
||||
*
|
||||
* Header-only, like the rest of libr3d. Include it in a .hip after r3d_codecs.h.
|
||||
* Include in a .hip after r3d_codecs.h.
|
||||
*/
|
||||
#ifndef R3D_FP8_DEQUANT_H
|
||||
#define R3D_FP8_DEQUANT_H
|
||||
@@ -40,8 +30,8 @@
|
||||
#define R3D_E4M3_TBL 256 /* every E4M3 bit pattern, in order, as the f16 it means */
|
||||
#define R3D_E4M3_TBL_BYTES (R3D_E4M3_TBL * 2)
|
||||
|
||||
/* Fill the block's table: `tbl` is __shared__ uint16_t[R3D_E4M3_TBL]. The barrier is inside it,
|
||||
* because the only correct order is fill-then-read and the row should not have to remember it. */
|
||||
/* Fill the block's table: `tbl` is __shared__ uint16_t[R3D_E4M3_TBL]. Ends with the barrier that
|
||||
* orders the fill before any read. */
|
||||
__device__ __forceinline__ void r3d_e4m3_f16_init(uint16_t* tbl, int tid, int nthr)
|
||||
{
|
||||
for (int i = tid; i < R3D_E4M3_TBL; i += nthr)
|
||||
@@ -49,8 +39,8 @@ __device__ __forceinline__ void r3d_e4m3_f16_init(uint16_t* tbl, int tid, int nt
|
||||
__syncthreads();
|
||||
}
|
||||
|
||||
/* Two codes (the low 16 bits of a dword) as one f16 pair, the pair layout dot2_f16x2 reads: the
|
||||
* first code in the low half. Same answer as e4m3x2_to_f16x2, eight table reads per eight codes. */
|
||||
/* Two codes (the low 16 bits of a dword) as one f16 pair in dot2_f16x2 layout, the first code in
|
||||
* the low half. Same result as e4m3x2_to_f16x2. */
|
||||
__device__ __forceinline__ uint32_t r3d_e4m3x2_ld(const uint16_t* tbl, uint32_t pair)
|
||||
{
|
||||
const uint16_t lo = tbl[pair & 0xffu];
|
||||
@@ -58,9 +48,8 @@ __device__ __forceinline__ uint32_t r3d_e4m3x2_ld(const uint16_t* tbl, uint32_t
|
||||
return (uint32_t)lo | ((uint32_t)hi << 16);
|
||||
}
|
||||
|
||||
/* Eight codes (two dwords, straddling pairs as always) as four f16 pairs. The sibling of
|
||||
* codes8_to_f16x4 in r3d_vocab_bf16.hip; the int8 side of that helper stays with the codec, because
|
||||
* int8 has a hardware convert and fp8 does not. */
|
||||
/* Eight codes (two dwords) as four f16 pairs; the fp8 counterpart of codes8_to_f16x4 in
|
||||
* r3d_vocab_bf16.hip. */
|
||||
__device__ __forceinline__ void r3d_e4m3x8_ld(const uint16_t* tbl, uint2 c, uint32_t* w)
|
||||
{
|
||||
const uint32_t d0 = c.x, d1 = c.y;
|
||||
@@ -70,7 +59,7 @@ __device__ __forceinline__ void r3d_e4m3x8_ld(const uint16_t* tbl, uint2 c, uint
|
||||
w[3] = r3d_e4m3x2_ld(tbl, d1 >> 16);
|
||||
}
|
||||
|
||||
/* One code, for the rows that decode a scalar a step (an activation tile staged a byte a lane). */
|
||||
/* One code, for rows that decode a scalar per step (an activation tile staged a byte a lane). */
|
||||
__device__ __forceinline__ uint16_t r3d_e4m3_ld(const uint16_t* tbl, uint8_t code)
|
||||
{
|
||||
return tbl[code];
|
||||
|
||||
Reference in new issue
Block a user