In this article
CPU TopK in the 1.32 notes uses explicit NaN ordering; validate selected indices, ties and algorithm branches rather than only finite values.
ONNX Runtime 1.32.0 release notes report CPU TopK ordering NaN above ordinary values. The linked analysis explains why plain greater-than, less-than and equality comparisons do not provide the ordering algorithms need when NaN is present. This makes nonfinite inputs part of backend-consistency testing rather than a case covered by finite random arrays.
NaN breaks a familiar comparison shortcut
Ordinary floating comparisons do not place NaN on either side of a finite number. A sorting or selection implementation needs a consistent policy beyond those raw operators. The release reports one such policy and the PR relates it to existing CUDA behaviour. Do not describe that implementation choice as a new universal mathematical definition of NaN ordering; it is the behaviour callers should verify for this runtime and provider combination.
Indices reveal more than values
Two NaNs can look identical in a printed value list while referring to different input positions. Ties among finite values have the same issue. A proposed regression checks indices as well as values, with several NaNs at distinct positions and repeated finite values. Include largest and smallest selection modes. A comparator policy is only fully observable when the test verifies which original elements were chosen and in what order.
Different K values can exercise different algorithms
TopK implementations often specialize small and larger selections. The PR specifically discusses several paths, so one K value is incomplete coverage. Use a one-element selection, an intermediate K and a near-full selection with the same nonfinite pattern. Compare CPU with the documented reference policy before comparing providers. A finite-only throughput test can remain valuable, but it cannot establish correctness of the NaN-aware branches.
A stable selection does not repair upstream NaNs
Ordering nonfinite values consistently makes selection predictable; it does not make the model’s earlier arithmetic healthy. Preserve diagnostics about where NaNs originated if they are unexpected. This article reports the release policy and proposed regression structure without claiming to have run the PR’s tests or measured a new speedup. Applications that reject nonfinite inputs should still test that rejection separately from the operator’s defined handling.
Sources
Related reading
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.