Back to Blog
Oct 18, 2024
•By Swasthik Shetty•commit: c4e1208

Stress-Testing Strided Tensors: 8,187 View Ops Under Miri

Exposing negative strides, transpositions, and multi-axis slicing to randomized mutation fuzzing.

Diagnostic Challenge

Negative strides combined with non-zero byte offsets caused an integer underflow in raw pointer arithmetic during reverse slicing.

Architectural Discovery

Raw pointers must always calculate offsets in signed isize before applying to the base NonNull<T> pointer.

Stress-Testing Strided Tensors: 8,187 View Ops Under Miri

2024-10-18 • By Swasthik Shetty •commit: c4e1208
What Broke

Negative strides combined with non-zero byte offsets caused an integer underflow in raw pointer arithmetic during reverse slicing.

What Was Learned

Raw pointers must always calculate offsets in signed isize before applying to the base NonNull<T> pointer.

Strided memory layouts are notoriously error-prone in native C/C++/Rust engines. If your stride math is off by even one byte, you end up reading past buffer bounds.

To guarantee correctness before moving to CUDA, we built a custom view-op fuzzer generating:

  • Random rank dimensions ($1 \le r \le 6$)
  • Permutations, transpositions, and reverse slices
  • Multi-dimensional negative strides

The 8,187 Fuzzing Campaign

We ran 8,187 randomized operation chains under AddressSanitizer and Miri. The outcome:

code
[8,187 ops] full multi-axis fuzz suite completed.
Zero panics, zero segfaults, zero memory corruption.