Repository navigation
Fix the JVP of pivoted QR for wide matrices - #42634
Open
bhaskargurram-ai wants to merge 1 commit into
Open
bhaskargurram-ai wants to merge 1 commit into
bhaskargurram-ai wants to merge 1 commit into
Conversation
For m < n the JVP computes dR2 = dQ^H X2 + Q^H dX2, where X2 holds the trailing columns of X. With pivoting, Q R = X P, so X2 must come from the permuted matrix like dX does. Using the unpermuted X gave wrong derivatives for the trailing columns of R. Also run the JVP check in testScipyQrModes for all pivoting cases except mode='r'.
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.
Fixes #42633
With
pivoting=Trueand a wide input (m < n), the JVP of the R factor fromlax.linalg.qr/jax.scipy.linalg.qrwas wrong for the trailing n - m columns, so gradients through R were silently incorrect.The wide-case rule computes
dR2 = dQ^H X2 + Q^H dX2. With pivotingQ R = X P, and the rule already permutesdx, butX2was taken from the unpermutedx. This applies the same permutation tox.Test:
testScipyQrModesonly ran its pivoted JVP check for square and tall economic shapes. It now runs for every pivoting mode exceptmode='r'(which has no Q). The new wide cases fail on main and pass with this change; the tallmode='full'cases already passed.