HIP: the RX 6000 cards read prompts with FP16 GEMMs by default (#5151)

prompt_f16_resolve: with STRATA_HIP_PROMPT_F16 unset, a discrete gfx1030 / gfx1031 / gfx1032 card
(the RX 6000 package's cards, Linux and Windows) now runs the prompt path's 16-bit GEMMs FP16 in and
out, the route rocBLAS has tuned kernels for on gfx103x. STRATA_HIP_PROMPT_F16=0 keeps the old route
(register entry updated); =1 as before. The 780M rule is unchanged; gfx11, gfx12, gfx1034, the
integrated gfx1035 / gfx1036 and every other part keep the old route. The engine says once at start
that the default is in force.

Measured on an RX 6700 XT (gfx1031, Linux container, ROCm 10.1 / rocBLAS 5.7), Qwen3.8-Flash-Next
IQ2_XS pack, gate2.py forced-token KL: 16 prompts of 2,048 tokens, 64 forced tokens, truth = the
exact FP32 products (STRATA_RDNA2_SGEMM=1), reference = the old default, its repeat bit-identical
(ratio 1.000 [1.000, 1.000]):

  positions   KL old route   KL FP16    FP16 / old [95 %]      top-1 = truth (old / FP16)
  1           0.00681        0.00688    1.010 [0.672, 1.941]   100.00 % / 93.75 %
  2-8         0.00491        0.00552    1.125 [0.923, 1.454]   99.11 % / 98.21 %
  9-32        0.00585        0.00550    0.941 [0.769, 1.184]   97.14 % / 97.66 %
  33-64       0.00675        0.00542    0.802 [0.711, 0.890]   98.63 % / 98.83 %
  all         0.00621        0.00549    0.883 [0.829, 0.948]   98.14 % / 98.24 %

Prompt time (2,000 tokens, 3 interleaved pairs): 0.873 / 0.869 / 0.884 of the old route
(8 prompts of ~2K: 0.862-0.891). 8K prompts not measured (the box's 88 C junction stop line was
reached in the 8K start). Windows not measured on our side (community runs on RX 6800 / 6900 XT
used =1, docs/AMD_HIP.md).

Test: src/core/arch_defaults_test.cpp (the gfx103x rule: fails on the base, passes here).
This commit is contained in:
Niko1221 committed 2026-11-16 20:45:41 +01:00
1 parent e46fd29a0a
commit c1fa42c134
5 files changed
+29 -13

No files matched your search

+1 -1
View File
@@ -12357,7 +12357,7 @@
"last_date": "2026-11-12",
"status": "default",
"owner": "prefill",
"note": "[auto] on by default for a Radeon 780M (gfx1103, integrated, Linux) only (include/strata/core/arch_defaults.hpp:82 prompt_f16_resolve, used by prompt_f16() in src/prefill/gemm.cu); opt-in elsewhere (=1); =0 turns it off. [docs/AMD_HIP.md:512]",
"note": "on by default for a Radeon 780M (gfx1103, integrated, Linux) and for the discrete RX 6000 cards (gfx1030 / gfx1031 / gfx1032, #5151) (include/strata/core/arch_defaults.hpp prompt_f16_resolve, used by prompt_f16() in src/prefill/gemm.cu); opt-in elsewhere (=1); =0 turns it off (the way back). [docs/AMD_HIP.md:512]",
"retire_after": "",
"retired_in": ""
},
+1 -1
View File
@@ -509,7 +509,7 @@ kernels for FP16-in / FP16-out GEMMs only; the prompt path's FP16-in / FP32-out
| Switch | Effect |
| --- | --- |
| `STRATA_HIP_PROMPT_F16=1` | Runs the 16-bit prompt GEMMs FP16 in and out. On by default on a Radeon 780M (gfx1103) under Linux; `=0` turns it off there; every other card needs `=1`. Radeon 780M, Q2_0, prompt x1.11 / x1.15 / x1.19 / x1.25 at 300 / 1,000 / 2,048 / 8,192 tokens (x1.11 / x1.15 / x1.63 / x1.45 beside `STRATA_PF_FUSED=1`); forced-token KL against the FP16 path 0.00593 against 0.00543 for MMQ (24 prompts, 64 tokens each, ratio 1.09, 95% CI 0.97 to 1.23). On a Radeon AI PRO R9700 (gfx1201) the dense GEMMs are slower with it (x0.70 to x0.72), so it stays opt-in there. `STRATA_F16_RANGE=1` prints, per prompt, the largest value that entered or left FP16 (FP16 ends at 65504); `STRATA_DBG_NAN=1` counts non-finite FP16 outputs. Checks: [2026-10-04-rdna2-fp16-prompt](../bench/results/2026-10-04-rdna2-fp16-prompt/README.md). |
| `STRATA_HIP_PROMPT_F16=1` | Runs the 16-bit prompt GEMMs FP16 in and out. On by default on a Radeon 780M (gfx1103) under Linux and on the RX 6000 cards (gfx1030 / gfx1031 / gfx1032, from 0.2.16); `=0` turns it off there; every other card needs `=1`. RX 6700 XT, IQ2_XS, 16 prompts of 2K, against the exact FP32 products: KL 0.00549 against 0.00621 for the old route, prompts 11-14 % faster; 8K prompts not measured. Radeon 780M, Q2_0, prompt x1.11 / x1.15 / x1.19 / x1.25 at 300 / 1,000 / 2,048 / 8,192 tokens (x1.11 / x1.15 / x1.63 / x1.45 beside `STRATA_PF_FUSED=1`); forced-token KL against the FP16 path 0.00593 against 0.00543 for MMQ (24 prompts, 64 tokens each, ratio 1.09, 95% CI 0.97 to 1.23). On a Radeon AI PRO R9700 (gfx1201) the dense GEMMs are slower with it (x0.70 to x0.72), so it stays opt-in there. `STRATA_F16_RANGE=1` prints, per prompt, the largest value that entered or left FP16 (FP16 ends at 65504); `STRATA_DBG_NAN=1` counts non-finite FP16 outputs. Checks: [2026-10-04-rdna2-fp16-prompt](../bench/results/2026-10-04-rdna2-fp16-prompt/README.md). |
| `STRATA_RDNA2_SGEMM=1` | Widens both GEMM inputs to FP32 (exact) and runs SGEMM, no 65504 limit. `=all` forces it on any AMD card. With `STRATA_HIP_PROMPT_F16=1` the FP16 route runs first and SGEMM takes the products it leaves. Slower than the FP16 route. |
| `STRATA_ROCBLAS_TUNING=<file or dir>` | A rocBLAS solution table for the FP16 route; setup points the engine at the directory when a table for the architecture exists. The log says `rocBLAS tuning enabled (... rows ...)` or why not. See [rocBLAS table](#rocblas-table-gfx103x). |
| `STRATA_SELECT_SIMT=1` | QSA block scores on the FP32 tiled scorer instead of the warp kernel; helps long prompts (128K: +7.4%). Not bitwise the warp kernel. [Data](../bench/results/2026-10-07-rdna2-qsa-select-simt/README.md). |
+8 -3
View File
@@ -77,11 +77,16 @@ bool igpu_cache_drop_default(const char* gcn_arch, bool integrated, bool windows
/// STRATA_PF_FUSED=1 where the user has not set the variable; STRATA_PF_FUSED=0 is the way back to MMQ.
bool igpu_fused_prompt_default(const char* gcn_arch, bool integrated, bool windows);
/// The 16-bit prompt GEMMs FP16 in and out (STRATA_HIP_PROMPT_F16, gemm.cu prompt_f16()): `env` is the variable's text (nullptr = unset). "1" = on, any other set
/// value = off (as before); unset = the device rule: on for a Radeon 780M (gfx1103, integrated, Linux), off everywhere else (every other gfx11, gfx12, gfx103x,
/// Windows and discrete cards are unchanged). Inline: src/prefill/gemm.cu uses it without linking arch_defaults.cpp.
/// value = off (the way back); unset = the device rule: on for a Radeon 780M (gfx1103, integrated, Linux) and, #5151, for a discrete RX 6000 card (gfx1030 /
/// gfx1031 / gfx1032, Linux and Windows: rocBLAS has tuned kernels for FP16 in / FP16 out only there); off everywhere else (gfx11 and gfx12 cards, the integrated
/// gfx103x APUs, every other part). RX 6700 XT (gfx1031, ROCm 10.1, IQ2_XS, 16 prompts of 2K, 64 forced tokens, truth = the exact FP32 products): KL to the truth
/// 0.00549 against the old default's 0.00621 (ratio 0.883 [0.829, 0.948]; first token 1.010 [0.672, 1.941]), prompts 11-14 % faster; 8K not measured.
/// STRATA_HIP_PROMPT_F16=0 keeps the old route. Inline: src/prefill/gemm.cu uses it without linking arch_defaults.cpp.
inline bool prompt_f16_resolve(const char* env, const char* gcn_arch, bool integrated, bool windows) {
if (env != nullptr) return env[0] == '1';
return integrated && !windows && strata::kernels::gfx_arch_is(gcn_arch, "gfx1103");
if (integrated) return !windows && strata::kernels::gfx_arch_is(gcn_arch, "gfx1103");
return strata::kernels::gfx_arch_is(gcn_arch, "gfx1030") || strata::kernels::gfx_arch_is(gcn_arch, "gfx1031") ||
strata::kernels::gfx_arch_is(gcn_arch, "gfx1032");
}
/// Whether the expert arena skips its MADV_HUGEPAGE request: `no_arena_thp` is STRATA_NO_ARENA_THP (nullptr when unset): "0" asks for the huge
/// pages, any other value skips the request; unset leaves it to `igpu_rule` (igpu_arena_no_thp_default for this device). `thp_always`: the
+11 -2
View File
@@ -467,7 +467,16 @@ int main() {
for (const char* k : {"STRATA_HIP_WMMA", "STRATA_PF_GEMM", "STRATA_PA_FAST", "STRATA_SELECT_WMMA", "STRATA_HC_UPMIX"}) unset(k);
}
#endif
// STRATA_HIP_PROMPT_F16 (gemm.cu prompt_f16): "1" = on anywhere, any other set value = off (the way back), unset = on for the Linux integrated 780M only
// STRATA_HIP_PROMPT_F16 (gemm.cu prompt_f16): "1" = on anywhere, any other set value = off (the way back), unset = on for the Linux integrated 780M and
// (#5151) for a discrete RX 6000 card (gfx1030 / gfx1031 / gfx1032, Linux and Windows)
for (const char* g : {"gfx1030", "gfx1031", "gfx1032", "gfx1031:xnack-"}) {
CHECK(prompt_f16_resolve(nullptr, g, false, false));
CHECK(prompt_f16_resolve(nullptr, g, false, true)); // Windows too
CHECK(!prompt_f16_resolve(nullptr, g, true, false)); // an integrated part of that name: not the measured class
CHECK(!prompt_f16_resolve("0", g, false, false)); // the way back
CHECK(!prompt_f16_resolve("", g, false, false));
CHECK(prompt_f16_resolve("1", g, false, false));
}
for (const char* g : {"gfx1103", "gfx1103:sramecc-:xnack-"}) {
CHECK(prompt_f16_resolve(nullptr, g, true, false));
CHECK(!prompt_f16_resolve(nullptr, g, true, true)); // Windows
@@ -476,7 +485,7 @@ int main() {
CHECK(!prompt_f16_resolve("", g, true, false));
CHECK(prompt_f16_resolve("1", g, true, false));
}
for (const char* g : {"gfx1150", "gfx1151", "gfx1152", "gfx1100", "gfx1101", "gfx1102", "gfx1200", "gfx1201", "gfx1030", "gfx1031", "gfx1032", "gfx11030", "", "gfx90a"}) {
for (const char* g : {"gfx1150", "gfx1151", "gfx1152", "gfx1100", "gfx1101", "gfx1102", "gfx1200", "gfx1201", "gfx1034", "gfx1035", "gfx1036", "gfx10300", "gfx11030", "", "gfx90a"}) {
CHECK(!prompt_f16_resolve(nullptr, g, true, false)); // unchanged: opt-in
CHECK(!prompt_f16_resolve(nullptr, g, false, false));
CHECK(prompt_f16_resolve("1", g, false, false)); // =1 still turns it on anywhere
+8 -6
View File
@@ -609,9 +609,9 @@ bool prompt_f16() {
int dev = 0;
if (hipGetDevice(&dev) != hipSuccess || dev < 0 || dev >= kMaxDev) { (void) hipGetLastError(); return false; }
if (const int8_t c = cached[dev].load(std::memory_order_relaxed)) return c == 2;
// Opt-in (#835): STRATA_HIP_PROMPT_F16=1 turns it on. It changes the prompt path's numbers (an FP16 rounding of
// each 16-bit GEMM's output), so a card gets it unasked only where it was measured against the FP16 path's level: the Radeon 780M
// (gfx1103, integrated, Linux; strata::core::prompt_f16_resolve), where =0 is the way back.
// (#835) STRATA_HIP_PROMPT_F16=1 turns it on. It changes the prompt path's numbers (an FP16 rounding of each 16-bit GEMM's output), so a card
// gets it unasked only where it was measured: the Radeon 780M (gfx1103, integrated, Linux) and the discrete RX 6000 cards (gfx1030 / 1031 / 1032, #5151;
// strata::core::prompt_f16_resolve), where =0 is the way back.
const char* e = std::getenv("STRATA_HIP_PROMPT_F16");
hipDeviceProp_t p{};
if (hipGetDeviceProperties(&p, dev) != hipSuccess) { (void) hipGetLastError(); p.gcnArchName[0] = 0; p.integrated = 0; }
@@ -624,9 +624,11 @@ bool prompt_f16() {
if (on && e != nullptr) std::fprintf(stderr, "strata prefill: HIP device %d%s%s - STRATA_HIP_PROMPT_F16=1: the prompt's 16-bit GEMMs run FP16 in and out "
"(rocBLAS is tuned only for that on gfx103x; not bit-identical to the default)%s",
dev, p.gcnArchName[0] ? " " : "", p.gcnArchName, "\n");
// (#5151: the start-up tip that asked gfx103x owners to set STRATA_HIP_PROMPT_F16=1 is gone: users never set variables. On an RX 6700 XT the FP16 route
// read 2K prompts 11-14 % faster but moved the first-token distribution well above the default's repeat floor of 0 (KL mean 0.017 over 8 prompts,
// one top-1 change), so it stays opt-in; par/RESULTS-AMD-1116.md.)
else if (on && std::strncmp(p.gcnArchName, "gfx103", 6) == 0)
std::fprintf(stderr, "strata prefill: HIP device %d %s - the prompt's 16-bit GEMMs run FP16 in and out by default here (rocBLAS is tuned for that on "
"gfx103x; STRATA_HIP_PROMPT_F16=0 keeps the old route)%s", dev, p.gcnArchName, "\n");
// (#5151: the start-up tip that asked gfx103x owners to set STRATA_HIP_PROMPT_F16=1 is gone: users never set variables. On a discrete RX 6000 card the
// FP16 route is the default now (prompt_f16_resolve): against the exact FP32 products it is no further from exact than the old route and 11-14 % faster.)
cached[dev].store(on ? 2 : 1, std::memory_order_relaxed);
return on;
#else