Problem
Currently line 2366 in colibri.c gates METAL support to fmt:2 only:
&& l->kv_b.fmt==2. The Metal mm_gemv kernel (line 16) only supports fmt=1 (int8), fmt=2 (int4 per-row), fmt=3 (int2), and f32 — no fmt=4 (grouped int4).
As a result, PROF=1 PROMPT="Compare the myths of Lucifer and Prometheus" NGEN=64 COLI_METAL=1 DIRECT=1 MTP=0 TEMP=0 COLI_METAL_RESSET=1 SNAP=~/glm52_i4 ./colibri 64 achieves 2.39 tok/s on fmt:2 but only 0.81 tok/s on fmt:4
Proposed solution
Add fmt:4 support to the Metal attention path. This involves
- Adding gs to AttnW struct and bind_gemv
- Adding grouped-int4 handling in the mm_gemv Metal kernel
- Relaxing the l->kv_b.fmt==2 guard
Alternatives considered
We could leave processing as is, but the existing code performs Apple Silicon Mac attention processing on the CPU. This is ~3X slower than the fmt:2 model on my machine.
Scope and compatibility
Limited to fmt:4 on Mac apple silicon
Problem
Currently line 2366 in colibri.c gates METAL support to fmt:2 only:
&& l->kv_b.fmt==2. The Metal mm_gemv kernel (line 16) only supports fmt=1 (int8), fmt=2 (int4 per-row), fmt=3 (int2), and f32 — no fmt=4 (grouped int4).
As a result, PROF=1 PROMPT="Compare the myths of Lucifer and Prometheus" NGEN=64 COLI_METAL=1 DIRECT=1 MTP=0 TEMP=0 COLI_METAL_RESSET=1 SNAP=~/glm52_i4 ./colibri 64 achieves 2.39 tok/s on fmt:2 but only 0.81 tok/s on fmt:4
Proposed solution
Add fmt:4 support to the Metal attention path. This involves
Alternatives considered
We could leave processing as is, but the existing code performs Apple Silicon Mac attention processing on the CPU. This is ~3X slower than the fmt:2 model on my machine.
Scope and compatibility
Limited to fmt:4 on Mac apple silicon