Skip to content
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

Explicit Enzyme rules on Enzyme 0.13 #350

Merged
merged 15 commits into from
Nov 28, 2024
Merged

Explicit Enzyme rules on Enzyme 0.13 #350

merged 15 commits into from
Nov 28, 2024

Conversation

devmotion
Copy link
Member

I rebased #349 on #341 and adapted the PR to Enzyme 0.13.

@devmotion
Copy link
Member Author

The tests of the forward-mode rule pass on Julia 1.10 but fail on Julia 1.11 for all-Const arguments (it seems the rule is not picked up?). Tests of the batched reverse-mode error on both Julia 1.10 and 1.11 due to an LLVM error.

@yebai
Copy link
Member

yebai commented Nov 13, 2024

cc @wsmoses

@wsmoses
Copy link
Collaborator

wsmoses commented Nov 16, 2024

huh, yeah looks like we've never had anyone define a reverse-mode rule with a batched active [ie non duplicated return]. I've made it a beter error message in Enzyme. Probably just disable that test.

And open a mwe for the 1.11 issue?

@mhauru
Copy link
Member

mhauru commented Nov 26, 2024

Here's an issue for the error that only occurs on Julia v1.11: EnzymeAD/Enzyme.jl#2121

This might not be the root issue here though, like @devmotion says it seems like the rule defined here might just not get picked up?

@TuringLang TuringLang deleted a comment from github-actions bot Nov 26, 2024
@TuringLang TuringLang deleted a comment from github-actions bot Nov 26, 2024
@wsmoses
Copy link
Collaborator

wsmoses commented Nov 26, 2024

@mhauru can you open an issue for the fact the rule isn't getting picked up?

@devmotion
Copy link
Member Author

can you open an issue for the fact the rule isn't getting picked up

I tried to put together a small MWE for the issue last week but of course it worked without any problem 😅

After disabling the problematic tests, the EnzymeTestUtils tests of the rules pass. However, it seems Enzyme errors (in a quite nasty way) on Julia 1.11 (other Julia versions are fine) when running the the closely related tests in https://github.com/TuringLang/Bijectors.jl/blob/master/test/ad/flows.jl. Maybe it's also due to the rule not being picked up for some activities?

@wsmoses
Copy link
Collaborator

wsmoses commented Nov 27, 2024

Here's an issue for the error that only occurs on Julia v1.11: EnzymeAD/Enzyme.jl#2121

I looked at that issue it it appears to be a bug in Julia itself.

If you can open an issue for the lacking rule [maybe even start by taking bijectors itself and removing code as much as possible?], that would be helpful so we can make sure the rule is triggered for 1.11

In any case this PR lgtm and we can always follow it up

test/ad/utils.jl Outdated
if !(:EnzymeForwardCrash in broken)
if forward_broken
@test_broken(
collect(et, Enzyme.gradient(Enzyme.Forward, f, x)[1]) ≈ finitediff,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this collect shouldn't be required anymore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I removed it 🙂

test/ad/utils.jl Outdated
)
else
@test(
collect(et, Enzyme.gradient(Enzyme.Forward, f, x)[1]) ≈ finitediff,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here and below

@devmotion
Copy link
Member Author

In any case this PR lgtm and we can always follow it up

It seems we might be able to merge the PR, @yebai? The rules themselves and the update to Enzyme 0.13 seems fine in principle according to @wsmoses (thanks a lot for your help on the way!), the remaining test Enzyme test failure on 1.11 seems to be an upstream issue.

@yebai
Copy link
Member

yebai commented Nov 28, 2024

Thanks, @devmotion and @wsmoses -- it sounds good to merge this first.

@devmotion devmotion merged commit 1480e79 into master Nov 28, 2024
43 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants