mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
tools/vision/own: the fused attention is the default on gfx1151 (STRATA_VIT_FA=0 turns it off)
On gfx1151 (Strix Halo) with head size <= 96, a multiple of 8, and wave 32, k_attn_fa_gfx11 now runs
unless STRATA_VIT_FA=0 is set; STRATA_VIT_FA=1 still asks for it on other gfx11 cards. The variable
is read after the default, as the HPA16 variables are. No new setting. gfx1103 and the other gfx11
cards are unchanged (they get their own gate). The register note of STRATA_VIT_FA is marked
[DRAFT, status: research].
Measured on Strix (gfx1151, Windows, build 5 of af825339a, STRATA_VIT_FA=1 against no variable),
Qwen3.8 against mtmd-CPU:
- attention on big1024 (1,024 tokens, warm): 319.6 ms -> 158.7 ms (0.50); whole picture 383 -> 320 ms,
code4217 89 -> 80 ms;
- time against mtmd-HIP, 18 pictures, min / median / max: 0.56 / 0.66 / 0.92 -> 0.46 / 0.60 / 0.83
(Qwen3.6: 0.56 / 0.67 / 0.91 -> 0.46 / 0.61 / 0.91);
- rule 1 and rule 2 pass on 18 of 18 pictures on both models for both arms; byte-identical over 5
encodes and across two processes;
- longest launch 6 ms at 1,024 tokens, 17 ms at 65,536 patches (limit_4096x4096 reads 0.999693
against the stored mtmd-CPU embedding);
- smallest token against mtmd-CPU, fused minus default, Qwen3.8: below on 6 of 18 pictures
(code4217 -0.094 = token #47, shapes_p.gif -0.019), above on 12; token #47 of code4217 depends on
rounding in every variant measured (its length 0.74 to 2.03; the two CPU references agree on it
to 0.7600, on the whole picture to 0.999543; the fused kernel is near our CPU tower, the default
near mtmd-CPU).
Jobs strix-20261111-1620-a728, -1622-31a8, -1636-6cb1, -1644-15d4; details in
phaseA-tests/cleanup/RESULTS-OWN-3V.md part F8-F9. The gate of the build as it ships follows.
This commit is contained in:
1 parent
af825339a4
commit
f5d3b45c57
2 files changed
+18
-4
No files matched your search
@@ -611,7 +611,8 @@ struct VitGpuImpl {
|
||||
// phaseA-tests\par\RESULTS-COVER.md); mtmd's reader asks for the 16-bit result there. STRATA_VIT_HPA16_ATT=1: the same for the attention's P*V product
|
||||
// (F16 -> F16, float32 accumulation; the score product S is F16 -> F16 already). The result is the float32 sum rounded once to 16 bits.
|
||||
bool hpa16 = false, hpa16_att = false;
|
||||
// STRATA_VIT_FA=1 (off by default): the fused attention k_attn_fa_gfx11 on gfx11 cards (wave32). A launch takes at most fa_units query x key x head
|
||||
// [DRAFT, status: research] STRATA_VIT_FA (on by default on gfx1151 only, see VitGpu::load; =1 asks for it on another gfx11 card, =0 turns it off): the fused attention
|
||||
// k_attn_fa_gfx11 on gfx11 cards (wave32). A launch takes at most fa_units query x key x head
|
||||
// triples (STRATA_VIT_FA_UNITS overrides): 2^29, measured on the 780M with the first version at about 1.4 TFLOP/s as about 110 ms, so far
|
||||
// from the Windows GPU timeout of 2 s on any gfx11 card, also at the 16,384-token limit (65,232 patches: about 130 launches a layer). With STRATA_VIT_PROF the longest launch of an encode is printed.
|
||||
bool fa = false;
|
||||
@@ -839,6 +840,9 @@ bool VitGpu::load(const Gguf& gg, const VitGeometry& g, int device, int max_patc
|
||||
if (!vit_geometry_supported(g, why)) { err = "this tower is not supported: " + why; return false; }
|
||||
m.g = g;
|
||||
m.device = device;
|
||||
#if defined(STRATA_VIT_HIP)
|
||||
bool fa_default = false; // the fused attention is the default on gfx1151 (below); STRATA_VIT_FA overrides it either way
|
||||
#endif
|
||||
#if !defined(STRATA_VIT_HIP)
|
||||
bool pascal = false;
|
||||
{ // Pascal (compute capability 6.x): BF16 matrices as F16 (and the larger score chunk below)
|
||||
@@ -851,8 +855,15 @@ bool VitGpu::load(const Gguf& gg, const VitGeometry& g, int device, int max_patc
|
||||
// HH_HPA kernels (F16 results, 10-bit mantissa). Strix, 18 pictures at 1,024 tokens: Qwen3.8 0.54-0.83 of mtmd-HIP's time (median 0.66), Qwen3.6
|
||||
// 0.57-0.91 (median 0.67), rule 1 and 2 pass on both, byte-identical in and across processes; the BF16 results of BB_HPA missed rule 1 on 3 of the
|
||||
// Qwen3.8 pictures and rule 2 on 3 (RESULTS-OWN-3V.md PART F2/F3). STRATA_VIT_HPA16, STRATA_VIT_HPA16_ATT and STRATA_VIT_BF16_AS_F16 = 0 turn each off.
|
||||
// The fused attention k_attn_fa_gfx11 is on by default there too (Strix, RESULTS-OWN-3V.md PART F8): attention 0.50 of the default's time on the 1,024-token
|
||||
// picture, the whole picture 0.84-0.90, rule 1 and 2 on 18 of 18 pictures on both models, byte-identical in and across processes, longest launch 6 ms
|
||||
// (17 ms at 65,536 patches, which read 0.999693 against mtmd-CPU). STRATA_VIT_FA=0 turns it off. gfx1151 only: gfx1103 and the other gfx11 cards keep it off
|
||||
// until they have their own gate.
|
||||
hipDeviceProp_t p;
|
||||
if (hipGetDeviceProperties(&p, device) == hipSuccess && vit_gpu_is_gfx1151(p.gcnArchName)) m.bf16_as_f16 = m.hpa16 = m.hpa16_att = true;
|
||||
if (hipGetDeviceProperties(&p, device) == hipSuccess && vit_gpu_is_gfx1151(p.gcnArchName)) {
|
||||
m.bf16_as_f16 = m.hpa16 = m.hpa16_att = true;
|
||||
fa_default = p.warpSize == 32 && g.head_dim <= 96 && g.head_dim % 8 == 0;
|
||||
}
|
||||
(void) hipGetLastError();
|
||||
}
|
||||
#endif
|
||||
@@ -868,7 +879,9 @@ bool VitGpu::load(const Gguf& gg, const VitGeometry& g, int device, int max_patc
|
||||
if (m.hpa16 || m.hpa16_att)
|
||||
std::fprintf(stderr, "vit-hpa16: 16-bit results with float32 accumulation for %s%s%s\n", m.hpa16 ? "the weight products" : "",
|
||||
m.hpa16 && m.hpa16_att ? " and " : "", m.hpa16_att ? "the attention's P*V product" : "");
|
||||
if (const char* e = std::getenv("STRATA_VIT_FA"); e && std::atoi(e) != 0) {
|
||||
bool want_fa = fa_default;
|
||||
if (const char* e = std::getenv("STRATA_VIT_FA")) want_fa = std::atoi(e) != 0;
|
||||
if (want_fa) {
|
||||
hipDeviceProp_t p;
|
||||
if (hipGetDeviceProperties(&p, device) == hipSuccess && std::string(p.gcnArchName).rfind("gfx11", 0) == 0 && p.warpSize == 32 && g.head_dim <= 96 && g.head_dim % 8 == 0)
|
||||
m.fa = true;
|
||||
|
||||
@@ -36,7 +36,8 @@ inline bool vit_gpu_slower_nvidia(int cc_major, int cc_minor, bool bf16_matrices
|
||||
// AMD gfx1151 (Strix Halo, Radeon 8060S) takes our tower under `auto` (owner 11-11: "For Strix - use our reader, even if its a bit slower ... Our priority is to
|
||||
// get off ggml and llama.cpp"). The ROCm package's rocBLAS has tuned gfx1151 kernels for 16-bit results only (BF16 / F16 -> F32 is fallback-only), so on
|
||||
// gfx1151 the tower asks for F16 results with float32 accumulation (vit_gpu.cu, VitGpu::load): 0.54-0.91 of mtmd-HIP's time on Strix, rule 1 and 2 pass on
|
||||
// 18 pictures with both models (RESULTS-OWN-3V.md PART F2/F3; with float32 results it was 1.7 to 3.1).
|
||||
// 18 pictures with both models (RESULTS-OWN-3V.md PART F2/F3; with float32 results it was 1.7 to 3.1). The fused attention (STRATA_VIT_FA, k_attn_fa_gfx11) is on by
|
||||
// default there as well (PART F8); STRATA_VIT_FA=0 turns it off.
|
||||
// `gfx` is the device's arch name (hipDeviceProp_t::gcnArchName, possibly with feature suffixes such as ":xnack-").
|
||||
inline bool vit_gpu_is_gfx1151(const std::string& gfx) { return gfx.rfind("gfx1151", 0) == 0 && (gfx.size() == 7 || gfx[7] == ':'); }
|
||||
// AMD on Windows (coordinator 11-11, with the default flip to our tower): no card but gfx1151 has been measured with the Windows HIP package, so `auto` keeps
|
||||
|
||||
Reference in new issue
Block a user