In this article
Run Metal shader validation on an affected shape, then check output correctness and performance separately.
The b12221 pre-release includes a Metal flash attention fix for output scratch initialization. Its author reports out-of-bounds accesses detected with Metal shader validation on an M2. The release gives Apple Silicon operators a specific regression to reproduce with a model using the affected kernel.
The two writes must agree
The vector kernel zeroes scratch before it accumulates results. The patch limits initialization using the same condition as the subsequent update. That matters on shapes where some lanes have no valid scratch slot. Comparing the two paths explains why output can appear normal even when validation reports invalid writes.
Reproduce the reported case
The contributor reports that a head dimension of 64 on the tested M2 changed from 109 validation findings to zero. Treat the count as a report for that setup. Keep the model, prompt, Metal path and validation configuration fixed while comparing builds immediately before and after the fix.
Exercise neighboring shapes
Include shapes near the tested boundary and exercise prompts of several lengths. Save which implementation each run actually selects. A run that falls back to another attention kernel may finish successfully while leaving the corrected vector kernel untested. Collect a minimal reproducible shape whenever validation flags a write.
Separate correctness and instrumentation
Use the validation run to find memory access problems. In a separate run compare logits or deterministic short generation against an agreed reference within the tolerance appropriate for the numerical path. Measure throughput with instrumentation disabled, because validation adds work that would otherwise pollute the performance result.
Promote the pinned candidate
Record the runtime revision, operating system, chip and model digest in the test report. Acceptance should identify the affected path, whether validation stayed clean and whether the output test passed. A change in model conversion or system software calls for a fresh run on the affected shape.
Primary sources
Related reading
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.