Barron, Gnanapragasam and Tschannen (2026) show that the standard softmax cross-entropy has a silent numerical bug: once a target logit is far enough ahead of the rest, the target probability rounds to exactly 1 in floating point and its gradient becomes exactly zero, while the other gradients stay positive. The distance that matters is the logit margin, and the margin at which rounding kicks in is the precision cliff of the dtype. Implement both.
logit_margin(z, t)
z is a 1-D array of K >= 2 logits (any real values, including magnitudes like 1000), t an integer index.float (as defined in the paper):precision_cliff(dtype)
dtype is one of np.float16, np.float32, np.float64.1 when the arithmetic is done in that dtype: cast to dtype, add dtype(1), take the reciprocal, compare with dtype(1). This is the margin at which the standard target gradient rounds to zero.m over [0, 100]; only the rounding goes through the dtype. Stop once the bracket is narrower than 1e-9.