-
Notifications
You must be signed in to change notification settings - Fork 5
update pullback tolerances #92
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
Conversation
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
|
I do think it makes sense if |
src/common/defaults.jl
Outdated
| return eps(eltype(n))^(3 / 4) * max(n, one(n)) | ||
| end | ||
| default_pullback_gauge_atol(A) = eps(norm(A, Inf))^(3 / 4) | ||
| default_pullback_gauge_atol(A, As...) = maximum(default_pullback_gauge_atol, (A, As...)) |
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 don't think this multi-argument definition is necessary (I realised this yesterday after closing my computer and going to bed). Simply dong default_pullback_gauge_atol((ΔU, ΔVᴴ)) should be ok; norm((a,b), Inf) is automatically compiled to max(norm(a, Inf), norm(b, Inf)).
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.
Ok. If I am very nit-picky, I would say this leads to a type instability in the case of one of the two adjoints of the svd being zero, but I assume this is ok, as it will also not propagate to the output of the functions where this gauge_tol is being used, as it is just in a comparison.
julia> @code_warntype default_pullback_gauge_atol(ZeroTangent(), randn(5,5))
MethodInstance for default_pullback_gauge_atol(::ZeroTangent, ::Matrix{Float64})
from default_pullback_gauge_atol(A, As...) @ Main REPL[5]:1
Arguments
#self#::Core.Const(Main.default_pullback_gauge_atol)
A::Core.Const(ZeroTangent())
As::Tuple{Matrix{Float64}}
Body::Any
1 ─ %1 = Main.maximum::Core.Const(maximum)
│ %2 = Main.default_pullback_gauge_atol::Core.Const(Main.default_pullback_gauge_atol)
│ %3 = Core.tuple(A)::Core.Const((ZeroTangent(),))
│ %4 = Core._apply_iterate(Base.iterate, Core.tuple, %3, As)::Tuple{ZeroTangent, Matrix{Float64}}
│ %5 = (%1)(%2, %4)::Any
└── return %5
|
I am wondering if this is tested where one of the adjoint variables is |
|
I think this should now be handled, although it still has the multi-argument definition to make sure that we are actually intercepting the call to |
|
I tried again, I think this should now be type stable on the condition that |
|
|
* Bump v0.6 * rename `gaugefix` -> `fixgauge` * reduce unnecessary warnings * fix `copy_input` signatures in Mooncake tests * Add changelog to docs
Attempt to address #89
I've updated the tolerances across all pullbacks to follow this logic:
degeneracyandrankare determined by default relative to the normgaugeare determined relative to 1Or, in other words, gauge tolerances are absolute while degeneracy and rank tolerances are relative.
I would have really liked to have a better relative criterion for the gauge tolerance as well, but can't really come up with a satisfactory solution.
I'm guessing that the idea is that the cotangent in the direction of the gauge should be small compared to the total norm of the cotangent (is that even true?), so possibly we could consider an approach like that, but already this should be an improvement.