PyTorch CUDA batch-norm path reads past bounds on empty tensors
A report says batch_norm_gather_stats launches a CUDA kernel with a negative count and zero-size tensors, producing invalid global reads.
A bug report on the PyTorch tracker says the CUDA implementation of aten::batch_norm_gather_stats can read outside allocated GPU memory when callers pass empty tensors and a negative sample count, and that the operator does not reject those inputs before launch.
The report, against PyTorch 2.13.0 built with CUDA 12.6, describes a zero-length input, a zero-length inverse-standard-deviation tensor, and a large negative n. Compute Sanitizer's memory checker then reported an invalid 4-byte global read from the kernel behind batch_norm_gather_stats_cuda_template. The expected behavior is a clean error: n should be non-negative, and the mean and inverse-standard-deviation extents should match the input, before any kernel runs.
Batch-norm gather-stats is used when distributed or multi-tensor training combines per-batch statistics. An out-of-bounds device read is a memory-safety failure on the GPU, not merely a wrong number in the running mean. The report does not claim a crash in ordinary training, a CVE, or that the bad arguments arise from public Python APIs rather than a direct ATen call. No maintainer response or fix is attached yet.