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

EnzymeExt ignores runtime activity #115

Open
ptiede opened this issue Oct 3, 2024 · 4 comments
Open

EnzymeExt ignores runtime activity #115

ptiede opened this issue Oct 3, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@ptiede
Copy link

ptiede commented Oct 3, 2024

In Enzyme 0.13 runtime activity is now enabled in the ReverseMode type explicitly. For instance with ADtypes it would be done with

OptimizationFunction(f, AutoEnzyme(;mode=set_runtime_activity(Reverse)))

However, this isn't being respected in OptimizationEnzymeExt where Reverse and Forward are hardcoded.
For example

if g == true && f.grad === nothing
function grad(res, θ, p = p)
Enzyme.make_zero!(res)
Enzyme.autodiff(Enzyme.Reverse,
Const(firstapply),
Active,
Const(f.f),
Enzyme.Duplicated(θ, res),
Const(p)
)
end
elseif g == true
grad = (G, θ, p = p) -> f.grad(G, θ, p)
else
grad = nothing
end

forces Enzyme.Reverse regardless of the passed mode.

@ptiede ptiede added the bug Something isn't working label Oct 3, 2024
@Vaibhavdixit02
Copy link
Member

@gdalle how should this be accessed with SecondOrder, is so_adtype.inner.mode and so_adtype.outer.mode the recommended way?

@gdalle
Copy link
Contributor

gdalle commented Oct 4, 2024

DifferentiationInterface makes the functions inner and outer public, but without exporting them. So if you have backend = SecondOrder(AutoEnzyme(; mode=Forward), AutoEnzyme(; mode=Reverse)) then you can do inner(backend).mode.
Note that inner and outer will function as the identity on any AbstractADType that is not a SecondOrder.

@Vaibhavdixit02
Copy link
Member

That makes sense, I just needed to confirm

@gdalle
Copy link
Contributor

gdalle commented Oct 4, 2024

Always a better idea to use documented accessors instead of private internals ;) wink wink SparseMatrixColorings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants