Closed willtebbutt closed 2 years ago
Can we test the performance in some reliable way to avoid regressions?
You would need to add tests on the benchmark.jl in master first.
You would need to add tests on the benchmark.jl in master first.
Do I literally just need to add the ConstantKernel
to line 19 of benchmarks.jl
? Also, how is it that I trigger the benchmark suite?
Or are the AD-related benchmarking tests not on master yet? They don't appear to use Zygote.
edit: sorry, I thought we had AD-related performance checks somewhere.
@devmotion @theogf would either of you mind if I add them in this PR? I guess we might as well start tracking this stuff.
Merging #432 (0de2c43) into master (cbbf1d4) will decrease coverage by
0.14%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## master #432 +/- ##
==========================================
- Coverage 93.14% 92.99% -0.15%
==========================================
Files 52 52
Lines 1210 1214 +4
==========================================
+ Hits 1127 1129 +2
- Misses 83 85 +2
Impacted Files | Coverage Δ | |
---|---|---|
src/basekernels/constant.jl | 100.00% <100.00%> (ø) |
|
src/chainrules.jl | 85.18% <0.00%> (-2.47%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update cbbf1d4...0de2c43. Read the comment docs.
would either of you mind if I add them in this PR? I guess we might as well start tracking this stuff.
Sure but I am not sure if it works if you change the benchmark file in the PR before in the doing it in master
Ahh okay. I'll merge as-is then, and address benchmarking later.
Docs fail because of https://github.com/JuliaGaussianProcesses/KernelFunctions.jl/blob/cbbf1d4c540909eff95170c7a591472fe5dbd2ae/examples/gaussian-process-priors/script.jl#L52
It looks one cannot add I
to a FillMatrix
[EDIT:] Using Eye
instead would work but I don't think that we want that...
Ahh okay. I'll just go with fill
for now then -- it's still a big win.
I opened an issue in FillArrays
https://github.com/JuliaArrays/FillArrays.jl/issues/170
Ah, that's an unfortunate upstream bug it seems (with an easy fix probably?). I guess we could just use a full matrix or Eye
in the example.
It seems a bit unfortunate to not exploit the performance benefits, only because it breaks this example.
I agree that it's a shame, but I'm still inclined to merge when CI passes, unless there are strong objections. We can always improve once stuff is fixed in FillArrays.
I made an issue to remember.
No strong objections, just a bit sad :cry: I'm looking forward to changing it to Fill
(maybe open an issue?), it seems it would be a drastic improvement (2ms vs 37ns in the foo
benchmark, and 2ms vs 5μs in Zygote.pullback) :slightly_smiling_face:
Summary
I found a lovely pathological Zygote-related performance problem.
Proposed changes
Optimisations for
kernelmatrix
for the ConstantKernelWhat alternatives have you considered?
The only other option is to improve Zygote's handling of
map
. Unfortunately I can't see Zygote improving here in the immediate future (I certainly don't have time to look into it right now).Breaking changes
None
Performance
Here's a demo of how awful the performance is at the minute vs this PR:
You get similar results for the two-argument method of
kernelmatrix
.