Archived
r4d mla_attn: E4M3 latent cache twins of the three rows
mla_attn takes an optional `kv_dtype`; at fp8_e4m3 the cache is E4M3 as kv_store_fp8 writes it at its default descale of 1. mla_attn_fp8kv, mla_attn_matrix_fp8kv and mla_attn_rows_fp8kv are the bf16 rows' kernels with the cache element as a template parameter: the key load decodes E4M3 to bf16 (v_cvt_pk_f32_fp8, then the high half), which is exact since every E4M3 value is a bf16, so the tiles and all arithmetic past the load are the bf16 instance's. The twins carry the bf16 rows' constraints plus kv_dtype fp8_e4m3 and rank above all three bf16 rows, in their order. At uint16_t the loads are the plain loads the bf16 kernels made; their launchers still refuse any cache that is not bf16. r4d_emu test_mla runs every kernel form (wave, matrix and its element load, rows forms 0-3) on E4M3 codes against its bf16 instance on the decoded cache: bit-identical on all 23 form/case pairs, and each launcher refuses the other cache dtype.
This commit is contained in:
1 parent
b632c72f5d
commit
17f0eae420
6 files changed
+249
-24
No files matched your search
@@ -743,7 +743,9 @@ extern "C" int r4d_shape_mla_attn(const RadParam* p, int n_p, int operand, RadOp
|
||||
const int64_t B = pi(p, n_p, "blocks"), bs = pi(p, n_p, "block_size"),
|
||||
pages = std::max((int64_t)2, B * M);
|
||||
const uint32_t dt = dt_act(p, n_p, "dtype");
|
||||
const RadOpdDesc l[] = { opd(dt, M, H, D), opd(dt, pages, 1, bs, D), opd_idx(M, B, pages),
|
||||
/* The cache is the query's dtype unless `kv_dtype` names another (fp8_e4m3). */
|
||||
const uint32_t kv = r4d_pgets(p, n_p, "kv_dtype") ? dt_act(p, n_p, "kv_dtype") : dt;
|
||||
const RadOpdDesc l[] = { opd(dt, M, H, D), opd(kv, pages, 1, bs, D), opd_idx(M, B, pages),
|
||||
opd_idx(M, 0, 0, B * bs), opd(dt, M, H, D) };
|
||||
R4D_PICK(l);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user