Skip to content

🚨fix(metal): bound padded rows in scalar copy kernel - #831

Merged
0xShug0 merged 1 commit into
mainfrom
fix/metal-copy-row-bounds
Oct 9, 2026
Merged

0xShug0 merged 1 commit into
mainfrom
fix/metal-copy-row-bounds

Conversation

@0xShug0

@0xShug0 0xShug0 commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Summary

Add the missing row-bounds check to Metal's generic scalar copy kernel. Rounded-up row dispatches could overwrite neighboring tensor regions, causing incorrect and nondeterministic separation output.

Upstream GGML already has this check: kernel_cpy_t_t.

Validation

Tested on M4 Pro Metal with TF-GridNet F32 and MossFormer2 F16 from #830:

  • Isolated production-shape copy: ~1.58M incorrect samples before; zero after.
  • Both models: identical requests and chunked → whole-file → chunked sequences now produce sample-exact repeats.
  • TF-GridNet/reference cosine: 0.722 / 0.205 → 0.999827 / 0.998830.
  • MossFormer2/CPU cosine: 0.992911 / 0.939109 → 0.999999949 / 0.999999893.

Only the Metal copy kernel changes. Valid rows follow the existing path.

@0xShug0 0xShug0 added the ggml label Oct 8, 2026
@0xShug0
0xShug0 marked this pull request as draft October 8, 2026 03:55
@0xShug0
0xShug0 marked this pull request as ready for review October 9, 2026 16:29
@0xShug0 0xShug0 changed the title fix(metal): bound padded rows in scalar copy kernel 🚨fix(metal): bound padded rows in scalar copy kernel Oct 9, 2026
@0xShug0
0xShug0 merged commit 75f62ec into main Oct 9, 2026
6 checks passed
@0xShug0
0xShug0 deleted the fix/metal-copy-row-bounds branch October 9, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant