-
Notifications
You must be signed in to change notification settings - Fork 89
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
Fix for julia 1.9 #718
Fix for julia 1.9 #718
Conversation
The test we need to pass is using ChainRulesTestUtils
using Test
using ChainRulesCore
@testset "$f" for f in (/, \)
@testset "Matrix" begin
for n in 3:5, m in 3:5
A = randn(m, n)
B = randn(m, n)
test_rrule(f, A, B; check_inferred=false) # ChainRulesCore #407
end
end
@testset "Vector" begin
x = randn(10)
y = randn(10)
test_rrule(f, x, y; check_inferred=false) # ChainRulesCore #407
end
if f == (\)
@testset "Matrix $f Vector" begin
X = randn(10, 4)
y = randn(10)
test_rrule(f, X, y)
end
@testset "Vector $f Matrix" begin
x = randn(10)
Y = randn(10, 4)
test_rrule(f, x, Y; output_tangent=Transpose(rand(4)))
end
else
A = rand(2, 4)
B = rand(4, 4)
test_rrule(f, A, B; check_inferred=false) # ChainRulesCore #407
end
end |
Oh interesting x86 (32bit) segfaults |
@antoine-levitt you were going to review this? |
Yes sorry I commented on the other issue here: JuliaLang/julia#49915 (comment). I don't think that's the way to go, because it computes explicit pseudo-inverses. Instead, you can just do something like |
Ok cool are you abble to review this PR and if it looks good now approve so i can merge? |
I don't understand why you're doing this. Can't this PR literally be |
Ah, sorry, I didn't get that it was to factor only once. This is not an exact optimization, because |
But
Presumably that method needs to be added to factorize for that to work, I'll try to do a PR on julia. In the meantime, you can get by using the |
So I pulled out everything except your suggested change @antoine-levitt, and this still fails. ( we can make a follow up to pre-factorize once things are not longer broken on julia 1.9) Not sure why. Do you have any clue? I think it would be good to nail this down before JuliaLang/julia#49915 gets discussed by triage. |
Yeah same problem just a bit below:
That Y (but not the one above) needs to be []ified too. |
With that the |
What's your MWE? It looks like it's working for me. And what do you mean by accuracy? |
I am just running the tests: julia> using ChainRules, ChainRulesCore, ChainRulesTestUtils, Test
julia> @testset "$f" for f in (/, \)
@testset "Matrix" begin
for n in 3:5, m in 3:5
A = randn(m, n)
B = randn(m, n)
test_rrule(f, A, B; check_inferred=false) # ChainRulesCore #407
end
end
@testset "Vector" begin
x = randn(10)
y = randn(10)
test_rrule(f, x, y; check_inferred=false) # ChainRulesCore #407
end
if f == (\)
@testset "Matrix $f Vector" begin
X = randn(10, 4)
y = randn(10)
test_rrule(f, X, y)
end
@testset "Vector $f Matrix" begin
x = randn(10)
Y = randn(10, 4)
test_rrule(f, x, Y; output_tangent=Transpose(rand(4)))
end
else
A = rand(2, 4)
B = rand(4, 4)
test_rrule(f, A, B; check_inferred=false) # ChainRulesCore #407
end
end You can see it failing in CI: https://github.com/JuliaDiff/ChainRules.jl/actions/runs/5143424642/jobs/9258419472?pr=718#step:6:804 By accuracy I mean: It is giving significantly numerically different results to finite differencing. |
That's just a typo, you wrote
which is doing |
ah lol, in trying to simplify the problem I caused new ones |
Still getting errors.
we have that See the whole complexity of this to me is really saying that, it is kinda needed that |
works for me.
This workaround is needed because of the interaction of vector' * vector being a scalar (which is reasonable and isn't really questionned) and vector \ vector being pinv(A)*B. I think there's a consensus for saying that vector/vector and vector\vector working was a bad leftover from matlab (where it's also a bad idea, but unavoidable since there's no distinction between vectors and 2x1 matrices there), and that it should be removed in 2.0 in favor of matrix\vector and vector/matrix (in which case, to get the old A/B for A and B vectors, you'd do A/hcat(B)), so that this issue just goes away. Again I'm pretty sure this issue is the result of an overzealous implementation of the rule to support the vector\vector usecase, which pretty much nobody uses (and nobody should use, since hopefully it will be gone in 2.0). |
Also make second Y not scalar more coercing some things into arrays some of the time cleaner def with a helper function
ok, merging this. Though can revert if JuliaLang/julia#49915 goes through. I am going to just note that 1.6 on 64 bit is broken. |
JuliaLang/julia#44358 broke our things on julia 1.9
this gets it back, but idk numerical linear algrebra so I am not sure it doesn't cost us anything.
Also inv is broken on GPU again.