Fix _QuaxTracer concrete bool conversion for plain JAX arrays#110
Open
Fix _QuaxTracer concrete bool conversion for plain JAX arrays#110
_QuaxTracer concrete bool conversion for plain JAX arrays#110Conversation
…te tracers Agent-Logs-Url: https://github.com/nstarman/quax/sessions/b8746add-b060-4aee-9714-13117197a70b Co-authored-by: nstarman <8949649+nstarman@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix problem in
Fix Apr 9, 2026
_Quaxify.__call__ method_QuaxTracer concrete bool conversion for plain JAX arrays
Owner
|
Excellent. A simple solution. Most tests are passing. Not all, so let's not close #58 quite yet. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a TracerBoolConversionError when quaxify-wrapped functions attempt Python boolean evaluation on concrete (eager) JAX arrays by making _QuaxTracer able to produce a concrete value for _DenseArrayValue-backed arrays.
Changes:
- Override
_QuaxTracer.to_concrete_value()to delegate concretization for_DenseArrayValuepayloads. - Add a regression test covering concrete boolean conversion via
jnp.compress. - Remove
xfail_quax58from multiple NumPy-on-JAX tests that now pass; keep xfails for cases still failing with array conversion errors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/quax/_core.py |
Adds _QuaxTracer.to_concrete_value() override to enable concretization for plain JAX arrays. |
tests/unit/test_core.py |
Adds regression test reproducing the concrete-bool conversion failure (issue #58). |
tests/unit/test_numpy/test_jax_array.py |
Un-xfails a set of jnp.* functions now passing without static size. |
tests/unit/test_numpy/test_myarray.py |
Un-xfails choose for MyArray where it now passes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
90c9a35 to
60ff43d
Compare
Owner
|
@meeseeksdev help |
Owner
|
@meeseeksdev hello |
|
Helloooo @nstarman, I'm Mr. Meeseeks! Look at me! |
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.
_Quaxify.__call__wraps all dynamic JAX arrays as_QuaxTracerobjects inside a_QuaxTracecontext. When the wrapped function internally requires Python-level boolean evaluation of a concrete array (e.g.jnp.compressdoingif reductions.any(extra):), it fails withTracerBoolConversionErrorbecause_QuaxTracernever overrodeto_concrete_value(), sois_concrete()always returnedFalse.Changes
src/quax/_core.py— Overrideto_concrete_value()on_QuaxTracer: when the wrapped value is a_DenseArrayValue, delegate tocore.to_concrete_value(self.value.array). This allows__bool__(and__array__) to resolve concretely for plain JAX arrays passing through quaxify, while correctly returningNoneunder JIT.tests/unit/test_core.py— Addtest_concrete_bool_conversionreproducing the issue MWE.tests/unit/test_numpy/test_jax_array.py— Removexfail_quax58from the 15 functions that now pass without asizeargument:argwhere,bincount,choose,compress,flatnonzero,nonzero,ravel_multi_index,roots,trim_zeros,union1d,unique*(5 variants). Keepxfail_quax58onextract,intersect1d,setdiff1d,setxor1d(still fail withTracerArrayConversionError).tests/unit/test_numpy/test_myarray.py— Removexfail_quax58fromchoose(only case that passes; all others still fail because the condition is a customValuesubclass, not a_DenseArrayValue).