Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
hip: FP16 prompt GEMMs are opt-in (STRATA_HIP_PROMPT_F16=1), CUDA-guarded, decided once per stage, non-finite count (#835 review)
Niko122101f21ea6835d
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 68e9443ce..dbe1e39a1 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -525,6 +525,10 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP)target_link_libraries(hip_prefill_gemm PRIVATE strata_prefill strata_hip_runtime)add_test(NAME hip_prefill_gemm COMMAND hip_prefill_gemm)list(APPEND _strata_hip_tests hip_prefill_gemm)+ add_executable(hip_gemm_f16_io_parity tests/hip/gemm_f16_io_parity.cpp)+ target_link_libraries(hip_gemm_f16_io_parity PRIVATE strata_prefill strata_hip_runtime)+ add_test(NAME hip_gemm_f16_io_parity COMMAND hip_gemm_f16_io_parity)+ list(APPEND _strata_hip_tests hip_gemm_f16_io_parity)add_executable(hip_q2_zero tests/hip/q2_zero.cpp)target_link_libraries(hip_q2_zero PRIVATE strata_kernels strata_hip_runtime)add_test(NAME hip_q2_zero COMMAND hip_q2_zero)diff --git a/docs/AMD_HIP.md b/docs/AMD_HIP.mdindex 400978706..a22d0943c 100644--- a/docs/AMD_HIP.md+++ b/docs/AMD_HIP.md@@ -350,8 +350,8 @@ run it; the report below is from a community machine: an RX 6900 XT 16 GB (gfx10- **hipBLASLt:** ROCm's hipBLASLt ships no gfx1030 kernels, so there is no table and the plain hipBLAS path runs.- **Prompt GEMMs in FP16 (#835):** rocBLAS on gfx1030 has tuned kernels for FP16-in / FP16-out GEMMs only; the promptpath's FP16-in / FP32-out and BF16 products ran generic kernels about 6.6x slower (5.6 and ~5.3 TFLOPS against 37.7 at- N = 10240, T = 7313, K = 2560). On gfx103x the 16-bit prompt GEMMs now run FP16 in and out; `STRATA_HIP_PROMPT_F16=0` is- the old path. The output is not bit-identical to it (an FP16 rounding of each GEMM's output replaces the BF16 rounding of+ N = 10240, T = 7313, K = 2560). `STRATA_HIP_PROMPT_F16=1` (opt-in, off by default; the engine prints a tip on gfx103x) runs the 16-bit prompt GEMMs FP16 in and out;+ unset is the old path. `STRATA_DBG_NAN=1` also counts the non-finite FP16 outputs (a sum past 65504). The output is not bit-identical to it (an FP16 rounding of each GEMM's output replaces the BF16 rounding ofthe BF16 GEMMs' activations); what the distribution check showed and did not show is in[bench/results/2026-10-04-rdna2-fp16-prompt](../bench/results/2026-10-04-rdna2-fp16-prompt/README.md). Measured on asecond community machine - 2x RX 6900 XT 16 GB (one card for these numbers), Ryzen 5 5600X (6 cores, AVX2), 128 GB,diff --git a/src/prefill/gemm.cu b/src/prefill/gemm.cuindex 7299e6345..2c1db6de2 100644--- a/src/prefill/gemm.cu+++ b/src/prefill/gemm.cu@@ -54,13 +54,16 @@ namespace {// Y's rows, written by an FP16-out GEMM as FP16 at the start of each FP32 row (ldc = 2 ldy halves), widened in place.// Float c overwrites halves 2c and 2c+1, so a row is walked from its end in blocks: a block's halves are read into// registers, the block syncs, then writes its floats - which only cover halves of blocks already read.-__global__ void widen_rows_f16(float* __restrict__ Y, int64_t n, int64_t ldy) {+// STRATA_DBG_NAN: the FP16 outputs that are not finite (an FP32-accumulated sum past 65504 becomes inf in FP16).+__device__ unsigned long long g_f16_nonfinite = 0;+__global__ void widen_rows_f16(float* __restrict__ Y, int64_t n, int64_t ldy, int count_nonfinite) {float* y = Y + (int64_t) blockIdx.x * ldy;const __half* h = reinterpret_cast<const __half*>(y);const int64_t nb = (n + blockDim.x - 1) / blockDim.x;for (int64_t b = nb - 1; b >= 0; --b) {const int64_t c = b * blockDim.x + threadIdx.x;const float v = c < n ? __half2float(h[c]) : 0.0f;+ if (count_nonfinite && c < n && !isfinite(v)) atomicAdd(&g_f16_nonfinite, 1ull);__syncthreads();if (c < n) y[c] = v;__syncthreads();@@ -351,16 +354,19 @@ 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;- bool on = false;+ // Opt-in (#835): only 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 no card gets it unasked. On gfx103x it is ~2x faster, so we say so once.const char* e = std::getenv("STRATA_HIP_PROMPT_F16");+ const bool on = e != nullptr && e[0] == '1';hipDeviceProp_t p{};- if (e && e[0] == '0') on = false;- else if (e && e[0] == '1') on = true;- else if (hipGetDeviceProperties(&p, dev) == hipSuccess) on = std::strncmp(p.gcnArchName, "gfx103", 6) == 0;- else (void) hipGetLastError();- if (on) std::fprintf(stderr, "strata prefill: HIP device %d%s%s - the prompt's 16-bit GEMMs run FP16 in and out (rocBLAS "- "is tuned only for that there; STRATA_HIP_PROMPT_F16=0 keeps BF16 in / FP32 out)\n",- dev, p.gcnArchName[0] ? " " : "", p.gcnArchName);+ if (hipGetDeviceProperties(&p, dev) != hipSuccess) { (void) hipGetLastError(); p.gcnArchName[0] = 0; }+ if (on) 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");+ else if (e == nullptr && std::strncmp(p.gcnArchName, "gfx103", 6) == 0)+ std::fprintf(stderr, "strata prefill: HIP device %d %s - tip: STRATA_HIP_PROMPT_F16=1 reads long prompts about 2x faster here "+ "(FP16 prompt GEMMs, rocBLAS is tuned only for FP16 on gfx103x; the numbers differ slightly, see docs/AMD_HIP.md)%s",+ dev, p.gcnArchName, "\n");cached[dev].store(on ? 2 : 1, std::memory_order_relaxed);return on;#else@@ -748,7 +754,17 @@ void Gemm::f16_inplace(const uint16_t* X, const uint16_t* W, float* Y, int64_t T(int) K, X, CUDA_R_16F, (int) K, &zero, Y, CUDA_R_16F, (int) (2 * ldy), CUBLAS_COMPUTE_32F,CUBLAS_GEMM_DEFAULT),"cublasGemmEx f16 out");- widen_rows_f16<<<(unsigned) T, 256, 0, (cudaStream_t) stream_>>>(Y, N, ldy);+ static const bool dbg_nan = std::getenv("STRATA_DBG_NAN") != nullptr;+ widen_rows_f16<<<(unsigned) T, 256, 0, (cudaStream_t) stream_>>>(Y, N, ldy, dbg_nan ? 1 : 0);+ if (dbg_nan) { // debug only: a sync per GEMM+ unsigned long long bad = 0, zero_count = 0;+ (void) hipStreamSynchronize((hipStream_t) stream_);+ if (hipMemcpyFromSymbol(&bad, HIP_SYMBOL(g_f16_nonfinite), sizeof bad) == hipSuccess && bad != 0) {+ std::fprintf(stderr, "strata prefill: STRATA_DBG_NAN: %llu non-finite FP16 GEMM outputs (T=%lld N=%lld K=%lld; FP16 ends at 65504)%s",+ bad, (long long) T, (long long) N, (long long) K, "\n");+ (void) hipMemcpyToSymbol(HIP_SYMBOL(g_f16_nonfinite), &zero_count, sizeof zero_count);+ }+ }#else(void) X; (void) W; (void) Y; (void) T; (void) N; (void) K; (void) ldy;#endifdiff --git a/src/prefill/kernels.cu b/src/prefill/kernels.cuindex b21757d25..3f14fb16d 100644--- a/src/prefill/kernels.cu+++ b/src/prefill/kernels.cu@@ -47,8 +47,12 @@ __device__ __forceinline__ uint16_t hf(float f) { return __half_as_ushort(__floa__device__ __forceinline__ uint16_t hf_sat(float f) { return hf(isnan(f) ? f : fminf(fmaxf(f, -65504.0f), 65504.0f)); }// The prompt path's 16-bit activation image for the BF16-weight GEMMs: BF16, or FP16 where the GEMM library is fast// only in FP16 (prompt_f16() in gemm.cu: rocBLAS on gfx103x). Set once per device before the first prompt.+#if defined(__HIPCC__) // HIP only (#835): the CUDA kernels stay exactly as they were, they never read the flag__device__ int g_act_f16 = 0;__device__ __forceinline__ uint16_t act16(float f) { return g_act_f16 ? hf_sat(f) : bf(f); }+#else+__device__ __forceinline__ uint16_t act16(float f) { return bf(f); }+#endif// block-wide sum for blockDim.x <= 1024, result broadcast__device__ float block_sum(float v, float* sh) {const int lane = threadIdx.x & 31, w = threadIdx.x >> 5;@@ -1450,11 +1454,16 @@ void kv_append(const float* K, const float* V, int64_t T, int64_t pos0, const incheck("kv_append");}void set_act_f16(bool on) {+#if !defined(__HIPCC__)+ (void) on; // CUDA: the activation image is always BF16+ return;+#elseconst int v = on ? 1 : 0;if (cudaMemcpyToSymbol(g_act_f16, &v, sizeof v) != cudaSuccess) {std::fprintf(stderr, "prefill: setting the FP16 activation image failed: %s\n", cudaGetErrorString(cudaGetLastError()));std::exit(1);}+#endif}void to_f16(const float* x, uint16_t* y, int64_t n, void* stream) {if (n <= 0) return;diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cppindex cf1a03fab..05228b536 100644--- a/src/prefill/prefill.cpp+++ b/src/prefill/prefill.cpp@@ -213,16 +213,16 @@ constexpr int DQ = 2; // dequantized-expert ring (FP16 gate/up + do// second GEMM (Y = W.hi + W.lo, ~16 mantissa bits): a router that picks its top 10 from the same x decode would.// 2 = all but the hyper-connection's; 1 = the hyper-connection's too (its activations are 10240 wide and its up// projection writes as much: slower); 0 (the default: opt-in, it changes the prompt path's numbers) = off.-inline int bf16x2_mode() {+// `f16_io`: the stage's FP16 prompt path (Prefill::init decides it once per stage, on the stage's own device): FP16+// activations carry 11 mantissa bits, so the BF16 low part does not apply there.+inline int bf16x2_mode(bool f16_io) {static const int v = [] {const char* e = std::getenv("STRATA_PREFILL_BF16X2");return e != nullptr ? std::atoi(e) : 0;}();- // FP16 activations carry 11 mantissa bits; the BF16 low part does not apply (per device: a split can mix cards)- if (v != 0 && prompt_f16()) return 0;- return v;+ return f16_io ? 0 : v;}-inline bool bf16x2() { return bf16x2_mode() != 0; }+inline bool bf16x2(bool f16_io) { return bf16x2_mode(f16_io) != 0; }// S23 (opt-in STRATA_HC_UPMIX=1): the hyper-connection read's up projection and gr_mix_r as one kernel (gr_upmix, gfx11);// STRATA_HC_UPMIX_CHECK=N also runs the default pair on the first N reads and reports the difference of `mixed`static int64_t pf_switch_min_t() { // S23: STRATA_PF_SWITCH_MIN_T=N - the rounding-level prompt switches only on chunks of@@ -234,7 +234,7 @@ inline bool hc_upmix() {static const bool v = [] { const char* e = std::getenv("STRATA_HC_UPMIX"); return e != nullptr && e[0] == '1'; }();return v;}-inline bool bf16x2_hc() { return bf16x2_mode() == 1; }+inline bool bf16x2_hc(bool f16_io) { return bf16x2_mode(f16_io) == 1; }// S23 (opt-in STRATA_CVEC_FUSE=1): a steered layer's FFN write + control vector + the next half's norm in one pass// over R (gr_write_cvec_norm_rs; bitwise the gr_write + cvec_apply + gr_norm_rs it replaces)// S23 (opt-in STRATA_PF_HCDOWN=1, on chunks of STRATA_PF_SWITCH_MIN_T+ tokens): the hyper-connection read's down and@@ -548,6 +548,7 @@ struct Prefill::Impl {uint16_t *xn16 = nullptr, *lo16 = nullptr;float* mixed = nullptr;uint16_t *mixed_bf = nullptr, *mixed_h = nullptr;+ bool f16_io = false; // HIP, STRATA_HIP_PROMPT_F16=1: this stage's 16-bit GEMMs run FP16 in and out (set in init)uint16_t *xn16_lo = nullptr, *lo16_lo = nullptr, *mixed_bf_lo = nullptr; // bf16x2(): the BF16 GEMMs' low partsfloat* bo = nullptr;// GDN@@ -899,9 +900,12 @@ bool Prefill::init(const core::WeightTable& wt, const core::ModelGeometry& g, covoid* ws = o.take<uint8_t>(GEMM_WS, ok);if (!ok) { err = "prefill: GEMM scratch does not fit"; return false; }if (!m.gemm.init_external(stream, gs, GEMM_SCRATCH, ws, GEMM_WS, err)) return false;- const bool f16_io = prompt_f16(); // this device's gr_* kernels write the image its GEMMs read- m.gemm.set_f16_io(f16_io);- set_act_f16(f16_io);+ // this stage's device decides, once, here (init runs on the stage's own device): its gr_* kernels write the+ // image its GEMMs read, and set_act_f16 writes that device's symbol+ const core::OnDevice on_stage(m.device);+ m.f16_io = prompt_f16();+ m.gemm.set_f16_io(m.f16_io);+ set_act_f16(m.f16_io);}if (!carve(T, &o)) {err = "prefill: device buffers for a chunk of " + std::to_string(chunk) + " tokens do not fit";@@ -925,8 +929,8 @@ bool Prefill::carve(size_t T, void* alloc) {m.gated = o.take<float>(T * D, ok); m.inj = o.take<float>(T * HC, ok);m.mixed = o.take<float>(T * N, ok); m.mixed_bf = o.take<uint16_t>(T * N, ok);m.mixed_h = o.take<uint16_t>(T * N, ok); m.bo = o.take<float>(T * N, ok);- if (bf16x2_hc()) { m.xn16_lo = o.take<uint16_t>(T * D, ok); m.lo16_lo = o.take<uint16_t>(T * LR, ok); }- if (bf16x2()) m.mixed_bf_lo = o.take<uint16_t>(T * N, ok);+ if (bf16x2_hc(m.f16_io)) { m.xn16_lo = o.take<uint16_t>(T * D, ok); m.lo16_lo = o.take<uint16_t>(T * LR, ok); }+ if (bf16x2(m.f16_io)) m.mixed_bf_lo = o.take<uint16_t>(T * N, ok);m.steps_dev = o.take<int32_t>(T * strata::kernels::kStepCount, ok);strata::kernels::QsaShapes s = strata::kernels::qsa_real_shapes();s.n_head = g.n_head; s.n_head_kv = g.n_head_kv; s.head_dim = g.head_dim; s.idx_n_head = g.idx_q_heads;@@ -1450,8 +1454,9 @@ uint64_t Prefill::bytes_needed(const core::ModelGeometry& g, const core::Session}o.take<uint16_t>(T * (D + (hc_pad() ? XN_PAD : 0)), ok); f(T * LR); o.take<uint16_t>(T * LR, ok);f(T * D); f(T * HC); f(T * N); o.take<uint16_t>(T * N, ok); o.take<uint16_t>(T * N, ok); f(T * N);- if (bf16x2_hc()) { o.take<uint16_t>(T * D, ok); o.take<uint16_t>(T * LR, ok); }- if (bf16x2()) o.take<uint16_t>(T * N, ok);+ const bool f16_io = prompt_f16(); // the current device's mode (the stage's), as Prefill::init will decide it+ if (bf16x2_hc(f16_io)) { o.take<uint16_t>(T * D, ok); o.take<uint16_t>(T * LR, ok); }+ if (bf16x2(f16_io)) o.take<uint16_t>(T * N, ok);o.take<int32_t>(T * strata::kernels::kStepCount, ok);strata::kernels::QsaShapes s = strata::kernels::qsa_real_shapes();s.n_head = g.n_head; s.n_head_kv = g.n_head_kv; s.head_dim = g.head_dim; s.idx_n_head = g.idx_q_heads;@@ -1999,7 +2004,7 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::striconst auto tp = Clock::now();const strata::kernels::PleWeights& pw = ss.ple.w;constexpr int64_t HD = strata::kernels::NG_HC_DIM;- const uint64_t per_token = (uint64_t) (3 * HD + N + 4) * 4 + (uint64_t) N * (bf16x2() ? 4 : 2) + 4096;+ const uint64_t per_token = (uint64_t) (3 * HD + N + 4) * 4 + (uint64_t) N * (bf16x2(m.f16_io) ? 4 : 2) + 4096;const int64_t SB = std::min<int64_t>(T, (int64_t) (m.region_bytes / per_token));for (int64_t s0 = 0; s0 < T; s0 += SB) {const int64_t nb = std::min(SB, T - s0);@@ -2011,7 +2016,7 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::strifloat* val = carve_f((size_t) nb * N);float* gate = carve_f((size_t) nb * 4);uint16_t* e16 = (uint16_t*) carve_f((size_t) nb * N / 2);- uint16_t* e16_lo = bf16x2() ? (uint16_t*) carve_f((size_t) nb * N / 2) : nullptr;+ uint16_t* e16_lo = bf16x2(m.f16_io) ? (uint16_t*) carve_f((size_t) nb * N / 2) : nullptr;const float* emb = m.ple_emb + s0 * N;if (pw.key_bf16 != nullptr) {to_bf16(emb, e16, nb * N, m.cs, e16_lo);diff --git a/tests/hip/gemm_f16_io_parity.cpp b/tests/hip/gemm_f16_io_parity.cppnew file mode 100644index 000000000..804d66869--- /dev/null+++ b/tests/hip/gemm_f16_io_parity.cpp@@ -0,0 +1,107 @@+// #835: the FP16-in / FP16-out prompt GEMMs (Gemm::set_f16_io, STRATA_HIP_PROMPT_F16=1) against a CPU reference.+// f16() and bf16() (its weights BF16, its activations the FP16 image) write FP16 into Y's own rows and widen them in+// place; the columns past N must stay untouched and a beta = 1 call must keep the ordinary FP32 path. The tolerance+// is FP16's: one rounding of each output.+#include <hip/hip_runtime.h>+#include <hip/hip_bfloat16.h>+#include <hip/hip_fp16.h>+#include "strata/prefill/gemm.hpp"+#include <algorithm>+#include <cmath>+#include <cstdio>+#include <cstdlib>+#include <cstring>+#include <random>+#include <string>+#include <vector>++#define CHECK(call) do { const auto e = (call); if (e != hipSuccess) { \+ std::fprintf(stderr, "%s: %s\n", #call, hipGetErrorString(e)); std::exit(2); } } while (0)++struct Buffer {+ void* p = nullptr;+ explicit Buffer(size_t bytes) { CHECK(hipMalloc(&p, bytes)); }+ ~Buffer() { if (p) (void) hipFree(p); }+};++// bf16_w: the weights are BF16 (the bf16() entry); the activations are always the FP16 image on this path.+bool run(strata::prefill::Gemm& gemm, hipStream_t stream, bool bf16_w, int t, int n, int k, int ldy, float beta) {+ std::mt19937 rng(835 + t + n + (bf16_w ? 1 : 0));+ std::uniform_real_distribution<float> dist(-0.25f, 0.25f);+ std::vector<uint16_t> x((size_t) t * k), w((size_t) n * k);+ std::vector<float> xf(x.size()), wf(w.size());+ for (size_t i = 0; i < x.size(); ++i) {+ const __half v = __float2half_rn(dist(rng));+ std::memcpy(&x[i], &v, 2);+ xf[i] = __half2float(v);+ }+ for (size_t i = 0; i < w.size(); ++i) {+ if (bf16_w) {+ const hip_bfloat16 v(dist(rng));+ w[i] = v.data;+ const uint32_t wide = static_cast<uint32_t>(v.data) << 16;+ std::memcpy(&wf[i], &wide, 4);+ } else {+ const __half v = __float2half_rn(dist(rng));+ std::memcpy(&w[i], &v, 2);+ wf[i] = __half2float(v);+ }+ }+ constexpr int offset = 5;+ std::vector<float> initial(offset + (size_t) t * ldy + 8, -777.25f);+ for (int r = 0; r < t; ++r)+ for (int c = 0; c < n; ++c) initial[offset + (size_t) r * ldy + c] = (r + c) % 17 * 0.03125f;+ Buffer dx(x.size() * 2), dw(w.size() * 2), dy(initial.size() * 4);+ CHECK(hipMemcpyAsync(dx.p, x.data(), x.size() * 2, hipMemcpyHostToDevice, stream));+ CHECK(hipMemcpyAsync(dw.p, w.data(), w.size() * 2, hipMemcpyHostToDevice, stream));+ CHECK(hipMemcpyAsync(dy.p, initial.data(), initial.size() * 4, hipMemcpyHostToDevice, stream));+ if (bf16_w) gemm.bf16((const uint16_t*) dx.p, (const uint16_t*) dw.p, (float*) dy.p + offset, t, n, k, ldy, beta);+ else gemm.f16((const uint16_t*) dx.p, (const uint16_t*) dw.p, (float*) dy.p + offset, t, n, k, ldy, beta);+ CHECK(hipStreamSynchronize(stream));+ std::vector<float> got(initial.size());+ CHECK(hipMemcpy(got.data(), dy.p, got.size() * 4, hipMemcpyDeviceToHost));+ std::vector<bool> active(got.size());+ double diff2 = 0, ref2 = 0, maximum = 0;+ bool ok = true;+ for (int r = 0; r < t; ++r)+ for (int c = 0; c < n; ++c) {+ const size_t j = offset + (size_t) r * ldy + c;+ active[j] = true;+ double ref = beta * initial[j];+ for (int i = 0; i < k; ++i) ref += (double) xf[(size_t) r * k + i] * wf[(size_t) c * k + i];+ const double d = (double) got[j] - ref;+ ok = ok && std::isfinite(got[j]);+ diff2 += d * d;+ ref2 += ref * ref;+ maximum = std::max(maximum, std::abs(d));+ }+ for (size_t j = 0; j < got.size(); ++j)+ if (!active[j]) ok = ok && got[j] == initial[j];+ const double rel = std::sqrt(diff2 / std::max(ref2, 1e-300));+ // one FP16 rounding of the output (beta = 0), or the ordinary FP32 path (beta = 1)+ ok = ok && rel < (beta == 0.0f ? 2e-3 : 1e-4);+ std::printf("%s %s T=%d N=%d K=%d ldy=%d beta=%.1f rel_l2=%.3g max_abs=%.3g\n", ok ? "PASS" : "FAIL",+ bf16_w ? "BF16W" : "F16", t, n, k, ldy, beta, rel, maximum);+ return ok;+}++int main() {+ setvbuf(stdout, nullptr, _IONBF, 0);+ hipStream_t stream;+ CHECK(hipStreamCreateWithFlags(&stream, hipStreamNonBlocking));+ bool ok = true;+ {+ strata::prefill::Gemm gemm;+ std::string error;+ if (!gemm.init(stream, 2560 * 640, error)) { std::fprintf(stderr, "%s\n", error.c_str()); return 2; }+ gemm.set_f16_io(true);+ ok = run(gemm, stream, false, 32, 640, 2560, 648, 0) && ok; // N < ldy: the columns past N stay untouched+ ok = run(gemm, stream, false, 64, 2560, 640, 2560, 0) && ok;+ ok = run(gemm, stream, false, 17, 96, 2560, 96, 0) && ok; // T and N not multiples of the block+ ok = run(gemm, stream, true, 16, 96, 2560, 100, 0) && ok; // BF16 weights through the FP16 scratch+ ok = run(gemm, stream, true, 48, 640, 2560, 640, 0) && ok;+ ok = run(gemm, stream, false, 64, 640, 640, 640, 1) && ok; // beta = 1 keeps the FP32 path+ }+ CHECK(hipStreamDestroy(stream));+ return ok ? 0 : 1;+}