brotensor/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
12 / 12
100.0%
Branches:
-
-%
Functions:
1 / 1
100.0%

src/kernels/mir_fa_cm.h
Line Branch Exec Source
1 #pragma once
2
3 // 16x16x16 cooperative-matrix FlashAttention forward MIR builder replacing:
4 // fa_cm.comp (FP16 / BF16, FA_MODE_{ROWS, VARLEN, PACKED, LEN}, optional mask,
5 // VEC=0/1, DIRECT fragment store & shared-scratch store, SPLIT-K partials).
6
7 #include "../jit/gpu_mir_emit_detail.h"
8
9 #include <cstdint>
10
11 namespace brotensor::kernels {
12
13 5 struct FaCmSpec {
14 5 Dtype dt = Dtype::FP16;
15 5 std::uint32_t hd = 64;
16 5 std::uint32_t bc = 16; // 16, 32, or 64
17 5 std::uint32_t nsg = 2; // 1, 2, or 4 (WG = nsg * 32, BR = nsg * 16)
18 5 std::uint32_t mode = 0; // FA_MODE_*
19 5 bool has_mask = false;
20 5 bool vec = true;
21 5 bool direct = false;
22 5 bool split = false;
23 5 bool has_softcap = false;
24 5 bool head_swizzle = false; // Launch with ctaid_x = head, ctaid_y = qb (breaks PoT L1/L2 set aliasing)
25 };
26
27 // Params (23):
28 // ptrs[0..7]: q, k, v, o, mask, aux, aux2, part
29 // ints[8..20]: lq, lk, ldq, ldk, ldo, group, window, causal, nseq, chunk, hq, qb0, q_offset
30 // flts[21..22]: scale (log2(e) / sqrt(HD)), softcap
31 brass::Function* build_fa_cm_mir(brass::Module& mod, const FaCmSpec& spec);
32
33 } // namespace brotensor::kernels
34