mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 23:08:36 +00:00
ling32: gfx11 / gfx12 builds default to the pre-split f16x2 latent cache and the WMMA decode kernel
Without --latent, on an AMD gfx11 / gfx12 device (and with the shared MLA kernel, i.e. not --exact) the MLA cache is the pre-split fp16 hi / lo planes of the WMMA kernel (same bytes as fp32). --latent f32 selects the scalar fp32 kernel. Measured (P8-LONGCTX-RESULTS.md): attention per layer 1.8x (gfx1151) to 3.0x (gfx1201) faster at 128K / 256K, relative error 1e-6 .. 2.2e-6 against the scalar kernel, Strix golden set unchanged, Strix decode at a 256K position 9.5 -> 11.3 tok/s (tier C, ABBA).
This commit is contained in:
1 parent
27dd369432
commit
9bbf432586
1 file changed
+13
-1
@@ -167,6 +167,7 @@ struct RunOpts {
|
||||
int mla_prefill_kernel = -1; // --mla-prefill off|simt|tc|tcfast: the MLA kernel of prefill chunks (default: by the device, default_mla_prefill_kernel(): tc where the mma kernel is built and sm_80+, else simt)
|
||||
bool mla_kernel_set = false; // --mla-kernel given on the command line (else a reserved context of 64K+ picks the tensor-core split kernel where it exists)
|
||||
int mla_kernel = 1; // --mla-kernel old|simt|tc|tcfast (default simt: Strata's multi-head latent-attention kernel, fp32)
|
||||
bool latent_set = false; // --latent given (else gfx11 / gfx12 builds default to the pre-split f16x2 cache and the WMMA kernel)
|
||||
LatentFmt latent = LatentFmt::F32; // --latent f32|f16|q8 (default f32, the exact cache; q8 = int8 + fp16 block scales, 672 B per position and layer)
|
||||
int age_recent = 0; // --age-mix N: the newest N positions exact, older ones rounded by --latent-emul (study)
|
||||
int emul_lat = 0, emul_pe = 0; // --latent-emul lat=q8,pe=f16: study rounding of an fp32 cache (ling32_latent.hpp)
|
||||
@@ -684,6 +685,17 @@ int cmd_run(const RunOpts& o) {
|
||||
eo.tc_moe_min_n = o.tc_moe_min_n;
|
||||
eo.capture = !o.layer_out.empty();
|
||||
eo.latent = o.latent;
|
||||
#if defined(STRATA_USE_HIP)
|
||||
// AMD gfx11 / gfx12: the default MLA cache is the pre-split fp16 hi / lo planes (same bytes as fp32, fp32-class accuracy) read by the WMMA kernel: 1.8x (gfx1151) to 3x (gfx1201) faster
|
||||
// attention than the scalar fp32 kernel at long context, golden-neutral (P8-LONGCTX-RESULTS.md). --latent f32 selects the scalar kernel, --exact too.
|
||||
if (!o.latent_set && o.latent == LatentFmt::F32 && o.mla_kernel > 0) {
|
||||
cudaDeviceProp dp{};
|
||||
if (cudaGetDeviceProperties(&dp, o.device) == cudaSuccess && (std::strncmp(dp.gcnArchName, "gfx11", 5) == 0 || std::strncmp(dp.gcnArchName, "gfx12", 5) == 0)) {
|
||||
eo.latent = LatentFmt::F16X2;
|
||||
std::printf("MLA cache: f16x2 (pre-split fp16 planes, WMMA kernel); --latent f32 for the scalar fp32 kernel\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
eo.emul_lat = o.emul_lat;
|
||||
eo.emul_pe = o.emul_pe;
|
||||
eo.age_recent = o.age_recent;
|
||||
@@ -1452,7 +1464,7 @@ int main(int argc, char** argv) {
|
||||
else if (a == "--mm-runs") o.mm_runs = nx();
|
||||
else if (a == "--layer-out") o.layer_out = nx();
|
||||
else if (a == "--configs") o.configs = nx();
|
||||
else if (a == "--latent") { const std::string v = nx(); if (!latent_parse(v, &o.latent)) { std::fprintf(stderr, "strata-ling32: --latent f32|f16|q8|f16x2, not '%s'\n", v.c_str()); return 2; } }
|
||||
else if (a == "--latent") { o.latent_set = true; const std::string v = nx(); if (!latent_parse(v, &o.latent)) { std::fprintf(stderr, "strata-ling32: --latent f32|f16|q8|f16x2, not '%s'\n", v.c_str()); return 2; } }
|
||||
else if (a == "--age-mix") o.age_recent = std::atoi(nx().c_str());
|
||||
else if (a == "--latent-emul") { const std::string v = nx(); if (!emul_parse(v, &o.emul_lat, &o.emul_pe)) { std::fprintf(stderr, "strata-ling32: --latent-emul lat=f16|q8|bf16|q10|q12|q14,pe=f16|bf16, not '%s'\n", v.c_str()); return 2; } }
|
||||
else if (a == "--mla-prefill") { const std::string v = nx(); o.mla_prefill_kernel = v == "simt" ? 1 : v == "tc" ? 2 : v == "tcfast" ? 3 : 0; }
|
||||
|
||||
Reference in new issue
Block a user