-
Notifications
You must be signed in to change notification settings - Fork 68
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 DifferentiationInterface test suite #1563
Conversation
This was the result of a bad jll uptake yesterday, already caught by our existing CI, and has been fixed on main (and being released today). I'm not opposed to this in principle but the tests need to provide actionable feedback of Enzyme-specific MWE's. In any case since the existing suite caught this already, I'm going to assume the need for is moot and close. Feel free to re-open if you'd like. |
I can't reopen a PR you closed.
This specific bug was caught by your CI, but others may not be, and others have not been in the past. For instance, by using our type stability checks, you would have been able to catch #1401 right away.
What do you mean by this? Test failures in DifferentiationInterfaceTest are already fairly verbose and precise, take a look at the stack trace here for instance: https://github.com/gdalle/DifferentiationInterface.jl/actions/runs/9644116325/job/26595528876 |
We do generally add tests for any failures caught (so as an example the test you showed earlier led to us adding some inferred tests that should check the same). I guess the source of my hesitation here is that while adding these as integration tests is useful as a signal that everything is fine or not, the feedback isn't actionable to an enzyme dev. For example looking at the posted log:
I have no idea what the isolated function is, or the corresponding Enzyme.autodiff call which would correspond to it (required to successfully debug). If you would be able to print out a corresponding MWE with corresponding Enzyme.autodiff call which triggers that would be immensely useful. Also fwiw, adding this test suite here would not catch the bug before added, since, like mentioned this happened downstream in the jll. |
Yeah, the stack trace is not very useful here, what I meant was the test summary at the end. |
The issue is that it would require storing the result of every test somehow, instead of just relying on the nested |
Yeah I mean like I said before that's nice as an integration test, but that level of summary isn't sufficient to be able to debug -- which really requires an MWE of the fn and the autodiff. My hesitation here is that if someone has a PR which causes that to fail, they'd also have to look through a separate repo and have to try to disect what the failing code is, and how to reproduce it (after of course confirming whether that is indeed a bug or intended). Given that the bar to contribution is already relatively high, I'm hesitant to force devs to have to bear that burden (hence the ask for it to spit out an isolatable MWE). Otherwise it'll just get ignored, at which point there isn't much value in a check (like the present formatter) which is always assumed failing and never checked. |
Would it be enough if the test displayed a custom error message that gives you an MWE in DifferentiationInterface syntax? Something like: To reproduce this behavior, run the following Julia code and inspect the result: import Enzyme
using DifferentiationInterface, DifferentiationInterfaceTest
backend = AutoEnzyme()
f = DifferentiationInterfaceTest.num_to_arr_vector
x = 1.0
dy = float.(1:6)
pullback(f, backend, x, dy) |
I think here I'd really like to see the Enzyme autodiff / gradient / etc syntax [just to rule out false positives if from DI and lower the burden for Enzyme devs per above] |
If you can do that [and very minor make this a separate github CI target rather than default part of test suite], I'd be happy to merge! |
How would this be possible for operators that are not defined in Enzyme? For instance if DI.hessian fails? |
Even for existing operators, there are some I cannot use because of (apparent?) buggy behavior |
Yeah I think the "translate into an Enzyme.autodiff call" would only really be critical for a gradient. More complex ops, like hessian, etc I think would be completely fine to leave as DI.hessian/etc |
including jacobian, btw! |
+1 for more integration tests. Even if such tests don't provide Enzyme devs with immediate actionable feedback into what went wrong, they act as a canary in a coal mine – something somewhere broke, and should be investigated before a new release is made. As a compromise, I think you could pin the version of external packages in integration tests. That way, any failure is likely to indicate an internal regression, rather than simply indicating a new feature in a third-party library. |
Putting a standalone Enzyme call in the error message is something I don't have the skills or time to do, but if you have a reproducible test error involving DI, you can always Cthulhu your way through it until you hit the right Enzyme binding. Your call |
Closing for now because DITest is undergoing some major changes, but I'll be back |
Prompted by #1562, this PR adds some tests from DifferentiationInterfaceTest to the Enzyme test suite.
Our test suite has caught numerous bugs in the past, so it would be a great asset to check that new Enzyme releases don't jeopardize existing behavior.