-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Address invalidations caused by overloading Base.show()
#1354
Address invalidations caused by overloading Base.show()
#1354
Conversation
No, generally you don't have to define a mime type if you implement I think the main issue here might actually be defining |
For context, I imagine that Mike added the last line (defining show for |
Based on previous reports, my main worry with removing the method wholesale is that we will literally crash people's terminals printing stacktraces for larger models. Is there something we can do to limit the length/depth of type params printed for |
I'm not completely sure, I think the best (only?) solution to this problem of overly elaborate stacktraces and types in general is to fix it in base. There are many open issues (and some PRs it seems) that are concerned with exactly this problem, e.g. JuliaLang/julia#36517, JuliaLang/julia#40735, JuliaLang/julia#43260. Sometimes there are other tricks for simplifying stacktraces (e.g., shorter custom tags for ForwardDiff that you (safely) pass around only internally, as we do e.g. in SciML and Turing) but I don't know of any general solution. |
I've also been following that work, but it seems like things have barely moved since a year ago... To get a decent idea of the impact, we could take a decent-sized Metalhead model and add a function which throws an error on the backwards pass to the deepest part of the network. I won't be able to get to this super quickly, so if anyone wants to take a shot please go for it. |
One can compare the output of the failing tests with Julia nightly on the master branch and in #1356: For instance, compare https://github.com/FluxML/Zygote.jl/actions/runs/3888925581/jobs/6636732018#step:6:500 and https://github.com/FluxML/Zygote.jl/actions/runs/3891821243/jobs/6642519244#step:6:559 Clearly, without the invalidating method of |
Looks like ComponentArrays went through a similar discussion. Thoughts on the Preferences.jl idea mentioned in that thread? |
I don't really see how that would be useful. If it's enabled by default, the invalidations would still be present for most (and definitely the non-advanced) users. And if it's disabled by default, the problem with large stacktraces would still be present for most users. Edit: Sorry, closed the PR by accident. |
If opt-in, it would at least give us an escape hatch for when stacktrace length is causing issues. Ideally we could mark the Back to the PR at hand, I don't think the 3-arg show methods defined here work for stacktraces at the REPL? |
As I said above, I think the PR is not the right fix - that's why I opened #1356 😉 |
Right, based on those comments I assumed it would at least be functional despite the continued piracy. Is there somewhere this method does work, or will it flat out never be called in regular usage? |
It should work if e.g. you run something like julia> typeof(f) in the REPL where |
Looks like I stumbled into a deeper issue. I suggest closing this issue in favour of #1356 to streamline the discussion (and clear up the issues board). |
While hunting down causes of large compilation times for a package I am developing, I found that
the largest number of invalidations were caused by two lines in Zygote.jl
(note: all timings are with Julia v1.8.5 and Zygote v0.6.54)
Specifically (in
show.jl
), theseneed a mime type defined, e.g.
Here are comparisons before and after the change: