diff --git a/tools/vision/own/vit_gpu.cu b/tools/vision/own/vit_gpu.cu index 3d58382cb3..eb8bf4a248 100644 --- a/tools/vision/own/vit_gpu.cu +++ b/tools/vision/own/vit_gpu.cu @@ -486,7 +486,7 @@ struct VitGpuImpl { #endif #if defined(STRATA_VIT_HIP) - // STRATA_VIT_HPA16=1 (off by default): the 16-bit weight products ask rocBLAS for a 16-bit RESULT with float32 accumulation (BF16 -> BF16 and F16 -> F16, + // STRATA_VIT_HPA16=1 (on by default on gfx1151 only, see VitGpu::load): the 16-bit weight products ask rocBLAS for a 16-bit RESULT with float32 accumulation (BF16 -> BF16 and F16 -> F16, // compute 32F: rocBLAS's BB_HPA / HH_HPA kernels), then widen it to float32. On gfx110x and gfx1151 the Windows ROCm package's rocBLAS has tuned kernels // for those types and only its generic fallback kernels for BF16 / F16 -> F32 (BS_HPA / HS_HPA), which our products asked for (lane COVER 11-11, // 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 @@ -721,6 +721,15 @@ bool VitGpu::load(const Gguf& gg, const VitGeometry& g, int device, int max_patc if (cudaGetDeviceProperties(&p, device) == cudaSuccess && p.major == 6) pascal = m.bf16_as_f16 = true; (void) cudaGetLastError(); } +#else + { // gfx1151 (Strix Halo): every product with a 16-bit result and float32 accumulation, BF16 matrices held as F16, so all of them run rocBLAS's tuned + // 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. + hipDeviceProp_t p; + if (hipGetDeviceProperties(&p, device) == hipSuccess && vit_gpu_is_gfx1151(p.gcnArchName)) m.bf16_as_f16 = m.hpa16 = m.hpa16_att = true; + (void) hipGetLastError(); + } #endif if (const char* e = std::getenv("STRATA_VIT_BF16_AS_F16")) m.bf16_as_f16 = std::atoi(e) != 0; if (cudaSetDevice(device) != cudaSuccess) { err = std::string("cannot use GPU ") + std::to_string(device) + ": " + cudaGetErrorString(cudaGetLastError()); return false; } diff --git a/tools/vision/own/vit_gpu.h b/tools/vision/own/vit_gpu.h index c7018d498d..aa91b2d671 100644 --- a/tools/vision/own/vit_gpu.h +++ b/tools/vision/own/vit_gpu.h @@ -34,8 +34,9 @@ inline bool vit_gpu_slower_nvidia(int cc_major, int cc_minor, bool bf16_matrices return max_tokens <= kVitGpuDefaultLimit && cc_major == 6 && !(cc_minor == 0 && 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"). It is slower there: the ROCm package's rocBLAS ships only its generic "fallback" Tensile kernels for gfx1151 (Windows, Strix: -// 1.73 to 3.03 of mtmd-HIP's time with hipBLAS; RESULTS-OWN-3V.md 12.14, PART F), and correct (rule 1 and 2 pass on 18 pictures, both models). +// 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). // `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