Repository navigation
Preserve broadcast operand shapes in solve gradients - #831
Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
AHMETHAKANBEZIR1 wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Differentiating
numpy.linalg.solvewith broadcast operands can fail or return a gradient with the wrong shape. For example, NumPy 2 evaluatessolve(A, b)forA.shape == (3, 2, 2)andb.shape == (2,), but either reverse-mode gradient raises a core-dimension error. A shared matrix with batched matrix right-hand sides also receives an unreduced, incorrectly shaped gradient.Determine vector right-hand sides using the installed NumPy version's solve semantics, promote them explicitly for the adjoint solve, and reduce each operand's gradient back to its original broadcast shape with the existing
unbroadcast_fhelper. Constant Python-list right-hand sides continue to work.Validation:
git diff --checkpass. Separate complex, all-entry finite-difference checks cover both NumPy versions and agree within 4e-11.AI disclosure: OpenAI Codex autonomously prepared the code, tests, and this description. Validation and an additional AI review were performed; there has been no independent human review.