Repository navigation
s390x: IBM Z CPU variants z13 / z15 / z16 (patch 0023), 4-4.5x faster on a z16 - #580
Conversation
…tch 0023) cpu-linux-s390x was one static, scalar library: GGML_NATIVE=OFF switches VXE off, so no IBM Z vector code ever shipped. build-linux-s390x now builds it modular (JLLAMA_BACKEND_DL) with GGML_CPU_ALL_VARIANTS: ggml-cpu-z13 (scalar), -z15 (VXE2) and -z16 (VXE2 + NNPA), of which ggml loads the best for the machine. On cfarm191 (z16, b11901, Qwen3-0.6B Q4_K_M big-endian, 4 threads) prompt processing goes from 19.7 to 82.6-95.5 t/s and generation from 13.6 to 51.9-58.3; against a Q8_0 reference the Q4_K_M model lands at the same KLD on z13 and z16. Patch 0023, two parts: - llamafile/sgemm.h included <vecintrin.h> a second time after ggml-cpu-impl.h; clang's header has no include guard, so ggml-cpu.c failed with "redefinition of 'vec_extract'". The include is not needed (added by ggml-org/llama.cpp#14273; GCC's guard hid it). - Upstream's s390x variant list starts at z15; a scalar z13 module keeps the z13 floor the jar has had. A modular build cannot link jllama_test, so the C++ suite moves to the new test-cpp-linux-s390x job (static build, same toolchain, qemu). c_abi now runs under the toolchain's emulator, where ggml loads the z15 module. build-linux-s390x checks that all three modules were built. Verified locally with the job's toolchain (clang-18, manylinux_2_28 sysroot): the build, c_abi under qemu, verify-native-deps.py (9 libraries, 0 violations), and a JVM load on RHEL 8.10 s390x. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DuAkLtHrCTx81vP5Mt4jad
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Add s390x CPU variants llama/patches/0023-ggml-cpu-s390x-variants-build-with-clang-and-a-z13-baseline.patch, llama/CMakeLists.txt |
The patch adds a z13 backend, extends the cross-compilation target range, and removes a conditional vecintrin.h include. CMake enables modular Linux s390x builds and permits the C ABI test under an emulator. |
Build and test s390x artifacts .github/workflows/publish.yml, .github/buildcheck/nativedeps.py |
The build job checks for the z13, z15, and z16 modules. A separate job runs the C++ suite under qemu, and package requires that job. The dependency description reflects the modular libraries. |
Document modular s390x support CHANGELOG.md, CLAUDE.md, README.md, TODO.md, docs/patches.md |
The documentation and patch inventories describe the CPU modules, build and test setup, and recorded measurements. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant CMake
participant BuildWorkflow
participant QemuTestJob
participant Package
CMake->>BuildWorkflow: Configure modular CPU backends
BuildWorkflow->>BuildWorkflow: Check z13, z15, and z16 modules
QemuTestJob->>Package: Provide required C++ test result
Possibly related PRs
- bernardladenthin/java-llama.cpp#573: Defines the s390x sysroot and dependency checks used by this modular build.
- bernardladenthin/java-llama.cpp#568: Documents the s390x glibc limitation that the updated build and platform documentation address.
- bernardladenthin/java-llama.cpp#577: Adds s390x typeinfo alignment checks, which the updated documentation describes for multiple libraries.
Suggested reviewers: claude
Merge Risk: 
Minimal · up to 89711
-
The modular s390x build, z13 fallback, required artifacts, and qemu-backed tests are wired coherently; no merge-blocking risk is established.
Architecture risk: 
Low · up to 89711
-
The change affects 6 systems.
Changed systems:
llama,CHANGELOG.md,CLAUDE.md,docs,README.md,TODO.mdArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — llama (service) was modified; 2 changed files map to changed impact.
- observed — CHANGELOG.md (service) was modified; 1 changed file maps to changed impact.
- observed — CLAUDE.md (service) was modified; 1 changed file maps to changed impact.
- observed — docs (service) was modified; 1 changed file maps to changed impact.
Before / after behavior
- observed — Modified behavior in CHANGELOG.md: Adds a changelog entry for modular s390x CPU libraries with
z13,z15, andz16modules and startup selection. It records z16 benchmark results, patch0023build and variant-list fixes, and the s390x C++ test job running under qemu. - observed — Modified behavior in README.md: The platform description now includes Linux s390x with the shared-library and CPU-module layout; s390x is removed from the platforms described as using one static library, leaving that description for macOS.
- observed — Modified behavior in README.md: The
cpu-linux-s390xentry now specifies three startup-selected CPU modules (z13,z15,z16) and adds a z16 performance comparison against the scalar library of 6.0.x. - observed — Modified behavior in TODO.md: The model-backed plain-C smoke note no longer says that s390x remains a static build; it still identifies macOS as static.
-
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the main change: modular s390x CPU backends (z13, z15, z16) with patch 0023, and the z16 speedup. The raw summary and PR objectives both center on this change, so the title is clearly related. It is somewhat long at 78 characters, but it is specific and not vague.
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (2 skipped: 2 unsupported.)
-
Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
The dockcross Android images set CMAKE_CROSSCOMPILING_EMULATOR too
(qemu-arm), so "cross-compiling with an emulator" enabled c_abi in the
Android aarch64 job, where qemu-arm cannot run the aarch64 executable
("Invalid ELF image for this architecture", run 40469900299). Only the
s390x toolchain's emulator is meant.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DuAkLtHrCTx81vP5Mt4jad
|



Summary
cpu-linux-s390xuses the IBM Z vector unit. Until now the jar was one static, scalar library:GGML_NATIVE=OFFswitches VXE off, so no vector code shipped.build-linux-s390xnow builds it modular (JLLAMA_BACKEND_DL) withGGML_CPU_ALL_VARIANTS:ggml-cpu-z13(scalar),-z15(VXE2) and-z16(VXE2 + NNPA). ggml loads the best module for the machine. The floor stays z13 and glibc 2.28.0023, two parts.llamafile/sgemm.hincludes<vecintrin.h>a second time afterggml-cpu-impl.h. clang's header has no include guard, soggml-cpu.cfailed with "redefinition of 'vec_extract'"; GCC's guard hid the problem. The include came with llamafile: support s390x SIMD instruction set ggml-org/llama.cpp#14273 and is not needed:sgemm.hdeclares no vector type, and both of its includers includeggml-cpu-impl.h. Removed.z13module.jllama_test, so the C++ suite moves to the new jobtest-cpp-linux-s390x(static build, same toolchain, still under qemu). It gatespackage.c_abinow runs under the toolchain's emulator. There ggml loads the z15 module, because qemu's CPU model has VXE2, so CI runs the vector code too.build-linux-s390xchecks that all three modules exist; the configure skips a variant the compiler rejects (z17 with clang 18) without reporting it.Measured on cfarm191 (IBM z16, LinuxONE, Debian 13)
b11901, Qwen3-0.6B Q4_K_M converted to big-endian,
llama-bench -t 4 -p 64 -n 16, two interleaved rounds, t/s:llama-perplexity --kl-divergenceagainst a Q8_0 reference computed on z13:Test plan
c_abipasses under qemu, withCPU : VXE = 1;verify-native-deps.py: 9 libraries, 0 violations (glibc ≤ 2.27,GLIBCXX_3.4.25,CXXABI_1.3.11, the existing allowlist, typeinfo alignment).NativeLoadSmokewith the built directory in the UBI 8 OpenJDK 21 image on RHEL 8.10 s390x (qemu): z15 module,patches=…0022,0023.check-patches.py(14 patches, 104 hunks, 0 problems;docs/patches.mdcurrent),check-natives.py(0 disagreements), buildcheck unit tests 127/127 on Linux, release gate (75 jobs, 0 violations), run scripts parse,publish.ymlloads as YAML.TODO.md, "Linux s390x")Related issues / PRs
The open TODO item "s390x runs scalar" is closed by this PR. Follows #573 (glibc floor) and #577 (typeinfo alignment).
Checklist
CONTRIBUTING.mdandCODE_OF_CONDUCT.md🤖 Generated with Claude Code
https://claude.ai/code/session_01DuAkLtHrCTx81vP5Mt4jad
Summary by CodeRabbit