NaN
A special value in the IEEE 754 floating-point standard representing the result of an invalid operation. Common sources include 0/0, infinity minus infinity, infinity times zero, and reads of uninitialized memory. It is highly contagious and can invalidate an entire computation chain.
Timeline (last 90 days)
According to the IEEE 754 standard, comparisons of NaN with any value (including itself) return false, so argmax behavior is undefined when it encounters NaN.
After explicitly mapping NaN to -inf, NaN is smaller than any finite value and is thus deterministically excluded, making argmax output independent of hardware and implementation.
Since this involves multi-step normalization such as softmax, temperature scaling and top-p truncation, any 0/0, log(0) or overflow in any step will contaminate the logits and produce NaN.
If NaN is not handled correctly, greedy sampling may output wrong tokens, manifesting as degraded generation quality or even garbled output.
In GPU kernels, reading uninitialized or out-of-bounds memory is a common source of NaN; residual arbitrary bit patterns interpreted as floating-point numbers will contaminate the computation chain once they participate in accumulation.
NaN is contagious: the result of any arithmetic operation with NaN is NaN; in the cross-chunk reduction of chunk scan, a NaN produced by one chunk will propagate to all subsequent chunks.
NaN in the IEEE 754 floating-point standard represents an invalid operation result, with common triggering conditions including 0/0, ∞−∞, ∞×0, and taking the square root of a negative number.
All Facts (7)
According to the IEEE 754 standard, comparisons of NaN with any value (including itself) return false, so argmax behavior is undefined when it encounters NaN.
50%UnverifiedAfter explicitly mapping NaN to -inf, NaN is smaller than any finite value and is thus deterministically excluded, making argmax output independent of hardware and implementation.
50%UnverifiedSince this involves multi-step normalization such as softmax, temperature scaling and top-p truncation, any 0/0, log(0) or overflow in any step will contaminate the logits and produce NaN.
50%UnverifiedIf NaN is not handled correctly, greedy sampling may output wrong tokens, manifesting as degraded generation quality or even garbled output.
50%UnverifiedIn GPU kernels, reading uninitialized or out-of-bounds memory is a common source of NaN; residual arbitrary bit patterns interpreted as floating-point numbers will contaminate the computation chain once they participate in accumulation.
50%UnverifiedNaN is contagious: the result of any arithmetic operation with NaN is NaN; in the cross-chunk reduction of chunk scan, a NaN produced by one chunk will propagate to all subsequent chunks.
50%UnverifiedNaN in the IEEE 754 floating-point standard represents an invalid operation result, with common triggering conditions including 0/0, ∞−∞, ∞×0, and taking the square root of a negative number.
50%