Correct nit_sot shapes for scan with n_steps=0 (or raise)#2040
Draft
ricardoV94 wants to merge 8 commits intopymc-devs:v3from
Draft
Correct nit_sot shapes for scan with n_steps=0 (or raise)#2040ricardoV94 wants to merge 8 commits intopymc-devs:v3from
ricardoV94 wants to merge 8 commits intopymc-devs:v3from
Conversation
Rename Op.grad/L_op/R_op to Op.pullback/pushforward with deprecation wrappers. Rename module-level Rop/Lop to pushforward/pullback with deprecation wrappers. Rename _rop_legacy to _pushforward_direct. Update parameter names: eval_points to tangents/cotangents, use_op_rop_implementation to use_op_pushforward.
When n_steps=0, Scan's perform method was creating nit_sot output arrays with shape (0,)*ndim instead of (0, *core_shape). This caused silent shape mismatches in downstream operations like concatenation or broadcasting. Add Scan.nit_sot_core_shapes() method that returns static core shapes when all are known, or None otherwise. All three backends (Python, Cython, Numba) now use correct shapes when known, and raise a clear ValueError when shapes are unknown and n_steps=0.
f797f96 to
8cdd022
Compare
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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.
When n_steps=0, Scan's perform method was creating nit_sot output arrays with shape (0,)*ndim instead of (0, *core_shape). This caused silent shape mismatches in downstream operations like concatenation or broadcasting.
Add Scan.nit_sot_core_shapes() method that returns static core shapes when all are known, or None otherwise. All three backends (Python, Cython, Numba) now use correct shapes when known, and raise a clear
ValueError when shapes are unknown and n_steps=0.
We could consider making the shapes a symbolic input (PyTensor can often lift it out of the computation), a bit like numba BlockwiseWithCoreShape and RandomVariableWithCoreShape, but that's an improvement, not a must.
Now we don't silently return garbage.
Closes #1287