# Property-Based Testing for Robust Softmax and Cross-Entropy

arXiv: https://arxiv.org/abs/2610.36427 · HTML: https://mlsanity.com/paper/2610.36427/

## Key facts

- Cited by 1 papers in the map (data through 24 Nov 2026).
- Builds on 4 of its 9 references that are in the map.
- Submitted 27 Oct 2026.

## Builds on (most cited first, 4 of 4)

- [Attention Is All You Need](https://mlsanity.com/paper/1706.03762/) (2017)
- [Grokking at the Edge of Numerical Stability](https://mlsanity.com/paper/2501.04697/) (2025)
- [Agentic Property-Based Testing: Finding Bugs Across the Python Ecosystem](https://mlsanity.com/paper/2510.09907/) (2025)
- [A Fix for Softmax and Cross-Entropy](https://mlsanity.com/paper/2610.31642/) (2026)

## Built on by (most cited first, 1 of 1)

- [On numerical issues of divergences between nearly equal distributions](https://mlsanity.com/paper/2611.18511/) (2026)

## Abstract (arXiv)

A recent paper of Barron et. al. (2026) identified two numerical issues with the softmax and cross-entropy functions in virtually all standard machine learning libraries (e.g., PyTorch and JAX). We show that these issues can be recovered through simple property-based tests in Hypothesis. However, our tests identify an additional edge case where their implementation fails. We then propose an even more robust softmax implementation which passes these tests and also supports use in causal attention masking. We compare our implementation with theirs and discuss some of the differences. Overall, this work shows that property-based testing can be a powerful tool for discovering and fixing numerical issues in machine learning libraries. Our implementations and property-based tests can be found at https://github.com/mmaaz-git/softmax-fix.
