Skip to content

Commit e72c855

Browse files
sepion02claude
andcommitted
fix(stt): stop compiling the shipped whisper helper for the build machine
GGML_NATIVE was ON under a comment claiming it produced a "+avx2 +fma +f16c" baseline. It does not: ggml turns GGML_NATIVE=ON into `-march=native`, so the CPU backend targets whatever CPU ran the build. build-whisper-stt.yml builds the shipped binaries on GitHub-hosted runners, whose x64 images are Xeons with AVX-512 — so a published artifact could carry AVX-512 and die with SIGILL on every AMD before Zen 4 and every Intel consumer part since Alder Lake, and the baseline shifted silently with whatever hardware picked up the job. Same class of bug as the OpenSSL note: an artifact whose contents depend on the machine that built it. Turning GGML_NATIVE off is necessary but not sufficient. ggml derives its instruction-set options from INS_ENB via `option()`, which only seeds a value the first time a build tree is configured — a cache written while NATIVE was ON keeps GGML_AVX2=OFF, and the result is a plain x86-64 binary with no AVX2 at all. Verified: that path produced zero %ymm instructions. So pin the baseline explicitly instead of inheriting it. Ships SSE4.2 + AVX + AVX2 + BMI2 + FMA + F16C, x86-64 hosts only, AVX-512 deliberately excluded. That is the Haswell/Zen 1 floor the installer already requires. OSC_NATIVE_CPU=ON restores -march=native for local benchmarking. Verified on linux-x64: `-msse4.2 -mf16c -mfma -mbmi2 -mavx -mavx2`, 12744 %ymm instructions, 0 %zmm, and the helper still transcribes on Vulkan. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent e06871f commit e72c855

1 file changed

Lines changed: 37 additions & 7 deletions

File tree

electron/native/whisper-stt/CMakeLists.txt

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,43 @@ set(FETCHCONTENT_QUIET OFF)
4646
# at the cost of a larger single binary. Mirrors the working POC build.
4747
set(GGML_BACKEND_DL OFF CACHE BOOL "" FORCE)
4848
set(GGML_CPU_ALL_VARIANTS OFF CACHE BOOL "" FORCE)
49-
# GGML_NATIVE compiles for this dev machine's CPU arch (Zen 2 on AMD Ryzen
50-
# 5 7520U). This is what llama.cpp ships by default and it produces one
51-
# `ggml-cpu` library statically linked into `ggml.dll`. The `+avx2 +fma
52-
# +f16c` baseline is broad enough to cover every x86 CPU OpenScreen
53-
# supports (the OpenScreen installer currently does not run on
54-
# pre-Haswell/AMD-Bulldozer hardware).
55-
set(GGML_NATIVE ON CACHE BOOL "" FORCE)
49+
# ponytail: this was ON, under a comment claiming it produced a "+avx2 +fma
50+
# +f16c" baseline. It does not. GGML_NATIVE=ON makes ggml compile the CPU
51+
# backend with `-march=native` (ggml/src/ggml-cpu/CMakeLists.txt), i.e. for
52+
# whichever CPU happened to run the build. `.github/workflows/build-whisper-stt.yml`
53+
# builds the shipped binaries on GitHub-hosted runners, and the x64 images are
54+
# Xeons that carry AVX-512, so a published artifact could contain AVX-512 and
55+
# die with SIGILL on every AMD before Zen 4 and every Intel consumer part since
56+
# Alder Lake — while the baseline silently shifted with whatever hardware
57+
# picked up the job. Same class of bug as the OpenSSL note below: an artifact
58+
# whose contents are a function of the build machine.
59+
#
60+
# OFF is what actually yields the intended baseline. ggml then sets INS_ENB=ON,
61+
# which defaults GGML_SSE42/AVX/AVX2/BMI2/FMA/F16C to ON and leaves every
62+
# GGML_AVX512* OFF — Haswell/Zen 1 and newer, which is what the installer
63+
# already requires. This backend is only the fallback for hosts with no usable
64+
# GPU backend, so the cost is marginal and the artifact becomes reproducible.
65+
#
66+
# OSC_NATIVE_CPU is the escape hatch for local benchmarking. It must never be
67+
# set for anything that gets shipped.
68+
option(OSC_NATIVE_CPU "Tune the CPU backend for this machine (-march=native); local builds only" OFF)
69+
if(OSC_NATIVE_CPU)
70+
set(GGML_NATIVE ON CACHE BOOL "" FORCE)
71+
else()
72+
set(GGML_NATIVE OFF CACHE BOOL "" FORCE)
73+
# Pin the baseline rather than inheriting ggml's INS_ENB defaults. `option()`
74+
# only seeds a value the first time a build tree is configured, so a cache
75+
# that was written while GGML_NATIVE was ON keeps GGML_AVX2=OFF forever and
76+
# quietly downgrades the result to plain x86-64 — no AVX2 at all, which is
77+
# slower than what this project shipped before. Being explicit also states
78+
# the contract in one place instead of leaving it to an upstream default.
79+
# AVX-512 stays off: that is the part that does not run everywhere.
80+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64)$")
81+
foreach(osc_isa SSE42 AVX AVX2 BMI2 FMA F16C)
82+
set(GGML_${osc_isa} ON CACHE BOOL "" FORCE)
83+
endforeach()
84+
endif()
85+
endif()
5686
set(WHISPER_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
5787
set(WHISPER_BUILD_TESTS OFF CACHE BOOL "" FORCE)
5888
set(WHISPER_BUILD_SERVER OFF CACHE BOOL "" FORCE)

0 commit comments

Comments
 (0)