Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ jobs:
fail-fast: true
matrix:
include:
# SSE4.2 stays on unless we disable it; that SIGILLs pre-Nehalem CPUs (#1422).
# -march=x86-64 stops gcc from emitting SSE4 via auto-vectorization.
- build: 'noavx'
defines: '-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF -DGGML_BMI2=OFF'
defines: '-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF -DGGML_BMI2=OFF -DGGML_SSE42=OFF -DCMAKE_C_FLAGS=-march=x86-64 -DCMAKE_CXX_FLAGS=-march=x86-64'
os: ubuntu-22.04
arch: x64
- build: 'avx2'
Expand Down Expand Up @@ -95,7 +97,7 @@ jobs:
matrix:
include:
- build: 'noavx'
defines: '-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF -DGGML_BMI2=OFF'
defines: '-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF -DGGML_BMI2=OFF -DGGML_SSE42=OFF -DCMAKE_C_FLAGS=-march=x86-64 -DCMAKE_CXX_FLAGS=-march=x86-64'
- build: 'avx2'
defines: ''
- build: 'avx'
Expand Down Expand Up @@ -160,7 +162,7 @@ jobs:
matrix:
include:
- build: 'noavx'
defines: '-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF -DGGML_BMI2=OFF'
defines: '-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF -DGGML_BMI2=OFF -DGGML_SSE42=OFF'
- build: 'avx2'
defines: ''
- build: 'avx'
Expand Down Expand Up @@ -222,8 +224,9 @@ jobs:
matrix:
include:
- build: 'arm64'
defines: '-T ClangCL -DCMAKE_GENERATOR_PLATFORM=ARM64 -DGGML_NATIVE=OFF'
runs-on: windows-latest
# ClangCL + CMake PCH disagrees on C17 for ggml-cpu, so llama.dll is never built.
defines: '-T ClangCL -DCMAKE_GENERATOR_PLATFORM=ARM64 -DGGML_NATIVE=OFF -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON'
runs-on: windows-2022
steps:
- uses: actions/checkout@v6
with:
Expand All @@ -238,6 +241,7 @@ jobs:
cd build
cmake .. ${{ env.COMMON_DEFINE }} ${{ matrix.defines }}
cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS} --target ggml ggml-base ggml-cpu llama mtmd
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
tree /f

- name: Upload artifacts (llama)
Expand Down Expand Up @@ -535,7 +539,7 @@ jobs:
defines: '-DCMAKE_OSX_ARCHITECTURES=x86_64 -DGGML_METAL=OFF -DGGML_AVX=ON -DGGML_AVX2=ON'
targets: '--target ggml ggml-base ggml-cpu ggml-blas llama mtmd'
- build: 'x64-rosetta2'
defines: '-DCMAKE_OSX_ARCHITECTURES=x86_64 -DGGML_METAL=OFF -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_F16C=OFF -DGGML_BMI2=OFF'
defines: '-DCMAKE_OSX_ARCHITECTURES=x86_64 -DGGML_METAL=OFF -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_F16C=OFF -DGGML_BMI2=OFF -DGGML_SSE42=OFF -DCMAKE_C_FLAGS=-march=x86-64 -DCMAKE_CXX_FLAGS=-march=x86-64'
targets: '--target ggml ggml-base ggml-cpu ggml-blas llama mtmd'
env:
MACOS_RPATH_DEFINE: "-DCMAKE_INSTALL_RPATH='@loader_path' -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON"
Expand Down
2 changes: 1 addition & 1 deletion LLama/Native/Load/NativeLibraryMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public override string ToString()
public enum AvxLevel
{
/// <summary>
/// No AVX
/// No AVX or SSE4.2. For x86_64 CPUs that only provide SSSE3 / SSE2.
/// </summary>
None,

Expand Down
16 changes: 16 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ Generally, there are two possible cases for this problem:
1. The native library (backend) you are using is not compatible with the LLamaSharp version. If you compiled the native library yourself, please make sure you have checkouted llama.cpp to the corresponding commit of LLamaSharp, which could be found at the bottom of README.
2. The model file you are using is not compatible with the backend. If you are using a GGUF file downloaded from huggingface, please check its publishing time.

### Illegal instruction (core dumped) on an older CPU

`LLamaSharp.Backend.Cpu` ships several x86_64 binaries. The loader picks `noavx` when the CPU has no AVX. Those binaries must also be free of SSE4.2. A CPU that only has SSSE3 (no `sse4_1` / `sse4_2` in `lscpu`) will SIGILL if the `noavx` build still contains SSE4.2 kernels.

Until a backend package built with `-DGGML_SSE42=OFF` is published, compile llama.cpp yourself and load it before any other LLamaSharp call:

```bash
cmake -B build -DGGML_NATIVE=OFF -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF -DGGML_BMI2=OFF -DGGML_SSE42=OFF -DCMAKE_C_FLAGS=-march=x86-64 -DCMAKE_CXX_FLAGS=-march=x86-64 -DBUILD_SHARED_LIBS=ON
```

```cs
NativeLibraryConfig.All.WithLibrary("<path-to-libllama.so-or-llama.dll>", null);
```

You can also add `NativeLibraryConfig.All.WithLogCallback(...)` at startup to confirm which runtime folder was loaded (`noavx`, `avx`, `avx2`, ...).


## Why my model is generating output infinitely

Expand Down
Loading