You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Potential instability in backward pass for spectral operations (missing explicit gradient w.r.t. exponent / parameters) #25
matrix_power: backward does not return gradient w.r.t. exponent (parameter)
Description
Hi,
We would like to clarify a design choice in the matrix_power autograd function.
The implementation provides a carefully derived and stabilized gradient for the input matrix X, but does not return a gradient with respect to the exponent parameter. The backward currently returns:
@staticmethoddefbackward(ctx, grad_output):
s, U, s_modified=ctx.saved_tensorsexponent=ctx.exponentreturnmodeig_backward(
grad_output, s, U, s_modified, matrix_power.derivative, exponent
), None
So:
gradient w.r.t. X → explicitly implemented
gradient w.r.t. exponent → set to None
Practical impact
This appears for example in SPDBatchNormMeanVar, where the exponent depends on a learnable parameter:
In this case, since matrix_power.backward returns None for the exponent:
no gradient is propagated back to self.weight through this operation
Question
Is this behavior intentional?
Would it make sense to explicitly implement and return the gradient w.r.t. the exponent (similarly to what is done for X), to ensure consistency and numerical control?
We would be happy to contribute a PR if this aligns with the intended design.
This is something that Florian noticed too during the development, but we never had the time to fix. I was wondering, could you create an PR to address this? I would be happy to treat any other function that it is missing the backpropagation.
Activity
Marco-Congedo commentedon Apr 29, 2026
The proper spectral power backprop rule is needed also elsewhere, for example in
airm_geodesic.bruAristimunha commentedon Apr 29, 2026
This is something that Florian noticed too during the development, but we never had the time to fix. I was wondering, could you create an PR to address this? I would be happy to treat any other function that it is missing the backpropagation.
Marco-Congedo commentedon Apr 29, 2026
Good. Emma will do it soon