-
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
Fix methodinstance usage and backedges #2199
Conversation
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
@@ -1258,6 +1272,8 @@ Create the methodinstance pair, and lookup the primal return type. | |||
@nospecialize(TT::Type), | |||
world::Union{UInt,Nothing} = nothing, | |||
) | |||
|
|||
fdsafdsafsa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
fwd_sig = Tuple{typeof(EnzymeRules.forward), <:EnzymeRules.FwdConfig, <:Enzyme.EnzymeCore.Annotation, Type{<:Enzyme.EnzymeCore.Annotation},Vararg{Enzyme.EnzymeCore.Annotation}} | ||
push!(edges, ccall(:jl_method_table_for, Any, (Any,), fwd_sig)::Core.MethodTable) | ||
push!(edges, fwd_sig) | ||
else | ||
push!(edges, GPUCompiler.methodinstance(typeof(Compiler.Interpreter.rule_backedge_holder), Tuple{typeof(EnzymeRules.augmented_primal)}, world)) | ||
rev_sig = Tuple{typeof(EnzymeRules.augmented_primal), <:EnzymeRules.RevConfig, <:Enzyme.EnzymeCore.Annotation, Type{<:Enzyme.EnzymeCore.Annotation},Vararg{Enzyme.EnzymeCore.Annotation}} | ||
push!(edges, ccall(:jl_method_table_for, Any, (Any,), rev_sig)::Core.MethodTable) | ||
push!(edges, rev_sig) | ||
|
||
rev_sig = Tuple{typeof(EnzymeRules.reverse), <:EnzymeRules.RevConfig, <:Enzyme.EnzymeCore.Annotation, Union{Type{<:Enzyme.EnzymeCore.Annotation}, Enzyme.EnzymeCore.Active}, Any, Vararg{Enzyme.EnzymeCore.Annotation}} | ||
push!(edges, ccall(:jl_method_table_for, Any, (Any,), rev_sig)::Core.MethodTable) | ||
push!(edges, rev_sig) | ||
end | ||
|
||
ina_sig = Tuple{typeof(EnzymeRules.inactive), Vararg{Any}} | ||
push!(edges, ccall(:jl_method_table_for, Any, (Any,), ina_sig)::Core.MethodTable) | ||
push!(edges, ina_sig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does look much better.
@@ -110,7 +94,7 @@ function rule_backedge_holder_generator(world::UInt, source, self, ft::Type) | |||
new_ci.slotflags = UInt8[0x00 for i = 1:2] | |||
|
|||
# return the codegen world age | |||
push!(new_ci.code, Core.Compiler.ReturnNode(0)) | |||
push!(new_ci.code, Core.Compiler.ReturnNode(world)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm this, on the other hand, looks horribly illegal.
@@ -198,6 +176,37 @@ function EnzymeInterpreter( | |||
else | |||
InferenceParams(; unoptimize_throw_blocks=false) | |||
end | |||
|
|||
@static if HAS_INTEGRATED_CACHE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also contemplating that Enzyme for 1.11 could simply not use the integrated cache...
But we might have removed some interface...
@@ -2,30 +2,32 @@ import EnzymeCore: Annotation | |||
import EnzymeCore.EnzymeRules: FwdConfig, RevConfig, forward, augmented_primal, inactive, _annotate_tt | |||
|
|||
function has_frule_from_sig(@nospecialize(interp::Core.Compiler.AbstractInterpreter), | |||
@nospecialize(TT), sv::Core.Compiler.AbsIntState)::Bool | |||
@nospecialize(TT::Type), sv::Core.Compiler.AbsIntState, partialedge::Bool=true)::Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is a partialedge
? It seems not used?
Hopefully now that I understand backedges, this fixes pending issues.
Simultaneously this gets rid of a bunch of inner generated functions so hopefully compile time comes down.
Time to first derivative (post precompile) is now: