Skip to content

metal: fix the PTQ1_0 CPY crash and add the missing PTQ1_0 dequant-copy kernels - #162

Merged
bri-prism merged 1 commit into
prismfrom
fix/metal-cpy-ptq1_0-gate
Sep 7, 2026
Merged

metal: fix the PTQ1_0 CPY crash and add the missing PTQ1_0 dequant-copy kernels#162
bri-prism merged 1 commit into
prismfrom
fix/metal-cpy-ptq1_0-gate

Conversation

@bri-prism

Copy link
Copy Markdown

What

Metal accepted GGML_OP_CPY in both directions for PTQ1_0 while no copy kernel for the type existed. The first such op asked the library for a pipeline that is not there (kernel not found in any metal library: kernel_cpy_f32_ptq1_0) and the process died with SIGSEGV.

  • PTQ1_0 -> F32/F16: instantiate kernel_cpy_ptq1_0_f32 and kernel_cpy_ptq1_0_f16 on the existing cpy_q_f32 template with dequantize_ptq1_0 (nl = 8, matching the PQ2_0 copy and the PTQ1_0 get_rows and mul_mm instantiations).
  • F32 -> PTQ1_0: decline in supports_op so the op falls back to the CPU. There is no Metal quantize_ptq1_0.

Why

Same permissive-gate pattern as the per-expert mat-vec crash fixed in #157: supports_op claimed a type the shader library never instantiated. It also made the CPY sweep in test-backend-ops look green: the run aborted at the first PTQ1_0 case, after the PQ2_0 cases, and everything it had printed was OK.

Verification

test-backend-ops test -b MTL0 -o CPY on an M5 Pro:

before after
exit code 139 0
result aborted mid-list 203/203 passed
PTQ1_0 -> F32 cases never ran 2 OK
F32 -> PTQ1_0 cases crash 15 not supported (CPU fallback)

No kernel used by the model graph changes; this only adds instantiations and removes a false capability claim.

…py kernels

supports_op accepted CPY in both directions for PTQ1_0 while no cpy kernel for
the type was instantiated, so the first such op asked for a pipeline that does
not exist ("kernel not found in any metal library") and the process died with
SIGSEGV. test-backend-ops -o CPY on Metal therefore exited 139 partway through
the type list while every line it did print was OK.

- PTQ1_0 -> F32/F16: instantiate kernel_cpy_ptq1_0_f32/f16 on the existing
  cpy_q_f32 template with dequantize_ptq1_0 (nl = 8, same as PQ2_0 and the
  PTQ1_0 get_rows/mul_mm instantiations).
- F32 -> PTQ1_0: decline in supports_op so it falls back to the CPU; there is
  no Metal quantize_ptq1_0.

test-backend-ops test -b MTL0 -o CPY: exit 0, 203/203 passed (was exit 139).
Both PTQ1_0 -> F32 cases OK, the 15 F32 -> PTQ1_0 cases report not supported.
@bri-prism
bri-prism merged commit 7d2da03 into prism Sep 7, 2026
8 checks passed
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.

1 participant