-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add lazy kronecker product for matrix kernels, if Kronecker.jl is loaded #364
Conversation
Having looked at However, for the MO use-case, the calling is exactly the same as for plain |
This was my preferred option as well, I just had some issues with getting the function to overwrite correctly/ thought about making it more explicit to the user. However, I was able to sort out the code issues that I had, and have now made some changes that clean up the code substantially I think. I think what is missing though is clear documentation about this., so I will add that soon. |
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.
I think this broadly looks good -- would just like some code moved around I think.
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.
I'm happy for this to go in now. Just needs a patch bump, then please feel free to merge and tag when CI passes.
The test errors seem real: https://github.com/JuliaGaussianProcesses/KernelFunctions.jl/pull/364/checks?check_run_id=3675219571#step:6:123 (and the same with the stable Julia version) I assume this is caused by the hardcoded |
This is very odd, because previously the tests passed, and I didn't think that I changed anything that would affect this. |
Looking at the error, I think the optimal fix is probably just to make the pullbacks defined for pairwise of My reasoning is as follows: based on the CI logs that @devmotion linked, it looks like a edit: just tried this locally and can confirm that it works. |
I just had a look at the successful test from a week (or so) ago (https://github.com/JuliaGaussianProcesses/KernelFunctions.jl/runs/3613631221), and while I am not 100% sure I am looking at the right things I see that Zygote has gone from 0.6.21 to 0.6.22 (this happened 13h ago in fact, https://github.com/FluxML/Zygote.jl/releases). |
Yeah, that seems like a likely culprit, specfically FluxML/Zygote.jl#1044 . It's 100% a bug fix though, so we've done that classic thing whereby KF only works properly because of a bug in Zygote. Tbh, the rules in question should probably all be declared no-ops from an AD perspective using |
After some bad handling of of git on my part, I have now made some changes, I hope I understood correctly what you suggested. |
Looks like it's nearly there. Just also needs the same kind of modification here if I'm interpretting the CI logs correctly. |
Ok, tests are passing now. I should be ready to merge now I think (I don't have permission to merge). |
This doesn't seem great for Zygote flexibility wise. It shouldn't be returning ChainRules types since most rules shouldn't be written to handle them. We should convert these to Zygote friendly types where something like this happens. |
Sorry @DhairyaLGandhi I don't follow. Which bit in particular are you referring to? |
Needing to have adjoints be aware of (/explicitly handle) ChainRules's types, I mean. |
Oh, but we're just writing |
Summary
Following #354 this PR adds lazy Kronecker products for the
IndependentMOKernel
and theIntrinsicCoregionMOKernel
via an optional dependency on Kronecker.jl. Also includes comments and thoughts from the previous PR.Proposed changes
kronecker_kernelmatrix
What alternatives have you considered?
The name for
kronecker_kernelmatrix
is perhaps not ideal, maybe an additionalmo
suffix/prefix is needed. I think conflating this withkernelkronmat
would be confusing.I have also considered making the
_mo_output_covariance
function apply also for the regularkernelmatrix
, but this may cause conflicts with #363 , and would have to be done once both are resolved.Breaking changes
None.