Repository navigation
ggml-cpu: skip x86 variants whose register state the OS has not enabled - #246
Open
alanshurafa wants to merge 3 commits into
Open
alanshurafa wants to merge 3 commits into
alanshurafa wants to merge 3 commits into
Conversation
The CPU backend score checked CPUID feature bits only. On a machine where CPUID advertises AVX-512 but the OS leaves the ZMM state off in XCR0 (seen on Zen 5 Windows, XCR0 = 0x7), the cascadelake variant won and the first 512-bit instruction raised an illegal-instruction fault. Read XCR0 with xgetbv when OSXSAVE is set and score a variant 0 unless the OS enables the state it needs: SSE+YMM for AVX-class variants, opmask+ZMM for AVX-512, XTILECFG+XTILEDATA for AMX. Scores are otherwise unchanged. Fixes cjpais/Handy#2402. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ggml/ is regenerated by scripts/sync-ggml.sh from the upstream SHA plus patches/ggml/*.patch; without a patch file the cpu-feats.cpp fix would be dropped on the next sync. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
macOS enables AVX-512 register state lazily, so XCR0 bits 5-7 are clear until a thread first uses AVX-512. The XCR0 check therefore rejected the AVX-512 variants on Intel Macs that support them. On Apple, take AVX-512 OS support from hw.optional.avx512f instead, as google/cpu_features does. Also mark `is` unused for the x64 variant, which checks no CPUID bits and otherwise warns under -Wextra. Patch 0004 regenerated to match.
alanshurafa
marked this pull request as ready for review
November 6, 2026 18:33
alanshurafa
added a commit
to alanshurafa/transcribe.cpp
that referenced
this pull request
Nov 7, 2026
…ter#246's 0004 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Handy no longer fails to load any model on newer AMD processors where Windows hasn't switched on the chip's advanced math features.
ggml_backend_cpu_x86_score()only checks CPUID, so it picksggml-cpu-cascadelake.dll; the first 512-bit instruction faults (0xC000001D).xgetbvwhen OSXSAVE is set, and score a variant 0 if the OS hasn't enabled the state it needs (YMM for AVX, opmask + ZMM for AVX-512, tiles for AMX).Scope
ggml/src/ggml-cpu/arch/x86/cpu-feats.cpp: the fix.patches/ggml/0004-cpu-x86-score-os-xsave-check.patch+ggml/UPSTREAM: same change as a downstream patch sosync-ggml.shkeeps it.Related
Fixes cjpais/Handy#2402. Measurements from
fakingpescobar-ctrlin that issue.Not fixed in llama.cpp master yet; open PRs there: ggml-org/llama.cpp#19514, #20388, #20940.
AI Assistance
Code written with Claude Code; I reviewed it.
Validation
Harness compiling patched and original
cpu-feats.cppper variant (MSVC 2022, sameGGML_*defines), with XCR0 injected:alderlake(waszen4).sse42.git apply --check, forward and reverse.Not run: full library build, repo tests, GCC/Clang
xgetbvpath, real Zen 5 hardware.🤖 Generated with Claude Code