ggml-cpu(s390x): add repack support for q4_0 - #28667
Conversation
Signed-off-by: Aaron Teo <aaron.teo1@ibm.com> ggml-cpu: clean comments Signed-off-by: Aaron Teo <aaron.teo1@ibm.com>
|
Heads-up: this PR broke the build for s390x targets without VXE. It is still broken on What happensThe three helpers
It hits a documented configuration
That documented build does not compile any more. Reproduced with Why CI did not catch itBoth s390x jobs build with VXE2, so neither reaches the
There is no scalar s390x configuration anywhere in CI. Worth noting that this PR clearly intended the non-VXE path to work: each function has an FixWrapping the three definitions in the same guard is sufficient — all 21 call sites are already --- a/ggml/src/ggml-cpu/arch/s390/repack.cpp
+++ b/ggml/src/ggml-cpu/arch/s390/repack.cpp
@@ -70,6 +70,7 @@ void ggml_quantize_mat_q8_0_4x4(const float * GGML_RESTRICT x, void * GGML_RESTR
#endif
}
+#if defined(__VXE__) || defined(__VXE2__)
static inline int16x8_t vxe_dot_acc(const int8x16_t v_x, const int8x16_t v_y, const int16x8_t v_acc) {
return vec_meadd(v_x, v_y, vec_moadd(v_x, v_y, v_acc));
}
@@ -84,6 +85,7 @@ static inline int32x4_t vxe_fold(const int16x8_t v_sumi) {
const int16x8_t v_ones = vec_splats((int16_t)1);
return vec_add(vec_mule(v_sumi, v_ones), vec_mulo(v_sumi, v_ones));
}
+#endif // __VXE__ || __VXE2__
void ggml_gemv_q4_0_4x4_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const void * GGML_RESTRICT vx, const void * GGML_RESTRICT vy, int nr, int nc) {
const int qk = QK8_0;Verified against the pristine source: unpatched + the flags above reproduces the three errors; We carry this downstream for now — the patch file and the full write-up (including the measured
Found while cross-compiling s390x from x86 for a downstream JNI binding, which passes Happy to open a PR with the above if that is useful. AI usage disclosure: Claude Code + Opus 5 (investigation, reproduction and this write-up). |
@bernardladenthin By 'broken' you mean that the build is failing, and not that the logits computed are wrong right? And yes, I missed out those guards, so please feel free to open a PR :) Edit: I had also intended to refactor those helper functions into |
|
PR is open: #28775. And agreed, moving them into ggml-cpu-impl.h would be better. thanks! |
Overview
This PR introduces weights repack support for Q4_0 on s390x. We are seeing an approximate 1.60x performance improvement for Prompt Processing and 1.10x for Token Generation.
Additional information
$ build/bin/llama-bench -hf taronaeo/Granite-3.0-1B-A400M-Instruct-BE-GGUF:Q4_0 -lm mlockRequirements