Property-Based Testing for Robust Softmax and Cross-Entropy

Muhammad Maaz
10/27/2026
1 citation
cs.LG

Official code: mmaaz-git/softmax-fix (9 stars, Python, last commit 2026-10-26).

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

90PythonOct 26, 20261 months ago

Similar Papers

Cite this paper

@article{maaz2026propertybased,
  title  = {Property-Based Testing for Robust Softmax and Cross-Entropy},
  author = {Muhammad Maaz},
  year   = {2026},
  eprint = {2610.36427},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2610.36427v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2610.36427.svg)](https://codeofpaper.com/paper/2610.36427)

Discussion