We replaced a monolithic autograd.Function wrapping all of BitNet's ternary quantization with a minimal _STERound (STE only on round()), mirroring torchao's design — enabling full torch.compile fusion at the cost of being slower in eager mode without the compiler.
We traced a 3x training slowdown in a BitNet b1.58 quantization-aware training layer to ~25 unbatched CUDA kernel launches and autograd graph bloat, then recovered most of the overhead with torch.compile, a custom STE autograd Function, and removed redundant float32 upcasts.
When a CUDA graph is captured once and replayed across different benchmark workloads, stale kernel parameters can silently corrupt results — we added a minimal no-cache toggle to isolate whether pointer updates were actually taking effect.
We systematically improved a CuTeDSL sparse attention kernel from 9.6x to 43.6x speedup by tuning split count from 32 to 64 and eliminating Python preprocessing — then hit a hard wall trying to vectorize scatter-gather loads through swizzled SMEM.
We hit two undocumented CuTeDSL integration bugs — a missing MLIR context and a TVM-FFI type error — then reached 30x sparse attention speedup by extracting raw CUfunction handles and parallelizing the reduce kernel across head groups.
A quick data analysis script revealed our 'random access' sparse kernel was actually reading sequential, pre-sorted indices — completely changing the optimization approach.
NCU flagged our sparse attention kernel as "occupancy limited" at 12.5%, but increasing occupancy would have achieved nothing — the kernel was already near the HBM random-access bandwidth ceiling, and more warps just means more threads waiting on the same random DRAM requests.
We ran Nsight Compute on a Triton sparse attention kernel and discovered it already generates async pipelined scatter-gather loads — but three targeted optimizations (removing masks, adding pipeline stages, combining both) all made things worse.
Sorting sparse attention indices to improve DRAM coalescing backfired badly — the fix destroyed split-K load balance and eliminated cross-SM L2 cache sharing, making the kernel 2.4–3x slower despite reducing uncoalesced loads.
We discovered that PyTorch's ATen sum dispatch varies by tensor width in memory — not just the values being summed — while torch.topk is bit-exactly equivalent to stable descending sort, enabling 33x faster batched top-k via -inf padding.