Fix several regressions caused by last release#2272
Open
ricardoV94 wants to merge 8 commits into
Open
Conversation
The accumulation `if acc < arr: acc = arr` never takes a NaN, so max/min silently dropped NaNs, diverging from numpy, the C backend (whose scalar Maximum c_code explicitly tests both orderings to detect NaN), and the Python perform. Append an `arr != arr` clause: NaN is taken once and then sticks. The branch formulation compiles to a 2-compare/2-blend dependency chain, about 2x faster than the 3-compare/3-blend chain numba generates for np.maximum (which re-checks isnan(acc) every iteration).
The fused loop writes the elementwise result to the write buffer, never to the inplaced input, but the inner fgraph kept the inplace Elemwise: the Python-mode fallback (OpFromGraph.perform) would destroy that input without the outer destroy map declaring it, losing the ordering constraint for other readers of the destroyed buffer. The JIT path was unaffected (write buffers shadow the inplace pattern in make_outputs). Write-and-direct duplication now runs before the strip and preserves the inplace pattern, so an inplace on an output that stays materialized (the write consuming a duplicate) still survives the fusion.
undo_take_reshape_for_fusion assumed the reshape restores the flattened index's original shape without verifying it, so a gather regrouped to a different (runtime) shape was silently rewritten to x[mat_idx], changing the result shape and grouping. Verify instead that the leading and trailing target dims provably pass through the source, and build the ND index from the reshape target itself: x[idx].reshape(S) -> x[idx.reshape(S[axis:...])]. This is also more general than the flatten-form match: it fuses regroupings and reshapes of plain vector-index takes, and no longer requires the index to come from a ravel.
The reduction identity for bitwise AND is -1 (all bits set). Coercing it to an unsigned acc_dtype via the numpy scalar constructor (np.uint64(-1)) raises OverflowError on NumPy 2, so any AND-reduction over an unsigned dtype failed to compile. Cast through astype instead, which wraps -1 to all-ones the way the C backend already does. OR/XOR (identity 0) were unaffected.
introduce_explicit_core_shape_rv refused to wrap a RandomVariable when its core shape read the shape of another RandomVariable already feeding it (e.g. an MvNormal whose random `mean`'s trailing dimension is the core shape). That RV is computed before the node, so reading its shape needs no extra draw -- but `applys_between(node.inputs, [core_shape])` still yields such an input RV as the owner of a boundary variable, so the node was left unwrapped and later crashed numba funcify with "necessary to replace RandomVariable with RandomVariableWithCoreShape". Block the ancestor walk at the node's own inputs and only bail on a RandomVariable reachable past them (a genuine extra draw for the shape).
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.
Also fixes a couple others that had been sitting on dev branches