Skip to content

Disable SSE4.2 in noavx native builds - #1438

Merged
martindevans merged 3 commits into
SciSharp:masterfrom
modelpath-dev:fix/1422-noavx-sse42
Sep 12, 2026
Merged

martindevans merged 3 commits into
SciSharp:masterfrom
modelpath-dev:fix/1422-noavx-sse42

Conversation

@modelpath-dev

@modelpath-dev modelpath-dev commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The published noavx CPU backend still compiles with -msse4.2. ggml turns GGML_SSE42 on for a normal (non-cross) compile even when GGML_NATIVE=OFF.
  • That is an illegal instruction on CPUs that stop at SSSE3, which is the crash in Getting a Illegal instruction (core dumped) when trying to run聽#1422. lscpu there has no avx, sse4_1, or sse4_2.
  • noavx jobs on Linux, musl, Windows, and the macOS x64 Rosetta build now pass -DGGML_SSE42=OFF. gcc/clang jobs also pin -march=x86-64 so auto-vectorization cannot put SSE4 back in. MSVC only gets the CMake flag.

Test plan

  • Configure current llama.cpp with the old noavx flags. CMake prints Adding CPU backend variant ggml-cpu: -msse4.2 GGML_SSE42.
  • Configure with the new flags. CMake prints an empty CPU variant and GGML_SSE42=OFF.
  • objdump of libggml-cpu.so: old build contains pblendvb / pinsrd (SSE4.1). New build does not.
  • After the next Update Binaries run and a new LLamaSharp.Backend.Cpu publish, Getting a Illegal instruction (core dumped) when trying to run聽#1422 should load without SIGILL. Until then the FAQ notes the self-compile path.

ggml still enables SSE4.2 on a non-cross compile even with GGML_NATIVE=OFF,
so the current noavx binaries SIGILL on SSSE3-only CPUs.
@martindevans

Copy link
Copy Markdown
Member

Thanks for putting this together, it all looks good to me.

Could you please trigger a test action run on your fork (I can't do it in this repo until it's merged).

To do that:

  1. Go to "Actions" tab in your fork
  2. Select "Update Binaries" in the list on the left
  3. Click "Run Workflow" (top right of the action panel)
  4. Link the action run here

@modelpath-dev

Copy link
Copy Markdown
Contributor Author

Triggered Update Binaries on the fork from this branch (fix/1422-noavx-sse42, llama.cpp master):

https://github.com/modelpath-dev/LLamaSharp/actions/runs/34667855880

windows-latest is VS 18, where ClangCL rebuilds ggml-cpu against a C17 PCH
with C17 disabled, so llama.dll is never produced and artifact upload fails.
ggml-cpu fails with a C17 PCH mismatch on both windows-latest and
windows-2022, so llama.dll is never produced. Also fail the job when
cmake --build fails instead of hiding it behind tree.
@modelpath-dev

Copy link
Copy Markdown
Contributor Author

Update Binaries completed successfully on the fork from this branch:

https://github.com/modelpath-dev/LLamaSharp/actions/runs/34669867568

llama.cpp d3146f2 (master at dispatch). Every compile job and Gather Binaries passed, including Linux/Windows/musl noavx with SSE4.2 off.

The first run failed on Windows ARM64 only. ClangCL + CMake PCH disagrees on C17 for ggml-cpu, so llama.dll was never produced. That is unrelated to the noavx flags. I pinned that job to windows-2022 and set CMAKE_DISABLE_PRECOMPILE_HEADERS=ON so the ARM64 artifact builds.

@martindevans
martindevans self-requested a review September 12, 2026 14:05

@martindevans martindevans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for working on this! Ready to merge once the CI passes :)

@martindevans
martindevans merged commit 59dc975 into SciSharp:master Sep 12, 2026
8 of 9 checks passed
@modelpath-dev

Copy link
Copy Markdown
Contributor Author

@martindevans

Hi Martin, thanks again for the thorough review on this one. Walking through the noavx native builds and the fork CI runs taught me a lot about how the binary pipeline fits together. I would like to keep contributing to LLamaSharp, especially around native builds and packaging.

I am currently looking for a role, so if there is ever build or maintenance work you would like a hand with, I would be glad to help. Either way, I will keep an eye on the open issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants