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

Change to DifferentiationInterface #46

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Change to DifferentiationInterface #46

wants to merge 24 commits into from

Conversation

zuhengxu
Copy link
Member

Change the optimization interface to DifferentatiationInterface for easier switch/test between different AD systems.

@Red-Portal
Copy link
Member

Looks good to me!

Copy link
Member

@sunxd3 sunxd3 left a comment

Choose a reason for hiding this comment

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

Thanks for doing this David, so rather minor things.

),
)
time_elapsed = @elapsed begin
opt_stats = []
Copy link
Member

Choose a reason for hiding this comment

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

If you want to avoid the abstract container (and map(identity,...) below) you could move the first iteration out of the loop. Or define it unitialized with local opt_stats here and set it in the i = 1 iteration, similar to

julia> function f(n::Int)
           local out
           i = 1
           while i <= n
               out = i == 1 ? [1] : [i + only(out)]
               i += 1
           end
           return only(out)
       end

julia> f(3)
6

ADTypes.AutoReverseDiff(false),
ADTypes.AutoEnzyme(),
ADTypes.AutoReverseDiff(; compile=false),
ADTypes.AutoMooncake(; config=Mooncake.Config()),
Copy link
Member

Choose a reason for hiding this comment

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

Why remove the test with Enzyme?

ADTypes.AutoReverseDiff(false),
# ADTypes.AutoEnzyme(), # not working now
ADTypes.AutoReverseDiff(; compile = false),
ADTypes.AutoMooncake(; config=Mooncake.Config()),
Copy link
Member

Choose a reason for hiding this comment

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

The test was working with Enzyme (and runtime activity) in https://github.com/TuringLang/NormalizingFlows.jl/pull/38/files.

Copy link

Choose a reason for hiding this comment

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

Maybe try with AutoEnzyme(mode=Enzyme.set_runtime_activity(Enzyme.Reverse))?

@sunxd3
Copy link
Member

sunxd3 commented Feb 24, 2025

@zuhengxu PR looks great, I can take over and finish integrating the reviews if you are busy

@zuhengxu
Copy link
Member Author

Thank you all for the review and comments!

@zuhengxu PR looks great, I can take over and finish integrating the reviews if you are busy

Hi @sunxd3, I'm bit busy before Thursday this week. It will be much appreciated if you can help to integrate some of the review! Otherwise I'll integrate them by this Friday.

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.

6 participants