GitHub Repo
PyTorch fixes CUDA index-write bug that could cause out-of-bounds writes with certain contiguous tensor layouts
On November 7, PyTorch maintainers traced a stride bug in a CUDA index-write kernel and marked it fixed. The issue surfaced in a model cache update test, but inclusion in official packages and the full scope of its impact remain unconfirmed.

A PyTorch issue that initially appeared to be an attention compilation anomaly was traced on November 7 to the CUDA index_put_ write kernel. A report on November 5 said that Gemma 4 could produce incorrect output when used with a static cache, torch.compile, and packed grouped-query attention (GQA). Maintainers later provided a minimal reproduction that did not depend on a model or compiler, narrowing the root cause to a low-level tensor operation. Official issue
The key detail is that a dimension of length one can have a special stride while the tensor still qualifies as contiguous. The affected sorting write kernel used that dimension’s stride to advance across slices, causing data to be written outside the tensor’s bounds while the intended position remained unchanged. In the maintainers’ reproduction, the expected four elements were [0,1,0,1], but the actual result was [0,1,0,0]; another value was written to the wrong location in the underlying storage. Root cause and reproduction
The trigger conditions also help explain why the issue was difficult to trace: the model test enabled deterministic algorithms, which caused the cache update to use the affected kernel. The official documentation explains that torch.use_deterministic_algorithms(True) switches supported operations to deterministic implementations and also changes Inductor behavior. Engineering teams comparing outputs therefore need to include this setting among the environment conditions they check. Deterministic algorithms documentation
According to the maintainers, both accumulation writes with special layouts and multi-element overwrites in deterministic mode could reach the affected path. Out-of-bounds writes may cause illegal memory access or corrupt neighboring tensors. The issue was closed on November 7 and links to fix commit 1e69880, but that does not mean existing user installations have received the fix. Fix status
Teams maintaining inference services should track package and backport releases, and add the minimal reproduction and sliding-window cache tests to upgrade validation. This case suggests that testing should cover different strides and deterministic settings in addition to comparing ordinary and compiled execution. Public evidence is not yet sufficient to identify every affected version and model.