Repository navigation
Conversation
Add a test that forbids fastmath anywhere code from uxarray.utils.computing is compiled, and requires error_model="numpy" on acc_sqrt_re, _accux_gca, _accux_constlat and every kernel they are inlined into. An inline="always" callee is compiled with its caller's flags, so the test follows numba's inline call chains rather than only checking the definitions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
It looks to me that you are trying to test for two scenarios (to defend against flags ignored during inlining),
- If a function calls an inline function with error_model == numpy then make sure that the function also uses error_model == numpy (to avoid error_model in the inlined function being ignored)
- If a function calls an inline function make sure that the function does not use fastmath (to avoid fastmath being used for the inline function)
IMO, Changing some variable/function names and adding more comments would improve the readability of the code
The change to cleanup numba cache looks good, you might want to change the warning message to the user.
Some suggested comments are in the review comments ("Comment: ...")
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
- Rename _compiled_into to _get_inlined_funcs_in_call_tree. - Move the NUMPY_ERROR_MODEL_KERNELS presence check from the fixture into test_numpy_error_model, with a message, and add a matching guard to test_no_fastmath so neither test can pass vacuously. - Explain why NUMPY_ERROR_MODEL_KERNELS lists the source kernels by hand. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Explain why inlined EFT kernels need error_model="numpy" and no fastmath, with verified acc_sqrt_re examples, and correct the claim that sqrt of a negative raises under the default error model (only division does). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@jayeshkrishna The documentation should be better now, take a look |
Say why fastmath is rejected, what the offender entries are (kernels or module:line of a non-False fastmath keyword) and how to fix it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sevans711
left a comment
There was a problem hiding this comment.
Overall the changes here look pretty reasonable, and are pretty low-risk since they are all focused on improving developer experience (and tightening up testing). Before approving, I do have one sizeable concern though: What is the motivation for auto-clearing the cache during pre-commit?
I usually run pre-commit run --all-files locally, so I think this might wipe the relevant cached files for me every time I run that. It also wipes the cache after I've already made most of the changes; I don't always remember to run pre-commit before calling pytest. Local testing showed that pytest test/grid alone takes roughly 90 seconds right after running ci/clean_numba_cache.py, but <20 seconds on a "warm" run, so aggressively auto-clearing the cache has a real downside. In practice I'm concerned that including the cache clearing in pre-commit would end up slowing down my future pytest runs on unrelated work more often than it saves me from a stale cache while debugging relevant pieces of the code. Auto-clearing the cache also won't help anyone pulling my changes onto their machine locally (e.g. swapping into a PR branch for local testing) because they will still have a stale cache. It also doesn't help the online CI, which always starts with no cache.
That being said, I do think there's a good amount of value in the test_numba_flags.py tests being added here, in creating the python ci/clean_numba_cache.py script, and in adding the documentation reminding developers to run this script when working on relevant numba methods. Locally I had been using a custom version of it (mine looked something like find ../uxarray -type f \( -name "*.nbc" -o -name "*.nbi" \) -delete), but it will be quite nice to have a documented and "canonical" way to do this instead.
I would be happy to approve if the auto cache clearing was removed from pre-commit. If you additionally want protection against a stale cache for local pytest runs so that you can catch issues before they hit the online CI in a PR, perhaps a good way to proceed could be to save hashes for the relevant files during conftest.py, and run python ci/clean_numba_cache.py only if those hashes have changed?
(Claude helped me with some of the local testing and figuring out what to focus on in this review, but I wrote the review text myself)
Closes #1805
Overview
Adds a few guards to prevent regressions during chunking refactor. These guards cover stale numba caches via
inline="always", and possible regressions if usingfastmathin accuracy-sensitive code regions.These cover H1 and H2 of #1789
PR Checklist
General
Testing & Benchmarking
Documentation and Examples
docs/api.rst; internal (private) function names start with an underscore (_)AI Disclosure
AI Usage: Claude Opus 5.5