[HIP] NVFP4 expert GEMV kernel (exact E2M1+E4M3 dequant, GPU-verified ~4e-7)
- kernels/hip: NVFP4 (SF4) codecs ported exactly from strata ink_hip_common —
sf4_e2m1_f32 (E2M1 nibble LUT {0,0.5,1,1.5,2,3,4,6,...}), e4m3fn_to_f32
(F8_E4M3FN: subnormal mant*2^-9, NaN->0, bias 7). Layout: packed_e2m1
[N,K/2] (low nib even col), scales_e4m3 [N,K/16], f32 outer_scale.
- k_nvfp4_gemv (M=1 decode): y[N] = dequant(W)[N,K] @ x[K], one block/row,
threads stride K/16 groups, f32 accumulate. Correctness-first; the Wave32
bandwidth-saturated path is the performance pass. This is the core of the
MoE expert compute (w13/w2); the full direct path (SiTU activation +
weighted reduce) builds on it.
- C ABI + safe wrapper nvfp4_gemv + CPU-oracle parity test (Rust e2m1/e4m3
matching the kernel).
Verified LIVE on gfx1150: nvfp4_gemv max_rel_err ~4e-7 across (8,64)/(16,256)/
(32,128). Eight compute kernels now verified. Default suite 97/97, lean 4
files green; GPU parity 8/8 (--features hip).
This commit is contained in:
1 parent
87a66aee37
commit
bd49da5636
3 files changed
+149
No files matched your search
@@ -64,6 +64,12 @@ int vetta_vec_add(const float* a, const float* b, float* y, size_t n,
|
||||
int vetta_cast_f32_bf16(const float* x, uint16_t* y, size_t n,
|
||||
vetta_stream_t stream);
|
||||
|
||||
// k_nvfp4_gemv (M=1): y[N] = dequant(W)[N,K] @ x[K], NVFP4 (E2M1 + E4M3/16 +
|
||||
// f32 outer_scale). packed [N,K/2], scales [N,K/16]. K % 16 == 0.
|
||||
int vetta_nvfp4_gemv(const uint8_t* packed, const uint8_t* scales,
|
||||
float outer_scale, const float* x, float* y,
|
||||
int N, int K, vetta_stream_t stream);
|
||||
|
||||
// Core <15 microkernel entry points (implemented progressively in M1 & M2):
|
||||
// 1. k_embed_bf16
|
||||
// 2. k_rms_norm
|
||||
|
||||
Reference in new issue
Block a user