[BUG] MLX Metal strided-copy selects int32 offset kernel by element count, not reachable offset → silent tail corruption for large-stride views (copy.cpp)
copy_gpu_inplace chooses between the 32-bit and 64-bit Metal copy kernels using the element COUNT of the arrays: large = in.data_size() > INT32_MAX || out.data_size() > INT32_MAX; For a strided (non-contiguous) copy this is incorrect. A thread for logical index (r, c) reads the source at element offset r * row_stride + c. When row_stride is large, that offset can exceed INT32_MAX even though the number of elements copied is far below it. The int32 kernel then computes the offset in 32-bit and wraps, so every row past floor(INT32_MAX / row_stride) reads a wrapped/garbage address. No error is raised — results are silently wrong only in the tail.
This is the same class as the already-fixed matmul int32 row-offset overflow (PR #3609); the copy kernel selection was never made offset-aware.
Steps to Reproduce
Expected Results GPU strided copy matches the CPU strided copy for all rows. rows differ: 0.
Actual Results rows differ: 1775 first: 196225
- 196225 == floor(INT32_MAX / 10944) + 1 exactly.
- At row 196225 the GPU reads 0.0; the correct value is 196225.0.
- Corruption is confined to the ~0.9% tail of rows (those whose source offset crosses INT32_MAX).