← Back to Pull requests

Linux x86_64 CPU builds: enable GGML_BACKEND_DL and GGML_CPU_ALL_VARIANTS (closes #68) #152

Open
unknown opened this pull request with 497 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 11, 2026 22:27 UTC
Author

Closes #68.

The cpu_mkl build for linux-64 compiles ggml's CPU backend for the baseline x86_64 target only. On 12004 cpu_mkl, objdump -d of libggml-cpu.so finds no ymm register use at all, so the quantized matmul and attention kernels run on SSE code even on AVX2, AVX-VNNI and AVX-512 machines; only what goes through MKL's BLAS is vectorized. The recipe sets no GGML_NATIVE and no AVX flag on Linux. ggml turns GGML_NATIVE off by default when cross-compiling or when SOURCE_DATE_EPOCH is set (ggml/CMakeLists.txt:105-107); the missing ymm code says the native path was not taken on the build machines, which is the right outcome for a redistributable package, and leaves only the baseline.

Upstream solves this for its own release archives with runtime dispatch: GGML_BACKEND_DL=ON builds each backend as a loadable module, and GGML_CPU_ALL_VARIANTS=ON builds the CPU backend once per x86_64 level (x64, sse42, sandybridge, haswell, skylakex, alderlake, zen4, … — ggml/src/CMakeLists.txt:489-516). At start-up ggml scores each variant against the running CPU and loads the best one. That is the change #68 asks for, and this PR applies it to the linux-64 CPU builds only.

Measured with the package this PR builds, against conda-forge's 12004 cpu_mkl_hf7acbac_0, on a 16-core desktop CPU with AVX-512 (Ubuntu 24.04), Gemma 4 E2B Q4_0, an 11 231-token cold prompt, llama-server --device none --parallel 2 --ctx-size 131072 --ubatch-size 512, three alternated runs each: prefill median 171.0 tok/s before, 584.1 tok/s with this PR, which loaded its zen4 variant. One CPU, one model; generation not measured.

What changes

  • linux-64, cuda_compiler_version == "None": -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON.

  • No GGML_BACKEND_DIR: the backend modules (libggml-cpu-*.so, libggml-blas.so, libggml-vulkan.so) install to bin/, upstream's default (ggml/src/CMakeLists.txt:388-391), and ggml finds them through the executable's directory (ggml-backend-reg.cpp:486-499). A compiled-in $PREFIX/lib does not work: conda relocates it with NUL padding, ggml keeps the literal's full length in the search path, and no module loads.

  • Programs that link libllama need nothing new when their executable is in $PREFIX/bin (python included): llama_backend_init() calls ggml_backend_load_all() when no backend is registered (src/llama.cpp:128-134). A program elsewhere calls ggml_backend_load_all_from_path() with $PREFIX/bin.

  • Tests, linux-64 CPU builds: check libggml-cpu-x64.so, libggml-cpu-haswell.so and libggml-blas.so in bin/; run llama-cli --list-devices | grep BLAS, which fails when no module loads; skip llama-convert-llama2c-to-ggml, llama-cvector-generator and llama-export-lora, which upstream does not build under GGML_BACKEND_DL (examples/CMakeLists.txt:37-38, tools/CMakeLists.txt:38-42).

  • Build number bumped.
  • Built locally with build-locally.py (linux_64_c_compiler_version15c_stdlib_version2.17cuda_compiler_versionNonecxx_compiler_version15); all tests pass.

    Open questions for the maintainers

  • The three tools above are no longer in the linux-64 CPU package. Upstream's ubuntu-x64 archive ships neither cvector-generator nor export-lora either. Keeping them would take a second, non-DL build of ggml. Is dropping them acceptable?

  • Should CUDA and win-64 builds get the same CPU variants? They have the same SSE-only CPU backend; this PR leaves them as they are to keep the first change small.

  • Package size grows with 14 CPU modules: the .conda goes from about 17.4 to 20.2 MiB.
  • Checklist

  • Title of this PR is meaningful

  • License file is packaged (unchanged)

  • Source is from official source (unchanged)

  • Bumped the build number

  • Re-rendered with the latest conda-smithy (no new variant or dependency; happy to ask the bot if needed)

  • Ensured the license file is being packaged
  • Diff: 497 lines (+372 / -125) across 6 files Reviewer: traversaro Review duration: 3983m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.47) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 497 lines diff across 6 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.372
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #152"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.5% (MEDIUM) · Higher = larger blast radius
    47.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.3% · Safe to merge
    25.3%