Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
CPU / GPU fixes + harness for upstream ggml's test-backend-ops (#1004)
Davide Eynard92174c7a7386
diff --git a/docs/building_dlls.md b/docs/building_dlls.mdindex ca6455e5..e33cc994 100644--- a/docs/building_dlls.md+++ b/docs/building_dlls.md@@ -74,3 +74,36 @@ At the end of this process, you should have the following libraries available in```To run llamafile with these libraries, add them in your home directory or bundle them in your llamafile (see [Creating a llamafile](creating_llamafiles.md)).++## Verifying numerical consistency (release gate)++Before shipping a GPU library, verify that it computes the same results as+the CPU reference. The `backend_ops_test` harness wires upstream ggml's+`test-backend-ops` into llamafile's real runtime loading path (cosmo_dlopen++ ms_abi thunks), so it validates the actual DSO artifact and ABI boundary.++Build it once (it is not part of the default test suite):++```+make o//tests/backend_ops_test+```++Copy `o//tests/backend_ops_test` next to the DSO(s) on the target machine+(rename to `backend_ops_test.exe` on Windows) and run the fast subset:++```+backend_ops_test test -o MUL_MAT+backend_ops_test test -o MUL_MAT_ID+backend_ops_test test -o FLASH_ATTN_EXT+```++A full `backend_ops_test test` run covers every op and takes much longer.+Every backend DSO present is loaded and tested; the summary at the end must+report all backends passing.++If a mismatch appears, attribute it before blaming the GPU: the CPU+reference itself goes through llamafile's tinyBLAS/iqk fast path. Rerun+with `LLAMAFILE_DISABLE_SGEMM=1` to compare against vanilla ggml — if the+failures disappear, the bug is in llamafile's CPU kernels, not the GPU+library (this is how the iq4_xs, bf16, and permuted-stride CPU bugs were+found).diff --git a/llamafile/iqk_mul_mat.inc b/llamafile/iqk_mul_mat.incindex dbcbba78..8ea8ab23 100644--- a/llamafile/iqk_mul_mat.inc+++ b/llamafile/iqk_mul_mat.inc@@ -768,6 +768,27 @@ inline void multiply_add(const Bits& bits, const __m256i * scales, int j, int i,}}+// Like multiply_add, but for signed int8 values (iq4_xs). maddubs needs an+// unsigned first operand, so multiply |v| by sign(v)*q8; pair sums stay+// within int16 range because |v| <= 127.+template <typename Q8, typename Bits>+inline void multiply_add_iq4xs(const Bits& bits, const __m256i * scales, int j, int i, const Q8& q8, __m256i * sumi) {+ for (int iy = 0; iy < Q8::nrc_y; ++iy) {+ __m256i p[4];+ for (int k = 0; k < 4; ++k) {+ const __m256i av = _mm256_sign_epi8(bits.values[k], bits.values[k]);+ const __m256i sy = _mm256_sign_epi8(q8.load_quants(iy, i, 4*j+k), bits.values[k]);+ p[k] = _mm256_madd_epi16(scales[k], _mm256_maddubs_epi16(av, sy));+ }+ if (j == 0) {+ sumi[iy] = _mm256_add_epi32(_mm256_add_epi32(p[0], p[2]), _mm256_add_epi32(p[1], p[3]));+ } else {+ sumi[iy] = _mm256_add_epi32(sumi[iy], _mm256_add_epi32(p[0], p[2]));+ sumi[iy] = _mm256_add_epi32(sumi[iy], _mm256_add_epi32(p[1], p[3]));+ }+ }+}+struct DequantizerQ4K final : public BaseDequantizer<block_q4_K> {DequantizerQ4K(const void * vx, size_t bx) : BaseDequantizer(vx, bx) {}template <typename Q8>@@ -789,7 +810,6 @@ struct DequantizerIQ4XS final : public BaseDequantizer<block_iq4_xs> {inline __m256i new_block(int i, const Q8& q8, __m256 * accd) {d = GGML_FP16_TO_FP32(x[i].d);auto scales128 = siq4.make_scales(*(const uint32_t *)x[i].scales_l, x[i].scales_h);- s8k.accum_mins(scales128, q8, i, -128.f*d, accd);return MM256_SET_M128I(scales128, scales128);}inline void prepare(int i, int j) {@@ -801,13 +821,17 @@ struct DequantizerIQ4XS final : public BaseDequantizer<block_iq4_xs> {}static __m256i load_values() {- static const uint8_t kvalues_iq4nl[16] = {1, 24, 45, 63, 79, 93, 106, 118, 129, 141, 153, 166, 181, 197, 217, 241};+ // Signed iq4_nl values. The +128 offset trick used on the AVX-512+ // (FANCY_SIMD) path is not usable here: _mm256_maddubs_epi16 pair+ // sums of offset values (up to 241) times q8 (up to 127) overflow+ // and saturate int16 (2*241*127 > 32767). Signed values stay within+ // range with the sign trick in multiply_add_iq4xs.+ static const int8_t kvalues_iq4nl[16] = {-127, -104, -83, -65, -49, -35, -22, -10, 1, 13, 25, 38, 53, 69, 89, 113};auto val128 = _mm_loadu_si128((const __m128i *)kvalues_iq4nl);return MM256_SET_M128I(val128, val128);}Q4Bits bits;- Scales8K s8k;ScaleIQ4XS siq4;const __m256i values;};@@ -992,7 +1016,11 @@ static void mul_mat_qX_K_q8_K_T(int n, const void * vx, size_t bx, const DataInfset_scales_8(all_scales, j, scales);- multiply_add(deq.bits, scales, j, i, q8, sumi);+ if constexpr (std::is_same_v<Dequantizer, DequantizerIQ4XS>) {+ multiply_add_iq4xs(deq.bits, scales, j, i, q8, sumi);+ } else {+ multiply_add(deq.bits, scales, j, i, q8, sumi);+ }}diff --git a/llamafile/tinyblas_cpu_mixmul.inc b/llamafile/tinyblas_cpu_mixmul.incindex 18b0bcfe..69a5b815 100644--- a/llamafile/tinyblas_cpu_mixmul.inc+++ b/llamafile/tinyblas_cpu_mixmul.inc@@ -251,14 +251,16 @@ class MixMul {#endifcase GGML_TYPE_Q1_0:- // Upstream Q1_0 uses 128-element blocks (QK1_0=128)+ // Upstream Q1_0 uses 128-element blocks (QK1_0=128), so the+ // BS template arg must be 128: mixmat passes cols/BS as the+ // kernel's per-row block count.if (thought->type != GGML_TYPE_F32 && thought->type != GGML_TYPE_Q8_0)return false;#if defined(__AVX2__) || defined(__AVX512F__)- return mixmat<32, 32, tinyBLAS_Q0_g128_AVX2<NCB | NCC, TC>,+ return mixmat<128, 128, tinyBLAS_Q0_g128_AVX2<NCB | NCC, TC>,block_q1_0, block_q8_0, TC>();#elif defined(__ARM_FEATURE_DOTPROD)- return mixmat<32, 32, tinyBLAS_Q0_g128_ARM<NCB | NCC, TC>,+ return mixmat<128, 128, tinyBLAS_Q0_g128_ARM<NCB | NCC, TC>,block_q1_0, block_q8_0, TC>();#elsereturn false;diff --git a/llamafile/tinyblas_cpu_sgemm.inc b/llamafile/tinyblas_cpu_sgemm.incindex c1fc3d2c..38049548 100644--- a/llamafile/tinyblas_cpu_sgemm.inc+++ b/llamafile/tinyblas_cpu_sgemm.inc@@ -95,8 +95,18 @@ bool llamafile_sgemm_impl(long m, long n, long k, const void *A, long lda, constreturn true;}#elif defined(__AVX512F__)- tinyBLAS<0, 16, __m512, __m512, ggml_bf16_t, float, TC> tb{- k, (const ggml_bf16_t *)A, lda, (const float *)B, ldb, C, ldc, ith, nth};+ if (Btype == GGML_TYPE_F32) {+ tinyBLAS<0, 16, __m512, __m512, ggml_bf16_t, float, TC> tb{+ k, (const ggml_bf16_t *)A, lda, (const float *)B, ldb, C, ldc, ith, nth};+ tb.matmul(m, n);+ return true;+ }+ // ggml-cpu may hand us B converted to the bf16 vec_dot_type (e.g. when+ // src1 is not contiguous); reading that buffer as f32 yields garbage.+ if (Btype != GGML_TYPE_BF16)+ return NOT_SUPPORTED;+ tinyBLAS<0, 16, __m512, __m512, ggml_bf16_t, ggml_bf16_t, TC> tb{+ k, (const ggml_bf16_t *)A, lda, (const ggml_bf16_t *)B, ldb, C, ldc, ith, nth};tb.matmul(m, n);return true;#elif defined(__AVX2__)@@ -304,8 +314,15 @@ bool llamafile_sgemm(long m, long n, long k, const void *A, long lda, const voidassert(nth > 0);assert(ith < nth);+ // iqk_mul_mat has no lda/ldb parameters and assumes densely packed rows.+ // Permuted or viewed tensors (e.g. ggml_permute'd src0) arrive with a+ // larger row stride, so route those to the stride-aware kernels below+ // or back to vanilla ggml.+ const bool dense_rows = (lda == k && ldb == k);+ (void)dense_rows; // unused on ISAs without an iqk_mul_mat shortcut+#if defined(__x86_64__)- if (X86_CHECK(AVX2) && X86_CHECK(FMA)) {+ if (dense_rows && X86_CHECK(AVX2) && X86_CHECK(FMA)) {if (Btype == GGML_TYPE_Q8_K && Ctype == GGML_TYPE_F32) {if (iqk_mul_mat(m, n, k * QK_K, Atype, A, B, (float *)C, ldc, ith, nth)) {return true;@@ -324,12 +341,12 @@ bool llamafile_sgemm(long m, long n, long k, const void *A, long lda, const void}}#elif defined __aarch64__ && defined __ARM_FEATURE_DOTPROD && !defined _MSC_VER- if (Btype == GGML_TYPE_Q8_K && Ctype == GGML_TYPE_F32) {+ if (dense_rows && Btype == GGML_TYPE_Q8_K && Ctype == GGML_TYPE_F32) {if (iqk_mul_mat(m, n, k * QK_K, Atype, A, B, (float *)C, ldc, ith, nth)) {return true;}}- if ((Btype == GGML_TYPE_Q8_0 || Btype == GGML_TYPE_Q8_1) && Ctype == GGML_TYPE_F32) {+ if (dense_rows && (Btype == GGML_TYPE_Q8_0 || Btype == GGML_TYPE_Q8_1) && Ctype == GGML_TYPE_F32) {assert(QK8_0 == 32 && //QK8_1 == 32 && //QK4_0 == 32 && //diff --git a/llamafile/vulkan.bat b/llamafile/vulkan.batindex 53f941ad..44f622c2 100644--- a/llamafile/vulkan.bat+++ b/llamafile/vulkan.bat@@ -143,6 +143,39 @@ pushd "%LLAMA_CPP_DIR%\ggml" 2>nul && (popd)+:: -------- probe glslc shader extension support --------+:: Mirrors upstream CMake's test_shader_extension_support: these defines+:: gate which shader variants vulkan-shaders-gen emits and which pipelines+:: ggml-vulkan.cpp creates, so they must reflect the actual glslc on this+:: machine. Omitting them silently drops coopmat/coopmat2/decode-vector/+:: integer-dot/bf16 support from the DLL. Keep this list in sync with+:: upstream's test_shader_extension_support() calls in+:: ggml-vulkan/CMakeLists.txt.+set "FEATURE_TESTS_DIR=%SHADERS_DIR%\feature-tests"+set "GLSLC_DEFINES="+echo Probing glslc shader extension support...+call :probe_glslc coopmat.comp GGML_VULKAN_COOPMAT_GLSLC_SUPPORT+call :probe_glslc coopmat2.comp GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT+call :probe_glslc coopmat2_decode_vector.comp GGML_VULKAN_COOPMAT2_DECODE_VECTOR_GLSLC_SUPPORT+call :probe_glslc integer_dot.comp GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT+call :probe_glslc bfloat16.comp GGML_VULKAN_BFLOAT16_GLSLC_SUPPORT+echo.++:: The defines bake into vulkan-shaders-gen, the generated header, and every+:: cached artifact derived from them; invalidate the cache when they change.+set "FEATURES_STAMP=%BUILD_DIR%\glslc-features.txt"+set "OLD_DEFINES="+if exist "%FEATURES_STAMP%" set /p OLD_DEFINES=<"%FEATURES_STAMP%"+if not "!OLD_DEFINES!"=="!GLSLC_DEFINES!" (+ echo glslc feature set changed; clearing cached shader artifacts+ del /q "%BUILD_DIR%\vulkan-shaders-gen.exe" "%BUILD_DIR%\ggml-vulkan-shaders.hpp" "%BUILD_DIR%\ggml-vulkan.obj" "%BUILD_DIR%\shader-*.obj" 2>nul+ if exist "%SHADERS_BUILD_DIR%" rmdir /s /q "%SHADERS_BUILD_DIR%"+ if exist "%SPVDIR%" rmdir /s /q "%SPVDIR%"+ mkdir "%SHADERS_BUILD_DIR%" 2>nul+ mkdir "%SPVDIR%" 2>nul+ >"%FEATURES_STAMP%" echo(!GLSLC_DEFINES!+)+echo Building ggml-vulkan.dll...echo Version: !GGML_VERSION! (commit: !GGML_COMMIT!)echo Source: %GGML_VULKAN_DIR%@@ -162,7 +195,7 @@ set "SHADERS_GEN_SRC=%SHADERS_DIR%\vulkan-shaders-gen.cpp"if not exist "%SHADERS_GEN%" (echo Compiling vulkan-shaders-gen.cpp...- cl /nologo /EHsc /O2 /std:c++17 /Fe:"%SHADERS_GEN%" "%SHADERS_GEN_SRC%"+ cl /nologo /EHsc /O2 /std:c++17 !GLSLC_DEFINES! /Fe:"%SHADERS_GEN%" "%SHADERS_GEN_SRC%"if errorlevel 1 (echo Error: failed to build vulkan-shaders-gen.exe & exit /b 1):: Clean up .obj left by cldel /q vulkan-shaders-gen.obj 2>nul@@ -223,7 +256,7 @@ echo Phase 4: Compiling shader C++ files...set "CXX_FLAGS=/c /nologo /EHsc /O2 /GR /MT /std:c++17 /Zc:preprocessor"set "CXX_FLAGS=%CXX_FLAGS% /I"%GGML_INC_DIR%" /I"%GGML_SRC_DIR%" /I"%BUILD_DIR%""-set "CXX_FLAGS=%CXX_FLAGS% /DNDEBUG /DGGML_BUILD=1 /DGGML_SHARED=1 /DGGML_BACKEND_SHARED=1 /DGGML_BACKEND_BUILD=1 /DGGML_MULTIPLATFORM"+set "CXX_FLAGS=%CXX_FLAGS% /DNDEBUG /DGGML_BUILD=1 /DGGML_SHARED=1 /DGGML_BACKEND_SHARED=1 /DGGML_BACKEND_BUILD=1 /DGGML_MULTIPLATFORM!GLSLC_DEFINES!"set "CPP_CMD_FILE=%BUILD_DIR%\cpp_cmds.txt"type nul > "%CPP_CMD_FILE%"@@ -329,3 +362,16 @@ for %%f in ("%OUTPUT%") do echo Size: %%~zf bytesecho.endlocal+exit /b 0++:: Probe one glslc shader extension: %1 = feature-test shader filename,+:: %2 = define to append to GLSLC_DEFINES when supported.+:probe_glslc+"%GLSLC%" -o NUL -fshader-stage=compute --target-env=vulkan1.3 "%FEATURE_TESTS_DIR%\%~1" >nul 2>&1+if errorlevel 1 (+ echo %~1: not supported by glslc+) else (+ set "GLSLC_DEFINES=!GLSLC_DEFINES! /D%~2"+ echo %~1: supported+)+exit /b 0diff --git a/llamafile/vulkan.sh b/llamafile/vulkan.shindex f1824a1f..c0dd7e50 100755--- a/llamafile/vulkan.sh+++ b/llamafile/vulkan.sh@@ -142,6 +142,47 @@ echo ""START_TIME=$(date +%s)+#+# Probe glslc shader extension support (mirrors upstream CMake's+# test_shader_extension_support). These defines gate which shader variants+# vulkan-shaders-gen emits and which pipelines ggml-vulkan.cpp creates, so+# they must reflect the actual glslc on this machine. Omitting them+# silently drops coopmat/coopmat2/decode-vector/integer-dot/bf16 support+# from the DLL. Keep this list in sync with upstream's+# test_shader_extension_support() calls in ggml-vulkan/CMakeLists.txt.+#+GLSLC_DEFINES=""+FEATURE_TESTS_DIR="$SHADERS_DIR/feature-tests"+probe_glslc_extension() {+ # $1 = feature test shader, $2 = define+ if "$GLSLC" -o /dev/null -fshader-stage=compute --target-env=vulkan1.3 \+ "$FEATURE_TESTS_DIR/$1" >/dev/null 2>&1; then+ GLSLC_DEFINES="$GLSLC_DEFINES -D$2"+ echo " $1: supported"+ else+ echo " $1: not supported by glslc"+ fi+}+echo "Probing glslc shader extension support..."+probe_glslc_extension coopmat.comp GGML_VULKAN_COOPMAT_GLSLC_SUPPORT+probe_glslc_extension coopmat2.comp GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT+probe_glslc_extension coopmat2_decode_vector.comp GGML_VULKAN_COOPMAT2_DECODE_VECTOR_GLSLC_SUPPORT+probe_glslc_extension integer_dot.comp GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT+probe_glslc_extension bfloat16.comp GGML_VULKAN_BFLOAT16_GLSLC_SUPPORT+echo ""++# The defines bake into vulkan-shaders-gen, the generated header, and every+# cached artifact derived from them; invalidate the cache when they change.+FEATURES_STAMP="$BUILD_DIR/glslc-features.txt"+if [ ! -f "$FEATURES_STAMP" ] || [ "$(cat "$FEATURES_STAMP" 2>/dev/null)" != "$GLSLC_DEFINES" ]; then+ echo "glslc feature set changed; clearing cached shader artifacts"+ rm -f "$BUILD_DIR/vulkan-shaders-gen" "$BUILD_DIR/ggml-vulkan-shaders.hpp" "$BUILD_DIR/ggml-vulkan.o"+ rm -rf "$SHADERS_BUILD_DIR" "$SPVDIR"+ mkdir -p "$SHADERS_BUILD_DIR" "$SPVDIR"+ rm -f "$BUILD_DIR"/shader-*.o+ printf '%s' "$GLSLC_DEFINES" > "$FEATURES_STAMP"+fi+## Phase 1: Build vulkan-shaders-gen tool#@@ -152,7 +193,7 @@ SHADERS_GEN_BIN="$BUILD_DIR/vulkan-shaders-gen"if [ ! -f "$SHADERS_GEN_BIN" ] || [ "$SHADERS_GEN_SRC" -nt "$SHADERS_GEN_BIN" ]; thenecho " Compiling vulkan-shaders-gen.cpp..."- $CXX -std=c++17 -O2 -o "$SHADERS_GEN_BIN" "$SHADERS_GEN_SRC" -lpthread+ $CXX -std=c++17 -O2 $GLSLC_DEFINES -o "$SHADERS_GEN_BIN" "$SHADERS_GEN_SRC" -lpthreadelseecho " vulkan-shaders-gen is up to date"fi@@ -236,7 +277,8 @@ CXX_FLAGS="-O2 -fPIC -std=c++17 \-DNDEBUG \-DGGML_BUILD=1 \-DGGML_SHARED=1 \- -DGGML_MULTIPLATFORM"+ -DGGML_MULTIPLATFORM \+ $GLSLC_DEFINES"count=0for src in $SHADER_CPP_FILES; dodiff --git a/tests/BUILD.mk b/tests/BUILD.mkindex 5bec12d3..335dead9 100644--- a/tests/BUILD.mk+++ b/tests/BUILD.mk@@ -120,6 +120,42 @@ o/$(MODE)/tests/gpu_backend_test: \@mkdir -p $(@D)$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)+# ==============================================================================+# Test: backend_ops_test (upstream ggml test-backend-ops under llamafile)+# ==============================================================================+#+# Compares every ggml op on each runtime-loaded GPU backend against the CPU+# reference (NMSE thresholds). Used to verify numerical consistency of the+# dlopen'd backend DSOs (e.g. CPU vs Vulkan matmuls, issue #938 follow-up).+# Not part of the default check suite: it needs a GPU and the backend DSO at+# runtime. Build with: make o/$(MODE)/tests/backend_ops_test++# upstream test uses #include <ggml.h>, so the ggml include dirs must be on+# the system search path (-iquote from LLAMAFILE_INCLUDES is not enough)+BACKEND_OPS_INCLUDES := \+ -isystem llama.cpp/ggml/include \+ -isystem llama.cpp/include++o/$(MODE)/tests/test_backend_ops_impl.o: llama.cpp/tests/test-backend-ops.cpp+ @mkdir -p $(@D)+ $(CXX) $(CXXFLAGS) $(TESTS_CPPFLAGS) $(BACKEND_OPS_INCLUDES) -Dmain=backend_ops_main -c -o $@ $<++o/$(MODE)/tests/backend_ops_harness.o: tests/backend_ops_harness.cpp+ @mkdir -p $(@D)+ $(CXX) $(CXXFLAGS) $(TESTS_CPPFLAGS) -c -o $@ $<++o/$(MODE)/tests/backend_ops_test: \+ o/$(MODE)/tests/backend_ops_harness.o \+ o/$(MODE)/tests/test_backend_ops_impl.o \+ o/$(MODE)/llamafile/llamafile.o \+ o/$(MODE)/llamafile/gpu.a \+ o/$(MODE)/llamafile/zip.o \+ o/$(MODE)/llamafile/check_cpu.o \+ $(GGML_OBJS) \+ $(TINYBLAS_CPU_OBJS)+ @mkdir -p $(@D)+ $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)+# ==============================================================================# Phony targets# ==============================================================================diff --git a/tests/backend_ops_harness.cpp b/tests/backend_ops_harness.cppnew file mode 100644index 00000000..be27817c--- /dev/null+++ b/tests/backend_ops_harness.cpp@@ -0,0 +1,78 @@+// -*- mode:c++;indent-tabs-mode:nil;c-basic-offset:4;coding:utf-8 -*-+// vi: set et ft=cpp ts=4 sts=4 sw=4 fenc=utf-8 :vi+//+// Copyright 2026 Mozilla.ai+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++// Harness for upstream ggml's test-backend-ops under llamafile.+//+// Upstream test-backend-ops compares every ggml op (all MUL_MAT quant+// variants included) computed on each registered backend against the CPU+// reference, with NMSE thresholds. Upstream registers GPU backends at+// static-init time; llamafile instead loads them at runtime through the+// dlopen probe path (llamafile_has_* -> gpu_backend_register). This+// wrapper performs those loads, then delegates to the upstream test's+// main, which is compiled with -Dmain=backend_ops_main.+//+// Every backend DSO found at runtime (next to the executable or in+// ~/.llamafile/v/<version>/) is loaded and tested, so the same binary+// serves as the consistency gate for Vulkan, CUDA, ROCm, and Metal+// artifacts. Backends that fail to load are reported and skipped.+//+// Caveat: the CPU reference itself goes through llamafile's tinyBLAS/iqk+// fast path (GGML_USE_LLAMAFILE), so a mismatch can be a CPU-side bug as+// well as a GPU-side one. Run with LLAMAFILE_DISABLE_SGEMM=1 to fall back+// to vanilla ggml when attributing a failure to one side or the other+// (that toggle is how the iq4_xs/bf16 CPU bugs were isolated).+//+// Usage matches upstream, e.g.:+// backend_ops_test test -o MUL_MAT+// backend_ops_test test -b Vulkan0+// backend_ops_test test # full op suite, all backends++#include <cstdio>++#include "llamafile.h"++int backend_ops_main(int argc, char **argv);++int main(int argc, char **argv) {+ FLAG_verbose = 1; // show the probe path so DSO-resolution issues are visible++ struct {+ const char *name;+ bool (*probe)(void);+ } backends[] = {+ {"metal", llamafile_has_metal},+ {"cuda", llamafile_has_cuda},+ {"rocm", llamafile_has_amd_gpu},+ {"vulkan", llamafile_has_vulkan},+ };++ int loaded = 0;+ for (const auto &b : backends) {+ if (b.probe()) {+ fprintf(stderr, "backend_ops_harness: %s backend loaded\n", b.name);+ loaded++;+ } else {+ fprintf(stderr, "backend_ops_harness: %s backend not available\n", b.name);+ }+ }+ if (!loaded)+ fprintf(stderr,+ "backend_ops_harness: WARNING: no GPU backend loaded; "+ "only CPU will be tested\n");++ return backend_ops_main(argc, argv);+}