Repository navigation
Handle scalar bfloat16 leaves in ULP assertions - #476
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #475.
Convert host scalar operands to at least one dimension before reinterpreting their storage in the bfloat16 ULP helper. NumPy rejects the existing item-size-changing view for 0D arrays, so identical scalar leaves currently raise a ValueError. Values, tolerances and the existing ULP arithmetic are unchanged.
Validation
python -m pytest -q chex/_src/asserts_test.py chex/_src/asserts_scalar_ulp_test.py -k 'ulp or ScalarBfloat'32 selected tests passed; 349 unrelated tests were deselected. This includes all existing ULP tests and 23 new cases. On unchanged source, 22 new scalar cases fail and the array/other-dtype control passes.
Tests cover host and JAX scalars, nested leaves, zero and signed values, exact/one/two-ULP boundaries, and host assertions on a jitted reduction's scalar output. The full Chex suite and multi-device execution were not run. No new support for assertions inside JIT or changed mixed-dtype policy is claimed.
Tested on macOS CPU. New test formatting, scoped static checks, syntax checks and
git diff --checkpass. No dependency or workflow changes.