The llama.cpp project released build b10545, which addresses a critical bug in the Metal backend's tensor API matrix multiplication kernel. The update prevents undefined behavior and corrupted results when processing tensors where the K dimension is not a multiple of 32.

  • The matmul2d op now uses dynamic_extent for K instead of a static tile size.
  • Operand tensor views are clamped to the remaining valid K range on every iteration.
  • This change eliminates out-of-bounds reads that previously caused NaN values or data corruption.
  • Test cases were added to exercise the unaligned K path and verify the fix.

This fix ensures numerical stability for models with non-aligned matrix dimensions on Apple Silicon devices, preventing silent errors during inference.