diff --git a/docs/ARCHITECTURES.md b/docs/ARCHITECTURES.md index e658f8a5..d433385e 100644 --- a/docs/ARCHITECTURES.md +++ b/docs/ARCHITECTURES.md @@ -1911,8 +1911,9 @@ fails. `partial_rotary_factor` is read per attention class, so either class may Kernels: libref and libavx serve every op, and so does libr4d: attention at (128, 4 queries a kv head) takes `attn_decode_h128_gqa4` up to 16 query rows and `attn_window_h128_gqa4` past -that, for the full layers (window 0) as for the sliding ones. libhalo has no `rope_rows` or -`rmsnorm_rows`, so on gfx1151 those run on the host. +that, for the full layers (window 0) as for the sliding ones. libhalo carries the same pair of +attention rows, and `rope_rows` and `rmsnorm_rows` under their row-form names (launched as +`rope` and `rmsnorm`). Checked against the reference's float32 forward on a tiny random LFM3 (conv, full, conv, sliding; window 8) at every position of the golden prompt (`tests/lfm3_golden.h`, made by diff --git a/libhalo/halo_attn_paged_window.hip b/libhalo/halo_attn_paged_window.hip index 65bf6d64..e75c8ab7 100644 --- a/libhalo/halo_attn_paged_window.hip +++ b/libhalo/halo_attn_paged_window.hip @@ -5,7 +5,9 @@ // // head_dim 128 is Unlimited-OCR's decoder (10 query heads over 10 KV heads): the plain MHA case, // served here so its q slice of the fused q|k|v plane is read in place instead of being lifted into -// a dense buffer. Gemma 4's text layers: sliding layers are 16 query heads over 8 KV heads at +// a dense buffer. head_dim 128 at gqa 4 is LFM3's attention (16 query heads over 4 KV heads): full +// layers, and sliding layers with a 256-token window; its decode steps stay on +// halo_attn_paged_h128_gqa4.hip and every longer q_len lands here. Gemma 4's text layers: sliding layers are 16 query heads over 8 KV heads at // head_dim 256 with a 1024-token window, full layers 16 over 2 at head_dim 512. Where this overlaps // libhalo's other h256 legs, the row table decides (halo_rows.cpp). // @@ -1191,7 +1193,7 @@ extern "C" { int halo_rad_attn_window_h##HD##_gqa##G##_fp8(const RadArgs* a, RadStream s) { \ return halo_win::launch_attn(a, s); \ } -HALO_WIN_DEF(128, 1) +HALO_WIN_DEF(128, 1) HALO_WIN_DEF(128, 4) HALO_WIN_DEF(256, 1) HALO_WIN_DEF(256, 2) HALO_WIN_DEF(256, 4) HALO_WIN_DEF(256, 8) HALO_WIN_DEF(512, 1) HALO_WIN_DEF(512, 2) HALO_WIN_DEF(512, 4) HALO_WIN_DEF(512, 8) #undef HALO_WIN_DEF diff --git a/libhalo/halo_plugin.h b/libhalo/halo_plugin.h index 89da9ae2..f86bc359 100644 --- a/libhalo/halo_plugin.h +++ b/libhalo/halo_plugin.h @@ -171,6 +171,8 @@ int64_t halo_rad_attn_qrow_h128_gqa8_scratch(const RadArgs*); * row pitch, so they serve both attn_paged and attn_paged_qrow. */ int halo_rad_attn_window_h128_gqa1_bf16(const RadArgs*, RadStream); int halo_rad_attn_window_h128_gqa1_fp8 (const RadArgs*, RadStream); +int halo_rad_attn_window_h128_gqa4_bf16(const RadArgs*, RadStream); +int halo_rad_attn_window_h128_gqa4_fp8 (const RadArgs*, RadStream); int halo_rad_attn_window_h256_gqa1_bf16(const RadArgs*, RadStream); int halo_rad_attn_window_h256_gqa1_fp8 (const RadArgs*, RadStream); int halo_rad_attn_window_h256_gqa2_bf16(const RadArgs*, RadStream); diff --git a/libhalo/halo_rows.cpp b/libhalo/halo_rows.cpp index 89f78fec..9efe8e77 100644 --- a/libhalo/halo_rows.cpp +++ b/libhalo/halo_rows.cpp @@ -2887,6 +2887,9 @@ static const RadOpSchema kSchemas[] = { SCHEMA("rmsnorm", pRmsNorm, oRmsNorm, "y = x * rsqrt(mean(x^2) + eps) * (w + wadd). `wadd` is GemmaRMSNorm's `1 +`, added in " "f32 after the load because forming it in bf16 first costs 0.3% per channel."), + SCHEMA("rmsnorm_rows", pRmsNorm, oRmsNorm, + "the same norm under its row-form name: a plugin written for libr4d's short-row launch " + "resolves here, and libhalo launches it as `rmsnorm` (byte-identical)."), SCHEMA("rmsnorm_p", pLayernorm, oUnary, "y = x * rsqrt(mean(x^2) + eps); an rmsnorm with NO gain tensor at all. Gemma's " "attention normalises the value with a bare RMS (a weightless ggml_rms_norm) and the " @@ -3009,6 +3012,9 @@ static const RadOpSchema kSchemas[] = { "that follow are untouched. The multi-component modes (`mrope`, `imrope`, `axial`) " "take [C, M] component-major positions and `sections`; with [M] positions every " "component is that one, so mrope and imrope over a text batch are neox exactly."), + SCHEMA("rope_rows", pRope, oRope, + "the same rotation under its row-form name: a plugin written for libr4d's one-angle-a-" + "(token, pair) launch resolves here, and libhalo launches it as `rope` (byte-identical)."), SCHEMA("layernorm", pLayernorm, oLayernorm, "y = (x - mean) * rsqrt(var + eps) * w + b, biased variance, two passes. `b` optional."), SCHEMA("grid_embed", pGridEmbed, oGridEmbed, @@ -3997,7 +4003,9 @@ static const RadConstraint cAttnPrefillH64G4Bf16[] = { /* The windowed kernels (halo_attn_paged_window.hip): head_dim 128, 256 and 512, 1/2/4/8 queries per * KV head, any window, causal or not. Gemma 4's sliding layers are h256/gqa2 with a 1024-token * window, its full layers h512 at gqa 8 (TP1/TP2), 4 (TP4) or 2 (TP8); h128/gqa1 is Unlimited-OCR's - * MHA decoder. One kernel serves every q_len (splitting the key range when there are too few tiles + * MHA decoder; h128/gqa4 is LFM3 (full layers, and sliding ones with a 256-token window), whose + * decode band (q_len <= 16) stays on the h128/gqa4 decode leg, which ranks above these rows. One + * kernel serves every q_len (splitting the key range when there are too few tiles * to fill the card), so `q_len` cuts no band. `causal` and `window` are runtime fields; block_size * is derived: 16. * @@ -4010,6 +4018,7 @@ static const RadConstraint cAttnPrefillH64G4Bf16[] = { C_GE("window", WMIN), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", KV), \ }; HALO_WIN_C(cWinH128G1Bf16, 128, 1, "bf16", 0) HALO_WIN_C(cWinH128G1Fp8, 128, 1, "fp8_e4m3", 0) +HALO_WIN_C(cWinH128G4Bf16, 128, 4, "bf16", 0) HALO_WIN_C(cWinH128G4Fp8, 128, 4, "fp8_e4m3", 0) HALO_WIN_C(cWinH256G1Bf16, 256, 1, "bf16", 0) HALO_WIN_C(cWinH256G1Fp8, 256, 1, "fp8_e4m3", 0) HALO_WIN_C(cWinH256G2Bf16, 256, 2, "bf16", 0) HALO_WIN_C(cWinH256G2Fp8, 256, 2, "fp8_e4m3", 0) HALO_WIN_C(cWinH256G4Bf16, 256, 4, "bf16", 1) HALO_WIN_C(cWinH256G4Fp8, 256, 4, "fp8_e4m3", 1) @@ -5768,6 +5777,18 @@ static const RadKernelInfo kKernels[] = { nullptr, nullptr, halo_rad_rmsnorm, nullptr, nullptr, nullptr, halo_shape_rmsnorm }, +/* rmsnorm under its row-form name (libr4d's rmsnorm_rows): the same launch, so a per-head q/k + * norm declared for the rows form has a device row on this part too. */ +{ "rmsnorm_rows_bf16", "rmsnorm_rows", "norm", + "root-mean-square norm with a gain, two passes over the row, under its row-form name", + "any n; the sum of squares accumulates in f32 and only the store narrows; byte-identical to " + "rmsnorm", + "bf16 y, x bf16 or (with a gain) f32, bf16 or f32 gain, fp32 reduction", + RAD_DOMAIN_DEVICE, HALO_PRIO_ONLY, + ROW(cBf16Row), NOTUNE, + nullptr, nullptr, halo_rad_rmsnorm, nullptr, nullptr, nullptr, + halo_shape_rmsnorm }, + { "rmsnorm_p_bf16", "rmsnorm_p", "norm", "weightless root-mean-square norm (no gain), two passes over the row", "any n; the sum of squares accumulates in f32 and only the store narrows", @@ -6026,6 +6047,18 @@ static const RadKernelInfo kKernels[] = { nullptr, nullptr, halo_rad_rope, nullptr, nullptr, nullptr, halo_shape_rope }, +/* rope under its row-form name (libr4d's rope_rows): the same launch. */ +{ "rope_rows_bf16", "rope_rows", "attn", + "rotary embedding in place, one thread a rotated pair, under its row-form name", + "any head_dim; rotary_dim even and no wider than head_dim -- the frequency exponent divides by " + "rotary_dim, so a partial rotary is a complete rotation of its own width; neox, mrope (which is " + "neox over one position component) and gptj pairings", + "bf16 qkv, i32 positions, fp32 angles through the accurate sincosf", + RAD_DOMAIN_DEVICE, HALO_PRIO_ONLY, + ROW(cRopeRow), NOTUNE, + nullptr, nullptr, halo_rad_rope, nullptr, nullptr, nullptr, + halo_shape_rope }, + { "kv_store_bf16", "kv_store", "attn", "scatter k and v into the paged cache, one workgroup a token", "cache exactly [n_blocks, kv_heads, block_size, 2*head_dim]; a negative or out-of-range slot " @@ -6775,7 +6808,7 @@ static const RadKernelInfo kKernels[] = { #define HALO_WIN_PAIR(HD, GQ) \ HALO_WIN_ROW(HD, GQ, bf16kv, bf16, cWinH##HD##G##GQ##Bf16, "bf16") \ HALO_WIN_ROW(HD, GQ, fp8kv, fp8, cWinH##HD##G##GQ##Fp8, "fp8-e4m3 (per-(seq,head) descales)") -HALO_WIN_PAIR(128, 1) +HALO_WIN_PAIR(128, 1) HALO_WIN_PAIR(128, 4) HALO_WIN_PAIR(256, 1) HALO_WIN_PAIR(256, 2) HALO_WIN_PAIR(256, 4) HALO_WIN_PAIR(256, 8) HALO_WIN_PAIR(512, 1) HALO_WIN_PAIR(512, 2) HALO_WIN_PAIR(512, 4) HALO_WIN_PAIR(512, 8) #undef HALO_WIN_PAIR diff --git a/libhalo/halo_selftest.cpp b/libhalo/halo_selftest.cpp index a1b4c6a5..aebeff2f 100644 --- a/libhalo/halo_selftest.cpp +++ b/libhalo/halo_selftest.cpp @@ -30914,6 +30914,17 @@ static void device_phase(const Plugin& pl) { attn_numeric_case(pl, "attn_window_h512_gqa8_bf16kv", 512, 8, 32, "bf16", 0); attn_numeric_case(pl, "attn_window_h512_gqa8_fp8kv", 512, 8, 1, "fp8_e4m3", 0); attn_numeric_case(pl, "attn_window_h512_gqa8_bf16kv", 512, 8, 1, "bf16", 0); + /* LFM3: 16 query heads over 4 kv heads at head_dim 128, full and with its 256-token window; the + * rows take what the decode leg's band (q_len <= 16) leaves. Launches, then numeric checks, the + * last two with a context past the window. */ + attn_case(pl, "attn_window_h128_gqa4_fp8kv", 128, 4, 32, "fp8_e4m3", 1); + attn_case(pl, "attn_window_h128_gqa4_bf16kv", 128, 4, 32, "bf16", 1); + attn_case(pl, "attn_window_h128_gqa4_bf16kv", 128, 4, 32, "bf16", 1, 256); + attn_numeric_case(pl, "attn_window_h128_gqa4_fp8kv", 128, 4, 32, "fp8_e4m3", 0); + attn_numeric_case(pl, "attn_window_h128_gqa4_bf16kv", 128, 4, 32, "bf16", 0); + attn_numeric_case(pl, "attn_window_h128_gqa4_bf16kv", 128, 4, 17, "bf16", 0, 300); + attn_numeric_case(pl, "attn_window_h128_gqa4_bf16kv", 128, 4, 64, "bf16", 256, 700); + attn_numeric_case(pl, "attn_window_h128_gqa4_fp8kv", 128, 4, 64, "fp8_e4m3", 256, 700); /* The h256/gqa2 prefill numeric check with ctx 2048 > window 1024, so the window applies: for * query row 0, pos = 2048-64 = 1984 and the visible keys are [961..1984], so wlo0 = 961 and * tstart = 961/48 = 20. This exercises the window mask and the below-window tile skip (tiles diff --git a/libhalo/halo_stubs.cpp b/libhalo/halo_stubs.cpp index bfad5da9..eeba199c 100644 --- a/libhalo/halo_stubs.cpp +++ b/libhalo/halo_stubs.cpp @@ -85,6 +85,8 @@ __attribute__((weak)) int halo_rad_attn_prefill_h64_gqa4_fp8(const RadArgs*, Rad __attribute__((weak)) int64_t halo_rad_attn_prefill_h64_gqa4_scratch(const RadArgs*) { return -1; } __attribute__((weak)) int halo_rad_attn_window_h128_gqa1_bf16(const RadArgs*, RadStream) { return RAD_E_UNSUPPORTED; } __attribute__((weak)) int halo_rad_attn_window_h128_gqa1_fp8(const RadArgs*, RadStream) { return RAD_E_UNSUPPORTED; } +__attribute__((weak)) int halo_rad_attn_window_h128_gqa4_bf16(const RadArgs*, RadStream) { return RAD_E_UNSUPPORTED; } +__attribute__((weak)) int halo_rad_attn_window_h128_gqa4_fp8(const RadArgs*, RadStream) { return RAD_E_UNSUPPORTED; } __attribute__((weak)) int halo_rad_attn_window_h256_gqa1_bf16(const RadArgs*, RadStream) { return RAD_E_UNSUPPORTED; } __attribute__((weak)) int halo_rad_attn_window_h256_gqa1_fp8(const RadArgs*, RadStream) { return RAD_E_UNSUPPORTED; } __attribute__((weak)) int halo_rad_attn_window_h256_gqa2_bf16(const RadArgs*, RadStream) { return RAD_E_UNSUPPORTED; } @@ -110,4 +112,4 @@ __attribute__((weak)) int halo_rad_attn_window_h512_gqa8_fp8(const RadArgs*, Rad * list is the only place that knows which hooks are still stubs, and it is generated from the same * scan as the bodies above, so a unit that lands a real hook drops its name here on the next run. * halo_selftest reads it through libhalo/halo_selftest.cpp's `hook()`. */ -extern "C" const char* halo_stub_hooks(void) { return "halo_gemm_fp8a8_pin_nt halo_mla_matrix_stats halo_qsa_select_pin_form halo_rad_attn_decode_gq_h256_gqa12_bf16 halo_rad_attn_decode_gq_h256_gqa12_fp8 halo_rad_attn_decode_gq_h256_gqa12_fp8v4 halo_rad_attn_decode_gq_h256_gqa12_k6v4 halo_rad_attn_decode_gq_h256_gqa6_bf16 halo_rad_attn_decode_gq_h256_gqa6_fp8 halo_rad_attn_decode_gq_h256_gqa6_fp8v4 halo_rad_attn_decode_gq_h256_gqa6_k6v4 halo_rad_attn_decode_h128_gqa1_bf16 halo_rad_attn_decode_h128_gqa1_fp8 halo_rad_attn_decode_h128_gqa1_scratch halo_rad_attn_decode_h128_gqa2_bf16 halo_rad_attn_decode_h128_gqa2_fp8 halo_rad_attn_decode_h128_gqa2_scratch halo_rad_attn_decode_h128_gqa8_bf16 halo_rad_attn_decode_h128_gqa8_fp8 halo_rad_attn_decode_h128_gqa8_scratch halo_rad_attn_decode_h256_gqa12_bf16 halo_rad_attn_decode_h256_gqa12_fp8 halo_rad_attn_decode_h256_gqa12_fp8v4 halo_rad_attn_decode_h256_gqa12_fp8v4_scratch halo_rad_attn_decode_h256_gqa12_k6v4 halo_rad_attn_decode_h256_gqa12_k6v4_scratch halo_rad_attn_decode_h256_gqa12_scratch halo_rad_attn_decode_h256_gqa4_bf16 halo_rad_attn_decode_h256_gqa4_fp8 halo_rad_attn_decode_h256_gqa4_scratch halo_rad_attn_decode_h256_gqa6_bf16 halo_rad_attn_decode_h256_gqa6_fp8 halo_rad_attn_decode_h256_gqa6_fp8v4 halo_rad_attn_decode_h256_gqa6_fp8v4_scratch halo_rad_attn_decode_h256_gqa6_k6v4 halo_rad_attn_decode_h256_gqa6_k6v4_scratch halo_rad_attn_decode_h256_gqa6_scratch halo_rad_attn_decode_h256_gqa8_bf16 halo_rad_attn_decode_h256_gqa8_fp8 halo_rad_attn_decode_h256_gqa8_scratch halo_rad_attn_prefill_h128_gqa1_bf16 halo_rad_attn_prefill_h128_gqa1_fp8 halo_rad_attn_prefill_h128_gqa1_scratch halo_rad_attn_prefill_h128_gqa2_bf16 halo_rad_attn_prefill_h128_gqa2_fp8 halo_rad_attn_prefill_h128_gqa2_scratch halo_rad_attn_prefill_h128_gqa8_bf16 halo_rad_attn_prefill_h128_gqa8_fp8 halo_rad_attn_prefill_h128_gqa8_scratch halo_rad_attn_prefill_h256_gqa12_bf16 halo_rad_attn_prefill_h256_gqa12_fp8 halo_rad_attn_prefill_h256_gqa12_fp8v4 halo_rad_attn_prefill_h256_gqa12_fp8v4_scratch halo_rad_attn_prefill_h256_gqa12_k6v4 halo_rad_attn_prefill_h256_gqa12_k6v4_scratch halo_rad_attn_prefill_h256_gqa12_scratch halo_rad_attn_prefill_h256_gqa4_bf16 halo_rad_attn_prefill_h256_gqa4_fp8 halo_rad_attn_prefill_h256_gqa4_scratch halo_rad_attn_prefill_h256_gqa6_bf16 halo_rad_attn_prefill_h256_gqa6_fp8 halo_rad_attn_prefill_h256_gqa6_fp8v4 halo_rad_attn_prefill_h256_gqa6_fp8v4_scratch halo_rad_attn_prefill_h256_gqa6_k6v4 halo_rad_attn_prefill_h256_gqa6_k6v4_scratch halo_rad_attn_prefill_h256_gqa6_scratch halo_rad_attn_prefill_h256_gqa8_bf16 halo_rad_attn_prefill_h256_gqa8_fp8 halo_rad_attn_prefill_h256_gqa8_scratch halo_rad_attn_prefill_h64_gqa4_bf16 halo_rad_attn_prefill_h64_gqa4_fp8 halo_rad_attn_prefill_h64_gqa4_scratch halo_rad_attn_window_h128_gqa1_bf16 halo_rad_attn_window_h128_gqa1_fp8 halo_rad_attn_window_h256_gqa1_bf16 halo_rad_attn_window_h256_gqa1_fp8 halo_rad_attn_window_h256_gqa2_bf16 halo_rad_attn_window_h256_gqa2_fp8 halo_rad_attn_window_h256_gqa4_bf16 halo_rad_attn_window_h256_gqa4_fp8 halo_rad_attn_window_h256_gqa8_bf16 halo_rad_attn_window_h256_gqa8_fp8 halo_rad_attn_window_h512_gqa1_bf16 halo_rad_attn_window_h512_gqa1_fp8 halo_rad_attn_window_h512_gqa2_bf16 halo_rad_attn_window_h512_gqa2_fp8 halo_rad_attn_window_h512_gqa4_bf16 halo_rad_attn_window_h512_gqa4_fp8 halo_rad_attn_window_h512_gqa8_bf16 halo_rad_attn_window_h512_gqa8_fp8"; } +extern "C" const char* halo_stub_hooks(void) { return "halo_gemm_fp8a8_pin_nt halo_mla_matrix_stats halo_qsa_select_pin_form halo_rad_attn_decode_gq_h256_gqa12_bf16 halo_rad_attn_decode_gq_h256_gqa12_fp8 halo_rad_attn_decode_gq_h256_gqa12_fp8v4 halo_rad_attn_decode_gq_h256_gqa12_k6v4 halo_rad_attn_decode_gq_h256_gqa6_bf16 halo_rad_attn_decode_gq_h256_gqa6_fp8 halo_rad_attn_decode_gq_h256_gqa6_fp8v4 halo_rad_attn_decode_gq_h256_gqa6_k6v4 halo_rad_attn_decode_h128_gqa1_bf16 halo_rad_attn_decode_h128_gqa1_fp8 halo_rad_attn_decode_h128_gqa1_scratch halo_rad_attn_decode_h128_gqa2_bf16 halo_rad_attn_decode_h128_gqa2_fp8 halo_rad_attn_decode_h128_gqa2_scratch halo_rad_attn_decode_h128_gqa8_bf16 halo_rad_attn_decode_h128_gqa8_fp8 halo_rad_attn_decode_h128_gqa8_scratch halo_rad_attn_decode_h256_gqa12_bf16 halo_rad_attn_decode_h256_gqa12_fp8 halo_rad_attn_decode_h256_gqa12_fp8v4 halo_rad_attn_decode_h256_gqa12_fp8v4_scratch halo_rad_attn_decode_h256_gqa12_k6v4 halo_rad_attn_decode_h256_gqa12_k6v4_scratch halo_rad_attn_decode_h256_gqa12_scratch halo_rad_attn_decode_h256_gqa4_bf16 halo_rad_attn_decode_h256_gqa4_fp8 halo_rad_attn_decode_h256_gqa4_scratch halo_rad_attn_decode_h256_gqa6_bf16 halo_rad_attn_decode_h256_gqa6_fp8 halo_rad_attn_decode_h256_gqa6_fp8v4 halo_rad_attn_decode_h256_gqa6_fp8v4_scratch halo_rad_attn_decode_h256_gqa6_k6v4 halo_rad_attn_decode_h256_gqa6_k6v4_scratch halo_rad_attn_decode_h256_gqa6_scratch halo_rad_attn_decode_h256_gqa8_bf16 halo_rad_attn_decode_h256_gqa8_fp8 halo_rad_attn_decode_h256_gqa8_scratch halo_rad_attn_prefill_h128_gqa1_bf16 halo_rad_attn_prefill_h128_gqa1_fp8 halo_rad_attn_prefill_h128_gqa1_scratch halo_rad_attn_prefill_h128_gqa2_bf16 halo_rad_attn_prefill_h128_gqa2_fp8 halo_rad_attn_prefill_h128_gqa2_scratch halo_rad_attn_prefill_h128_gqa8_bf16 halo_rad_attn_prefill_h128_gqa8_fp8 halo_rad_attn_prefill_h128_gqa8_scratch halo_rad_attn_prefill_h256_gqa12_bf16 halo_rad_attn_prefill_h256_gqa12_fp8 halo_rad_attn_prefill_h256_gqa12_fp8v4 halo_rad_attn_prefill_h256_gqa12_fp8v4_scratch halo_rad_attn_prefill_h256_gqa12_k6v4 halo_rad_attn_prefill_h256_gqa12_k6v4_scratch halo_rad_attn_prefill_h256_gqa12_scratch halo_rad_attn_prefill_h256_gqa4_bf16 halo_rad_attn_prefill_h256_gqa4_fp8 halo_rad_attn_prefill_h256_gqa4_scratch halo_rad_attn_prefill_h256_gqa6_bf16 halo_rad_attn_prefill_h256_gqa6_fp8 halo_rad_attn_prefill_h256_gqa6_fp8v4 halo_rad_attn_prefill_h256_gqa6_fp8v4_scratch halo_rad_attn_prefill_h256_gqa6_k6v4 halo_rad_attn_prefill_h256_gqa6_k6v4_scratch halo_rad_attn_prefill_h256_gqa6_scratch halo_rad_attn_prefill_h256_gqa8_bf16 halo_rad_attn_prefill_h256_gqa8_fp8 halo_rad_attn_prefill_h256_gqa8_scratch halo_rad_attn_prefill_h64_gqa4_bf16 halo_rad_attn_prefill_h64_gqa4_fp8 halo_rad_attn_prefill_h64_gqa4_scratch halo_rad_attn_window_h128_gqa1_bf16 halo_rad_attn_window_h128_gqa1_fp8 halo_rad_attn_window_h128_gqa4_bf16 halo_rad_attn_window_h128_gqa4_fp8 halo_rad_attn_window_h256_gqa1_bf16 halo_rad_attn_window_h256_gqa1_fp8 halo_rad_attn_window_h256_gqa2_bf16 halo_rad_attn_window_h256_gqa2_fp8 halo_rad_attn_window_h256_gqa4_bf16 halo_rad_attn_window_h256_gqa4_fp8 halo_rad_attn_window_h256_gqa8_bf16 halo_rad_attn_window_h256_gqa8_fp8 halo_rad_attn_window_h512_gqa1_bf16 halo_rad_attn_window_h512_gqa1_fp8 halo_rad_attn_window_h512_gqa2_bf16 halo_rad_attn_window_h512_gqa2_fp8 halo_rad_attn_window_h512_gqa4_bf16 halo_rad_attn_window_h512_gqa4_fp8 halo_rad_attn_window_h512_gqa8_bf16 halo_rad_attn_window_h512_gqa8_fp8"; } diff --git a/tests/halo_emu/test_attn.cpp b/tests/halo_emu/test_attn.cpp index 88fbd5f8..c7287144 100644 --- a/tests/halo_emu/test_attn.cpp +++ b/tests/halo_emu/test_attn.cpp @@ -42,7 +42,7 @@ struct Case { using Fn = int (*)(const RadArgs*, RadStream); static Fn pick(int hd, int gqa, bool fp8) { #define P(H, G) if (hd == H && gqa == G) return fp8 ? halo_rad_attn_window_h##H##_gqa##G##_fp8 : halo_rad_attn_window_h##H##_gqa##G##_bf16; - P(128, 1) P(256, 1) P(256, 2) P(256, 4) P(256, 8) P(512, 1) P(512, 2) P(512, 4) P(512, 8) + P(128, 1) P(128, 4) P(256, 1) P(256, 2) P(256, 4) P(256, 8) P(512, 1) P(512, 2) P(512, 4) P(512, 8) #undef P return nullptr; } @@ -182,6 +182,21 @@ int main(int argc, char** argv) { 0, 0, 512, 1}, {"wmma h128 gqa1 swa w1024 ragged", 128, 1, 1, false, true, true, false, 1024, {150, 70}, {300, 70}, -1, 0, 0, 0, 1}, + /* LFM3: h128, 16 query heads over 4 KV heads; full layers and a 256-token sliding window. + * Prefill and chunked prefill past the decode leg's band, ragged steps with decode rows, a + * query whose window starts inside the context, fp8 cache */ + {"h128 gqa4 kvh4 full verify17 split", 128, 4, 4, false, true, false, false, 0, {17}, {300}, -1, 262144, s128}, + {"h128 gqa4 kvh4 swa w256 ragged", 128, 4, 4, false, true, true, false, 256, {1, 5, 40}, {600, 77, 300}}, + {"h128 gqa4 kvh2 swa w256 fp8+descale split", 128, 4, 2, true, true, false, true, 256, {20}, {700}, -1, 4096, s128}, + {"h128 gqa4 kvh4 noncausal missing-block", 128, 4, 4, false, false, true, false, 0, {4, 2}, {37, 20}, 1}, + {"wmma h128 gqa4 kvh4 full prefill 200 of 900", 128, 4, 4, false, true, false, false, 0, {200}, {900}, + -1, 0, 0, 0, 1}, + {"wmma h128 gqa4 kvh4 swa w256 prefill 300 of 900", 128, 4, 4, false, true, false, false, 256, {300}, + {900}, -1, 0, 0, 0, 1}, + {"wmma h128 gqa4 kvh4 swa w256 ragged + decode rows", 128, 4, 4, false, true, true, false, 256, + {150, 1, 70}, {500, 50, 70}, -1, 0, 0, 0, 1}, + {"wmma h128 gqa4 kvh2 swa w256 fp8+descale", 128, 4, 2, true, true, true, true, 256, {100, 90}, + {400, 90}, -1, 0, 0, 0, 1}, /* Gemma 4 sliding: h256 gqa2, causal, windowed; a ragged mixed step */ {"h256 gqa2 swa w64 ragged bf16", 256, 2, 2, false, true, true, false, 64, {1, 5, 40}, {200, 77, 140}}, {"h256 gqa2 swa w64 ragged fp8+descale", 256, 2, 2, true, true, true, true, 64, {1, 5, 40}, {200, 77, 140}},