Skip to content

prism-v6: fix Q2_0_g128 ARM link failure and Metal shader compile - #113

Merged
khosravipasha merged 3 commits into
prism-v6from
prism-v6-g128-arm-metal-fixes
Aug 11, 2026
Merged

khosravipasha merged 3 commits into
prism-v6from
prism-v6-g128-arm-metal-fixes

Conversation

@bri-prism

Copy link
Copy Markdown
Collaborator

What

Two one-line fixes for the Q2_0_g128 port on prism-v6:

  1. ggml-cpu/arch-fallback.h: add the missing aarch64 alias mapping ggml_vec_dot_q2_0_g128_q8_0 to its generic implementation. Without it every ARM build of prism-v6 fails to link, since type_traits_cpu references the symbol unconditionally. Every other arch without a native g128 dot already carries this line.
  2. ggml-metal.metal: restore the template<int nr0, typename args_t> prefix on kernel_mul_mv_q2_0_g128_f32_impl. It was dropped in the port, so the Metal library failed to compile at runtime on every Apple device, for every model.

Why

Closes out the "Metal: ported, UNVERIFIED" line on the prism-v6 status board. The port could not previously build on ARM or run on Metal at all.

How verified (M5 Pro)

  • test-quantize-fns green including q2_0_g128
  • test-backend-ops: MUL_MAT 45/45 g128 cases OK across 3 backends; MUL_MAT_ID, GET_ROWS, CPY green (covers the mul_mv 8-sub-block and nl=8 risk spots)
  • Real model: F16 quantized with --pure Q2_0_G128, greedy output byte-identical to the same model at g64; tg128 280.8 vs 278.9 t/s (+0.7%) at a 5.6% smaller file
  • Regression check: Q1_0 27B loads and generates correctly, pp512 441.8 / tg128 39.2 t/s, about 9% faster than the same-day upstream master build on identical hardware

…8 dot

type_traits_cpu references ggml_vec_dot_q2_0_g128_q8_0 unconditionally, but
the aarch64 section of arch-fallback.h never aliased it to the generic
implementation, so every ARM build of prism-v6 failed to link. Every other
arch without a native g128 dot already carries this exact line.
kernel_mul_mv_q2_0_g128_f32_impl lost its template<int nr0, typename args_t>
prefix in the g128 port, so the Metal library failed to compile at runtime
(unknown type args_t, undeclared nr0) on every Apple device, for every model.
Restores the same declaration shape as the q2_0 g64 twin.

Verified on M5 Pro: test-quantize-fns green, test-backend-ops MUL_MAT 45/45
g128 cases + MUL_MAT_ID/GET_ROWS/CPY green, --pure Q2_0_G128 real-model
greedy output byte-identical to g64, tg128 +0.7% at 5.6% smaller file.
@khosravipasha
khosravipasha force-pushed the prism-v6-g128-arm-metal-fixes branch from dc56f19 to c5aae60 Compare August 11, 2026 01:36
@khosravipasha

Copy link
Copy Markdown
Collaborator

@bri-prism fixed the history mess I made, is that correct now? seems only two line changes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes Q2_0_G128 CPU linking on ARM and Metal shader compilation.

Changes:

  • Adds the ARM generic dot-product alias.
  • Restores the missing Metal template declaration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
ggml/src/ggml-cpu/arch-fallback.h Adds the ARM fallback alias; RISC-V remains unresolved.
ggml/src/ggml-metal/ggml-metal.metal Restores the Q2_0_G128 kernel template.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

#define ggml_gemm_q8_0_4x8_q8_0_generic ggml_gemm_q8_0_4x8_q8_0
#elif defined(__aarch64__) || defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)
// quants.c
#define ggml_vec_dot_q2_0_g128_q8_0_generic ggml_vec_dot_q2_0_g128_q8_0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

fixed

Q2_0_g128 has a native dot only on x86 (AVX-512-VNNI); every other arch must
alias ggml_vec_dot_q2_0_g128_q8_0_generic -> ...q8_0 so the symbol the CPU
traits reference resolves. The RISC-V block was the last one missing it
(GENERIC/aarch64/POWERPC/loongarch64/s390x/wasm already had it), which left
RISC-V builds with an undefined-symbol link failure. Addresses Copilot review
on #113. Now every non-x86 arch is covered; x86 keeps the native impl.
@khosravipasha
khosravipasha merged commit c946e65 into prism-v6 Aug 11, 2026
10 of 32 checks passed
@khosravipasha
khosravipasha deleted the prism-v6-g128-arm-metal-fixes branch August 25, 2026 19:29
MasterCool4389 pushed a commit to MasterCool4389/Built_PrismML-ENG-CUDA_llama.cpp that referenced this pull request Sep 18, 2026
…ismML-Eng#113)

* ggml-cpu: add missing aarch64 generic-fallback alias for the Q2_0_g128 dot

type_traits_cpu references ggml_vec_dot_q2_0_g128_q8_0 unconditionally, but
the aarch64 section of arch-fallback.h never aliased it to the generic
implementation, so every ARM build of prism-v6 failed to link. Every other
arch without a native g128 dot already carries this exact line.

* metal: fix Q2_0_g128 mul_mv kernel template declaration

kernel_mul_mv_q2_0_g128_f32_impl lost its template<int nr0, typename args_t>
prefix in the g128 port, so the Metal library failed to compile at runtime
(unknown type args_t, undeclared nr0) on every Apple device, for every model.
Restores the same declaration shape as the q2_0 g64 twin.

Verified on M5 Pro: test-quantize-fns green, test-backend-ops MUL_MAT 45/45
g128 cases + MUL_MAT_ID/GET_ROWS/CPY green, --pure Q2_0_G128 real-model
greedy output byte-identical to g64, tg128 +0.7% at 5.6% smaller file.

* ggml-cpu: add Q2_0_g128 generic-fallback alias for RISC-V

Q2_0_g128 has a native dot only on x86 (AVX-512-VNNI); every other arch must
alias ggml_vec_dot_q2_0_g128_q8_0_generic -> ...q8_0 so the symbol the CPU
traits reference resolves. The RISC-V block was the last one missing it
(GENERIC/aarch64/POWERPC/loongarch64/s390x/wasm already had it), which left
RISC-V builds with an undefined-symbol link failure. Addresses Copilot review
on PrismML-Eng#113. Now every non-x86 arch is covered; x86 keeps the native impl.

---------

Co-authored-by: Pasha Khosravi <khosravipasha@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants