- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 75
 
Chainrules rrules for Mooncake, LinearSolve integration #801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| # rrules for LinearCache | ||
| @from_chainrules MinimalCtx Tuple{typeof(init),LinearProblem,SciMLLinearSolveAlgorithm} true ReverseMode | ||
| @from_chainrules MinimalCtx Tuple{typeof(init),LinearProblem,Nothing} true ReverseMode | ||
| 
               | 
          ||
| # rrule for solve! | ||
| @from_chainrules MinimalCtx Tuple{typeof(SciMLBase.solve!),LinearCache,SciMLLinearSolveAlgorithm} true ReverseMode | ||
| @from_chainrules MinimalCtx Tuple{typeof(SciMLBase.solve!),LinearCache,Nothing} true ReverseMode | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are mutating, so there are no chain rules.
| CRC.rrule(T, cache, alg, args...; kwargs) | ||
| end | ||
| 
               | 
          ||
| function CRC.rrule(::typeof(SciMLBase.solve!), cache::LinearSolve.LinearCache, alg::LinearSolve.SciMLLinearSolveAlgorithm, args...; alias_A=default_alias_A( | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a mutating rule... is it okay to do this with CRC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the chainrules rrules for Mooncake are actually only used in Mooncake's derived rruleset context. So i dint face any issues with the required tests.
But yes it would be safer to write Mooncake rrules here as chainrules in general don't support mutation in reverse mode. I'll try adding the changes (avoided till now due to Mooncake.fdata mutation for structs)
Allows for Mooncake to be used for functions using
solve!,init.Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.