Skip to content

M2 Metal: reject Q8 activation staging without an integer-dot primitive #864

Open

Description

@jxsl13

Finding

On Apple M2 Pro with Apple Metal compiler 32023.883, a diagnostic MSL kernel using dot(char4, char4) fails to compile: the exposed dot overloads accept only half and float vectors. The installed metal_simdgroup_matrix headers likewise constrain multiply operands and accumulators to floating-point types; available 8x8 aliases are half, float, and bfloat. Thus a Q8_K activation staging transform cannot map its int8 products to a packed integer-dot or integer matrix primitive on this target.

Incumbent cross-check

Pinned current upstreams:

  • llama.cpp master 4a08fa29705b8177e332b134306566c2c4b95902 keeps N_R0_Q4_K=2/N_SG_Q4_K=2 and its Metal Q4_K matvec consumes F32 activations directly.
  • MLX main d9077d8316ad7305497a3ecf2296bd0e0e99a627 also performs quantized Metal matvec dots against floating activations rather than staging Q8 activations.

GoAI current Q4_K Metal counters are ALU-limited, so Q8 staging initially looks attractive. Without packed integer dot, however, it replaces each efficient floating multiply-accumulate with scalar/vector-lane integer multiply-add, retains the weight unpack, adds activation quantization plus scale traffic, and changes model numerics. No production proposal is justified until a target exposes a genuine packed integer-dot primitive or an isolated microbenchmark disproves this instruction-count model.

Potential detector guidance

A future perfscan GPU rule should warn when an activation-quantization proposal assumes int8 dot throughput without proving an exposed packed dot/MMA primitive for the exact backend capability tier. Treat conversion plus scalar integer multiply-add as extra work, not as a tensor-core path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions