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
+77
-93
@@ -1,20 +1,18 @@
|
||||
/* r3d_codecs.h -- the numeric codecs, in the one spelling every libr3d unit and the host use.
|
||||
/* r3d_codecs.h -- the numeric codecs, shared by every libr3d unit and the host.
|
||||
*
|
||||
* These define what a result is, so they are stated once: rad_plugin.h's bf16 / f16 / fp8 / int8
|
||||
* rounders, restated so a device kernel can call them. rad_plugin.h's are `static inline` host
|
||||
* functions, which a `__global__` cannot reach, and libref -- the oracle every libr3d row is
|
||||
* checked against at kbench -- is built out of them. The mirror is therefore not a style choice,
|
||||
* and r3d_selftest.cpp compares the two over the whole fp8 code space, the whole bf16 code space
|
||||
* and 2^20 random f32s, so a drift of one ulp is a test failure here and not a tolerance argument
|
||||
* at kbench.
|
||||
* rad_plugin.h's bf16 / f16 / fp8 / int8 rounders, restated so a device kernel can call them
|
||||
* (rad_plugin.h's are `static inline` host functions a `__global__` cannot reach). libref, the
|
||||
* oracle every libr3d row is checked against at kbench, is built from those, so these must match
|
||||
* bit for bit. r3d_selftest.cpp compares the two over the whole fp8 and bf16 code spaces and 2^20
|
||||
* random f32s, so a one-ulp drift fails there.
|
||||
*
|
||||
* The contract, from ref_common.h and rad_plugin.h: f32 accumulation, IEEE round-to-nearest-ties-
|
||||
* to-even narrowing, no fused multiply-add and no reassociation, subnormals kept. Widening is
|
||||
* exact. `-ffp-contract=off` is a correctness flag, and rad_hipify puts it on every HIP source.
|
||||
* to-even narrowing, no fused multiply-add, no reassociation, subnormals kept. Widening is exact.
|
||||
* `-ffp-contract=off` is a correctness flag; rad_hipify puts it on every HIP source.
|
||||
*
|
||||
* R3D_HD is `__host__ __device__` in a HIP translation unit and nothing in a host one, which is how
|
||||
* the same header serves a kernel and r3d_selftest.cpp. The pieces that want a GPU instruction are
|
||||
* behind __HIP_DEVICE_COMPILE__ and have a plain-C++ twin a device build never takes.
|
||||
* R3D_HD is `__host__ __device__` in a HIP translation unit and nothing in a host one, so the same
|
||||
* header serves kernels and r3d_selftest.cpp. Code that uses a GPU instruction sits behind
|
||||
* __HIP_DEVICE_COMPILE__ with a plain-C++ host equivalent.
|
||||
*/
|
||||
#ifndef R3D_CODECS_H
|
||||
#define R3D_CODECS_H
|
||||
@@ -22,12 +20,10 @@
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
/* HIP first, and before R3D_HD: `__forceinline__` is a macro of hip_runtime.h's, so a unit that
|
||||
* includes this header without including the runtime first -- r3d_common.h includes the codecs
|
||||
* before it -- would read `__forceinline__` as a type name. The runtime declares no
|
||||
* `__host__ __device__` memcpy, which is why the bitcasts below go through bits_of and float_of.
|
||||
* A host translation unit -- the row table, the operand descriptions, r3d_selftest.cpp -- takes the
|
||||
* #else and pulls in no ROCm header at all. */
|
||||
/* The HIP runtime comes first, before R3D_HD: `__forceinline__` is a hip_runtime.h macro, and
|
||||
* r3d_common.h includes the codecs before the runtime, so without this it would parse as a type
|
||||
* name. Host translation units (the row table, the operand descriptions, r3d_selftest.cpp) pull in
|
||||
* no ROCm header. */
|
||||
#if defined(__HIPCC__)
|
||||
#include <hip/hip_runtime.h>
|
||||
#endif
|
||||
@@ -38,11 +34,10 @@
|
||||
#define R3D_HD inline
|
||||
#endif
|
||||
|
||||
/* The bit cast, in one place. Device code cannot call `memcpy` and the HIP headers do not declare a
|
||||
* `__host__ __device__` one on every release, so the device path is the compiler's bit cast; the
|
||||
* host path keeps memcpy, which the optimiser folds to a move, because GCC only grew
|
||||
* `__builtin_bit_cast` in C++20 mode and r3d_selftest.cpp is built at C++17 by the tree's host
|
||||
* compiler. */
|
||||
/* The bit cast. Device code cannot call `memcpy` (the HIP headers do not declare a
|
||||
* `__host__ __device__` one on every release), so the device path uses the compiler's bit cast.
|
||||
* The host path keeps memcpy, which folds to a move, because GCC has `__builtin_bit_cast` only in
|
||||
* C++20 mode and r3d_selftest.cpp builds at C++17. */
|
||||
R3D_HD uint32_t bits_of(float f) {
|
||||
#if defined(__HIPCC__)
|
||||
return __builtin_bit_cast(uint32_t, f);
|
||||
@@ -68,9 +63,9 @@ R3D_HD float float_of(uint32_t u) {
|
||||
*
|
||||
* bf16 is f32's top half: widening is a shift, narrowing one add and a shift.
|
||||
*
|
||||
* `(u >> 16) & 1` is the tie-break -- it adds one more than the halfway point when the surviving
|
||||
* bit is odd, so ties go to even. Overflow carries into the bf16 infinity; a NaN is forced quiet so
|
||||
* it cannot round into an infinity, which is what rad_f32_to_bf16 does and what libref does. */
|
||||
* `(u >> 16) & 1` is the tie-break: it adds one more than the halfway point when the surviving bit
|
||||
* is odd, so ties go to even. Overflow carries into the bf16 infinity. A NaN is forced quiet so it
|
||||
* cannot round into an infinity, as in rad_f32_to_bf16 and libref. */
|
||||
R3D_HD float bf16_to_f32(uint16_t h) {
|
||||
const uint32_t u = (uint32_t)h << 16;
|
||||
return float_of(u);
|
||||
@@ -82,15 +77,15 @@ R3D_HD uint16_t f32_to_bf16(float f) {
|
||||
return (uint16_t)((u + 0x7fffu + ((u >> 16) & 1u)) >> 16);
|
||||
}
|
||||
|
||||
/* The same rounding, stopped one shift short: the rounded value sitting in a word's high half, the
|
||||
* form a packed store wants. gfx11 in this ROCm has no v_cvt_pk_bf16_f32 (llvm-mc rejects it on
|
||||
* gfx1100, gfx1102 and gfx1151), so a bf16 pair is two of these and one byte permute. */
|
||||
/* The same rounding without the final shift: the rounded value in a word's high half, the form a
|
||||
* packed store wants. gfx11 in this ROCm has no v_cvt_pk_bf16_f32 (llvm-mc rejects it on gfx1100,
|
||||
* gfx1102 and gfx1151), so a bf16 pair is two of these and one byte permute. */
|
||||
R3D_HD uint32_t bf16_hi_rne(float f) {
|
||||
const uint32_t u = bits_of(f);
|
||||
return u + 0x7fffu + ((u >> 16) & 1u);
|
||||
}
|
||||
|
||||
/* Two such words as one bf16 pair, `lo`'s half in the low half of the result: one v_perm_b32. */
|
||||
/* Two such words as one bf16 pair, `lo`'s value in the low half: one v_perm_b32. */
|
||||
R3D_HD uint32_t bf16_pack_hi(uint32_t lo, uint32_t hi) {
|
||||
#if defined(__HIP_DEVICE_COMPILE__)
|
||||
return __builtin_amdgcn_perm(hi, lo, 0x07060302u);
|
||||
@@ -103,7 +98,7 @@ R3D_HD uint32_t bf16x2_rne(float lo, float hi) {
|
||||
return bf16_pack_hi(bf16_hi_rne(lo), bf16_hi_rne(hi));
|
||||
}
|
||||
|
||||
/* A bf16 pair word's two values as floats: a shift and a mask, no conversion. */
|
||||
/* A bf16 pair word's two values as floats: a shift or a mask, no conversion. */
|
||||
R3D_HD float bf16w_lo(uint32_t w) {
|
||||
const uint32_t u = w << 16;
|
||||
return float_of(u);
|
||||
@@ -115,8 +110,8 @@ R3D_HD float bf16w_hi(uint32_t w) {
|
||||
|
||||
/* ================================================================== f16
|
||||
*
|
||||
* RTNE both ways with subnormals kept, as rad_f16_to_f32 and rad_f32_to_f16 do -- not the hardware
|
||||
* convert, whose rounding mode a caller could have changed and which flushes subnormal halves. */
|
||||
* RTNE both ways with subnormals kept, as rad_f16_to_f32 and rad_f32_to_f16 do. The hardware
|
||||
* convert is not used: its rounding mode is caller-settable and it flushes subnormal halves. */
|
||||
R3D_HD float f16_to_f32(uint16_t h) {
|
||||
const uint32_t s = (uint32_t)(h >> 15) << 31;
|
||||
const uint32_t e = (uint32_t)(h >> 10) & 0x1fu;
|
||||
@@ -171,12 +166,12 @@ R3D_HD uint16_t f32_to_f16(float f) {
|
||||
|
||||
/* Two f32 as one dword of two f16, `lo` in the low half.
|
||||
*
|
||||
* v_cvt_pkrtz_f16_f32 rounds toward zero, which is not RTNE, so this is only ever called with
|
||||
* values f16 represents exactly: a bf16 widened (seven mantissa bits into ten) or an E4M3 code
|
||||
* (three into three). For those the two spellings give the same bits and the instruction is free. */
|
||||
* v_cvt_pkrtz_f16_f32 rounds toward zero, not RTNE, so this is only called with values f16
|
||||
* represents exactly: a widened bf16 (seven mantissa bits into ten) or an E4M3 code (three into
|
||||
* ten). For those both paths give the same bits. */
|
||||
R3D_HD uint32_t f16x2_pack(float lo, float hi) {
|
||||
#if defined(__HIP_DEVICE_COMPILE__)
|
||||
/* The builtin answers as a pair of __fp16; the bits are the dword the dot2 reads. */
|
||||
/* The builtin returns a pair of __fp16; its bits are the dword the dot2 reads. */
|
||||
return __builtin_bit_cast(uint32_t, __builtin_amdgcn_cvt_pkrtz(lo, hi));
|
||||
#else
|
||||
return (uint32_t)f32_to_f16(lo) | ((uint32_t)f32_to_f16(hi) << 16);
|
||||
@@ -185,22 +180,17 @@ R3D_HD uint32_t f16x2_pack(float lo, float hi) {
|
||||
|
||||
/* A dword of two bf16 as a dword of two f16.
|
||||
*
|
||||
* Exact over f16's normal range, and that is what makes the dot2 path sound: a bf16 has seven
|
||||
* mantissa bits and an f16 ten, so within [2^-14, 65504] a widening costs no rounding and a dot
|
||||
* product over widened bf16 accumulates the sums libref forms over its bf16 operands.
|
||||
* Exact over f16's normal range, which makes the dot2 path sound: bf16 has seven mantissa bits and
|
||||
* f16 ten, so within [2^-14, 65504] widening costs no rounding and a dot over widened bf16 forms
|
||||
* the sums libref forms over its bf16 operands.
|
||||
*
|
||||
* Outside it the widening is not exact, and the two edges behave differently. Above 65504 a
|
||||
* magnitude becomes an infinity (the packing instruction saturates, which is the kinder of the two
|
||||
* answers). Below 2^-14 the operand is an f16 subnormal, whose grid is a power of two coarser than
|
||||
* bf16's at the same magnitude, so a widening truncates toward zero -- and below 2^-24 it flushes.
|
||||
* The truncation is what the packing instruction does, `v_cvt_pkrtz_f16_f32` rounding toward zero.
|
||||
*
|
||||
* The low edge costs a served model nothing: an activation below 2^-14 times a weight of a
|
||||
* hundredth is 1e-18, against an accumulator of order one, so it is not a term the sum can see;
|
||||
* and a scale-reduced operand is scaled back up before it is used, which is why the quantised rows
|
||||
* put the scale on the block, not the element. What would be visible is a weight stream whose
|
||||
* magnitudes live below 2^-14, and no checkpoint's do. The rows whose band can reach 65504 say so
|
||||
* in their `shape` text. */
|
||||
* Outside that range: above 65504 a magnitude becomes an infinity. Below 2^-14 the operand is an
|
||||
* f16 subnormal on a coarser grid than bf16's, and v_cvt_pkrtz_f16_f32 truncates toward zero;
|
||||
* below 2^-24 it flushes. The low edge does not affect a served model: an activation below 2^-14
|
||||
* times a weight of 0.01 is 1e-18 against an accumulator of order one, and the quantised rows keep
|
||||
* the scale on the block, not the element, so scale-reduced operands are scaled back before use. No
|
||||
* checkpoint's weights live below 2^-14. Rows whose band can reach 65504 say so in their `shape`
|
||||
* text. */
|
||||
R3D_HD uint32_t bf16x2_to_f16x2(uint32_t w) {
|
||||
return f16x2_pack(bf16w_lo(w), bf16w_hi(w));
|
||||
}
|
||||
@@ -210,11 +200,10 @@ R3D_HD uint32_t bf16x2_to_f16x2(uint32_t w) {
|
||||
* 1-4-3, bias 7, no infinity, S1111111 the only NaN, 448 the largest finite. The KV-cache and
|
||||
* block-scaled weight format, so the attention oracle and every fp8 row depend on its rounding.
|
||||
*
|
||||
* RDNA3 has no instruction for it: v_cvt_pk_fp8_f32 and v_cvt_pk_f32_fp8 need the fp8 feature,
|
||||
* which RDNA3 does not have. The builtins are *declared* for gfx11 -- so `__has_builtin` is true
|
||||
* here, which is the trap a `__has_builtin` guard falls into, and libr4d's guards are exactly that
|
||||
* -- and rejected at instruction selection. Both directions are bit maths, about eleven VALU an
|
||||
* encode and six a decode. */
|
||||
* RDNA3 has no fp8 instructions: v_cvt_pk_fp8_f32 and v_cvt_pk_f32_fp8 need the fp8 feature. The
|
||||
* builtins are declared for gfx11, so a `__has_builtin` guard (as in libr4d) passes, but they are
|
||||
* rejected at instruction selection. Both directions are bit maths, about eleven VALU per encode
|
||||
* and six per decode. */
|
||||
R3D_HD float e4m3_to_f32(uint8_t b) {
|
||||
const uint32_t s = (uint32_t)(b >> 7) << 31;
|
||||
const uint32_t e = (uint32_t)(b >> 3) & 0xfu;
|
||||
@@ -237,9 +226,9 @@ R3D_HD float e4m3_to_f32(uint8_t b) {
|
||||
return float_of(u);
|
||||
}
|
||||
|
||||
/* Saturates at 448 rather than overflowing: a NaN from one large activation spreads through the
|
||||
* whole row, and every fp8 cast in this project clamps for that reason. The clamp is inside the
|
||||
* codec here because there is no instruction to clamp in front of. */
|
||||
/* Saturates at 448 rather than overflowing, because a NaN from one large activation spreads
|
||||
* through the whole row; every fp8 cast in this project clamps. The clamp is inside the codec
|
||||
* because there is no hardware convert to clamp in front of. */
|
||||
R3D_HD uint8_t f32_to_e4m3(float f) {
|
||||
const uint32_t u = bits_of(f);
|
||||
const uint8_t s = (uint8_t)((u >> 24) & 0x80u);
|
||||
@@ -270,31 +259,29 @@ R3D_HD uint8_t f32_to_e4m3(float f) {
|
||||
return (uint8_t)(s | ((uint32_t)ee << 3) | q);
|
||||
}
|
||||
|
||||
/* Two codes in one dword, the low element in the low byte: the store a wave's lane does. */
|
||||
/* Two codes in one dword, the low element in the low byte: one lane's store. */
|
||||
R3D_HD uint32_t e4m3x2_pack(float lo, float hi) {
|
||||
return (uint32_t)f32_to_e4m3(lo) | ((uint32_t)f32_to_e4m3(hi) << 8);
|
||||
}
|
||||
|
||||
/* A dword of two E4M3 codes as a dword of two f16.
|
||||
*
|
||||
* Exact -- e4m3 has four exponent and three mantissa bits, f16 five and ten -- and this is the fp8
|
||||
* matrix path: a code becomes the f16 the checkpoint means, dot2 multiplies it, and the block
|
||||
* scale is applied once per block. RDNA3 has no fp8 hardware, so the decode is VALU, and it is
|
||||
* paid where the weight bytes are being read anyway. */
|
||||
* Exact (e4m3 has four exponent and three mantissa bits, f16 five and ten). This is the fp8 matrix
|
||||
* path: a code becomes its f16 value, dot2 multiplies it, and the block scale is applied once per
|
||||
* block. Without fp8 hardware the decode is VALU work, done where the weight bytes are read. */
|
||||
R3D_HD uint32_t e4m3x2_to_f16x2(uint32_t w) {
|
||||
return f16x2_pack(e4m3_to_f32((uint8_t)(w & 0xffu)), e4m3_to_f32((uint8_t)(w >> 8)));
|
||||
}
|
||||
|
||||
/* ================================================================== int8
|
||||
*
|
||||
* The symmetric int8 twin: amax/127, RTNE, saturating. f16 holds every int8 exactly, so widening
|
||||
* into a dot product is exact and the scale is the only float in the path. */
|
||||
* Symmetric int8: amax/127, RTNE, saturating. f16 holds every int8 exactly, so widening into a
|
||||
* dot product is exact and the scale is the only float in the path. */
|
||||
R3D_HD int8_t f32_to_i8_rtne(float f) {
|
||||
if (!(f == f)) return 0;
|
||||
/* Round to nearest, ties to even, in integer arithmetic. A tie at the top of the range would
|
||||
* round to a code that does not exist (+128), so the clamp is applied after the rounding, not
|
||||
* as an early return: 127.5 goes to the even 128 and then clamps to 127, which is what
|
||||
* rad_round_even_sat gives. */
|
||||
/* Round to nearest, ties to even, in integer arithmetic, then clamp. The clamp follows the
|
||||
* rounding, not an early return: 127.5 rounds to the even 128 and clamps to 127, as
|
||||
* rad_round_even_sat does. */
|
||||
const float fl = __builtin_floorf(f);
|
||||
const float frac = f - fl;
|
||||
int32_t q = (int32_t)fl;
|
||||
@@ -315,28 +302,25 @@ R3D_HD uint32_t i8x2_to_f16x2(uint32_t w) {
|
||||
|
||||
/* ================================================================== the dot product
|
||||
*
|
||||
* Two f16 products into an f32 accumulator, one instruction: v_dot2acc_f32_f16, which
|
||||
* __builtin_amdgcn_fdot2 lowers to on every gfx11 target (checked by reading the emitted asm on
|
||||
* gfx1100, gfx1102 and gfx1151). RDNA3 pairs it as v_dual_dot2acc_f32_f16 where the scheduler can,
|
||||
* which is how libr3d's inner loops reach the matrix unit's absence without noticing.
|
||||
* Two f16 products into an f32 accumulator in one instruction: v_dot2acc_f32_f16, which
|
||||
* __builtin_amdgcn_fdot2 lowers to on every gfx11 target (verified in the emitted asm on gfx1100,
|
||||
* gfx1102 and gfx1151). RDNA3 pairs it as v_dual_dot2acc_f32_f16 where the scheduler can.
|
||||
*
|
||||
* The selector is FALSE, always. RDNA3 has no bf16 dot2, and this compiler accepts the bf16
|
||||
* selector and emits the f16 instruction anyway: a bf16 pair passed with sel=true is read as two
|
||||
* f16s and the products are nonsense, silently, on every gfx11 target. bf16 operands are widened
|
||||
* with bf16x2_to_f16x2, which is exact.
|
||||
* Invariant: the last argument is always false. RDNA3 has no bf16 dot2, yet this compiler accepts
|
||||
* the bf16 selector and emits the f16 instruction, so a bf16 pair passed with sel=true is silently
|
||||
* read as two f16s. bf16 operands are widened exactly with bf16x2_to_f16x2.
|
||||
*
|
||||
* The two products go into `acc` in the order written, and a kernel that walks k ascending
|
||||
* reproduces libref's summand-for-summand: the reference loop is `s += a[k]*b[k]` with
|
||||
* -ffp-contract=off. The match is not bit-exact and cannot be: `v_dot2acc_f32_f16` folds the two
|
||||
* products and the accumulator with guard bits and rounds once, where the reference rounds each
|
||||
* product and each sum. The difference is under an f32 ulp a pair, a random walk of about
|
||||
* sqrt(K/2) ulps over a K-long dot, which is a thousandth of the bf16 the store narrows to -- so it
|
||||
* sits inside what `rad-kbench` measures, exactly as libr4d's WMMA accumulation does. What is
|
||||
* required, and what every loop here keeps, is that the *order* of the summands be the reference's:
|
||||
* k ascending, one accumulator per output element, no reassociation across lanes.
|
||||
* The two products go into `acc` in the order written, so a kernel walking k ascending follows
|
||||
* libref's summand order (`s += a[k]*b[k]` with -ffp-contract=off). The result is not bit-exact:
|
||||
* v_dot2acc_f32_f16 folds both products and the accumulator with guard bits and rounds once, where
|
||||
* the reference rounds each product and sum. The difference is under an f32 ulp per pair, a random
|
||||
* walk of about sqrt(K/2) ulps over a K-long dot: about a thousandth of the bf16 the store narrows
|
||||
* to, and inside what `rad-kbench` measures (as with libr4d's WMMA accumulation). What every loop
|
||||
* here must keep is the reference's summand order: k ascending, one accumulator per output element,
|
||||
* no reassociation across lanes.
|
||||
*
|
||||
* The host path below is the same arithmetic with each product rounded first, which is what a test
|
||||
* needs it to be. It is not the hardware's rounding. */
|
||||
* The host path is the same arithmetic with each product rounded first, for tests; it is not the
|
||||
* hardware's rounding. */
|
||||
R3D_HD float dot2_f16x2(uint32_t a, uint32_t b, float acc) {
|
||||
#if defined(__HIP_DEVICE_COMPILE__)
|
||||
typedef __fp16 v2h __attribute__((ext_vector_type(2)));
|
||||
@@ -350,8 +334,8 @@ R3D_HD float dot2_f16x2(uint32_t a, uint32_t b, float acc) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Four f16 products into one accumulator: the step every libr3d matmul runs. The two dot2s are a
|
||||
* dependency chain of two; a kernel keeps four of these chains in flight. */
|
||||
/* Four f16 products into one accumulator, the step every libr3d matmul runs. The two dot2s form a
|
||||
* dependency chain of two; a kernel keeps four such chains in flight. */
|
||||
R3D_HD float dot4_f16x4(uint32_t a0, uint32_t a1, uint32_t b0, uint32_t b1, float acc) {
|
||||
return dot2_f16x2(a1, b1, dot2_f16x2(a0, b0, acc));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user