Use a package extension for Enzyme.jl#312
Merged
Merged
Conversation
Contributor
Member
Author
b97ff8d to
6dcabf8
Compare
6dcabf8 to
f07ac89
Compare
Member
Author
|
@michel2323 The error is: ERROR: EnzymeRuntimeActivityError: Detected potential need for runtime activity.
Constant memory is stored (or returned) to a differentiable variable and correctness cannot be guaranteed with static activity analysis.
This might be due to the use of a constant variable as temporary storage for active memory (https://enzyme.mit.edu/julia/stable/faq/#faq-runtime-activity).
If Enzyme should be able to prove this use non-differentable, open an issue!
To work around this issue, either:
a) rewrite this variable to not be conditionally active (fastest performance, slower to setup), or
b) set the Enzyme mode to turn on runtime activity (e.g. autodiff(set_runtime_activity(Reverse), ...) ). This will maintain correctness, but may slightly reduce performance.
Failure within method:
DOCP_objective(::Vector{Float64}, ::CTDirect.DOCP{CTDirect.Midpoint, Model{…}, CTDirect.ADNLPBackend})
@ CTDirect ~/.julia/packages/CTDirect/DgVuH/src/docp.jl:614
Hint: catch this exception as `err` and call `code_typed(err)` to inspect the surrounding code.
Mismatched activity for: %value_phi = phi ptr addrspace(10) [ %6, %L12 ], [ %5, %L9 ] const val: %5 = load atomic ptr addrspace(10), ptr addrspace(11) %4 unordered, align 8, !dbg !92, !tbaa !94, !alias.scope !98, !noalias !99, !enzyme_type !100, !enzymejl_source_type_Vector\7BFloat64\7D !0, !enzymejl_byref_MUT_REF !0
Julia value causing error: Unknown object of type Vector{Float64}
LLVM view of erring value: %5 = load atomic ptr addrspace(10), ptr addrspace(11) %4 unordered, align 8, !dbg !92, !tbaa !94, !alias.scope !98, !noalias !99, !enzyme_type !100, !enzymejl_source_type_Vector\7BFloat64\7D !0, !enzymejl_byref_MUT_REF !0
Stacktrace:
[1] getproperty
@ ./Base_compiler.jl:54
[2] get_OCP_variable
@ ~/.julia/packages/CTDirect/DgVuH/src/disc/common.jl:12
[3] DOCP_objective
@ ~/.julia/packages/CTDirect/DgVuH/src/docp.jl:622
Stacktrace:
[1] getproperty
@ ./Base_compiler.jl:54 [inlined]
[2] DOCP_objective
@ ~/.julia/packages/CTDirect/DgVuH/src/docp.jl:620
[3] #4
@ ~/.julia/packages/CTDirect/DgVuH/ext/CTDirectExtADNLP.jl:30 [inlined]
[4] augmented_julia__4_40863_inner_36wrap
@ ~/.julia/packages/CTDirect/DgVuH/ext/CTDirectExtADNLP.jl:0
[5] macro expansion
@ ~/.julia/packages/Enzyme/S3nC6/src/compiler.jl:6672 [inlined]
[6] enzyme_call
@ ~/.julia/packages/Enzyme/S3nC6/src/compiler.jl:6151 [inlined]
[7] AugmentedForwardThunk
@ ~/.julia/packages/Enzyme/S3nC6/src/compiler.jl:6099 [inlined]
[8] autodiff(mode::ReverseMode{…}, f::Const{…}, ::Type{…}, args::Duplicated{…})
@ Enzyme ~/.julia/packages/Enzyme/S3nC6/src/Enzyme.jl:419
[9] gradient!(::ADNLPModels.EnzymeReverseADGradient, g::Vector{Float64}, f::Function, x::Vector{Float64})
@ ADNLPModelsEnzymeExt ~/Bureau/git/ADNLPModels.jl/ext/ADNLPModelsEnzymeExt.jl:73
[10] grad!(nlp::ADNLPModels.ADNLPModel{Float64, Vector{Float64}, Vector{Int64}}, x::Vector{Float64}, g::Vector{Float64})The related code is defined here. cc @ocots @jbcaillau |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
12/02/2026: I also remove all the code for
Zygote, it is not anymore relevant in 2026...I prefer to spend time on the support of
DI.jl.