Skip to content

Conversation

@wsmoses
Copy link
Member

@wsmoses wsmoses commented Nov 14, 2025

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/compiler.jl b/src/compiler.jl
index 496033a7..78c19b7b 100644
--- a/src/compiler.jl
+++ b/src/compiler.jl
@@ -385,11 +385,11 @@ end
     ::AdjointThunk{PT,FA,RT,TT,Width,TapeType},
 ) where {PT,FA,RT,TT,Width,TapeType} = TapeType
 
-@inline fn_type(::Type{<:CombinedAdjointThunk{<:Any,FA}}) where FA = FA
-@inline fn_type(::Type{<:ForwardModeThunk{<:Any,FA}}) where FA = FA
-@inline fn_type(::Type{<:AugmentedForwardThunk{<:Any,FA}}) where FA = FA
-@inline fn_type(::Type{<:AdjointThunk{<:Any,FA}}) where FA = FA
-@inline fn_type(::Type{<:PrimalErrorThunk{<:Any,FA}}) where FA = FA
+@inline fn_type(::Type{<:CombinedAdjointThunk{<:Any, FA}}) where {FA} = FA
+@inline fn_type(::Type{<:ForwardModeThunk{<:Any, FA}}) where {FA} = FA
+@inline fn_type(::Type{<:AugmentedForwardThunk{<:Any, FA}}) where {FA} = FA
+@inline fn_type(::Type{<:AdjointThunk{<:Any, FA}}) where {FA} = FA
+@inline fn_type(::Type{<:PrimalErrorThunk{<:Any, FA}}) where {FA} = FA
 
 using .JIT
 
@@ -5397,7 +5397,7 @@ end
 ) where {PT,FA,Width,RT,TT,TapeT} = enzyme_call(
     Val(true),
     thunk.adjoint,
-    AdjointThunk{PT,FA,RT,TT,Width,TapeT},
+    AdjointThunk{PT, FA, RT, TT, Width, TapeT},
     Val(Width),
     Val(false),
     TT,
@@ -5413,7 +5413,7 @@ end
 ) where {PT,FA,Width,RT,TT,ReturnPrimal,TapeT} = enzyme_call(
     Val(false),
     thunk.primal,
-    AugmentedForwardThunk{PT,FA,RT,TT,Width,ReturnPrimal,TapeT},
+    AugmentedForwardThunk{PT, FA, RT, TT, Width, ReturnPrimal, TapeT},
     Val(Width),
     Val(ReturnPrimal),
     TT,
@@ -5429,7 +5429,7 @@ end
 ) where {PT,FA,Width,RT,TT,ReturnPrimal,TapeT} = enzyme_call(
     Val(true),
     thunk.primal,
-    AugmentedForwardThunk{PT,FA,RT,TT,Width,ReturnPrimal,TapeT},
+    AugmentedForwardThunk{PT, FA, RT, TT, Width, ReturnPrimal, TapeT},
     Val(Width),
     Val(ReturnPrimal),
     TT,
@@ -5465,11 +5465,11 @@ end
     ::Val{returnPrimal},
     tt::Type{T},
     rt::Type{RT},
-    fn,
+        fn,
     ::Type{TapeType},
     args::Vararg{Any,N},
-) where {RawCall,PT,T,RT,TapeType,N,CC,width,returnPrimal}
-        FA = fn_type(CC)
+    ) where {RawCall, PT, T, RT, TapeType, N, CC, width, returnPrimal}
+    FA = fn_type(CC)
         F = eltype(FA)
         is_forward =
             CC <: AugmentedForwardThunk || CC <: ForwardModeThunk || CC <: PrimalErrorThunk
@@ -5497,48 +5497,50 @@ end
         end
 
         if !RawCall && !(CC <: PrimalErrorThunk)
-            argtys = copy(argtypes)
+        argtys = copy(argtypes)
 
-            pushfirst!(argtys, FA)
+        pushfirst!(argtys, FA)
 
-            hint = "Arguments to the thunk should be the activities of the function and arguments"
+        hint = "Arguments to the thunk should be the activities of the function and arguments"
 
-            if is_adjoint
-                if rettype <: Active ||
-                   rettype <: MixedDuplicated ||
-                   rettype <: BatchMixedDuplicated
+        if is_adjoint
+            if rettype <: Active ||
+                    rettype <: MixedDuplicated ||
+                    rettype <: BatchMixedDuplicated
 
-                    push!(argtys,
-                        if width == 1
-                            eltype(rettype)
-                        else
-                            NTuple{width,eltype(rettype)}
-                        end)
+                push!(
+                    argtys,
                     if width == 1
-                        hint *=", then the seed of the active return"
+                        eltype(rettype)
                     else
-                        hint *=", then an NTuple of width $width for the seeds of the batched active return"
+                        NTuple{width, eltype(rettype)}
+                    end
+                )
+                if width == 1
+                    hint *= ", then the seed of the active return"
+                else
+                    hint *= ", then an NTuple of width $width for the seeds of the batched active return"
                     end
                 end
 
-            end
+        end
 
-            if needs_tape
-                push!(argtys, TapeType)
-                hint *=", then the tape from the forward pass"
-            end
+        if needs_tape
+            push!(argtys, TapeType)
+            hint *= ", then the tape from the forward pass"
+        end
 
-            truety = Tuple{argtys...}
-            if length(argtys) != length(args) + 1
-                return quote
-                    throw(ThunkCallError($CC, $fn, $args, $truety, $hint))
+        truety = Tuple{argtys...}
+        if length(argtys) != length(args) + 1
+            return quote
+                throw(ThunkCallError($CC, $fn, $args, $truety, $hint))
                 end
-            end
+        end
 
-            for (expected, found) in zip(argtys, (fn, args...))
-                if !(found <: expected)
+        for (expected, found) in zip(argtys, (fn, args...))
+            if !(found <: expected)
                     return quote
-                        throw(ThunkCallError($CC, $fn, $args, $truety, $hint))
+                    throw(ThunkCallError($CC, $fn, $args, $truety, $hint))
                     end
                 end
             end
diff --git a/src/errors.jl b/src/errors.jl
index c6c949bc..77c56e88 100644
--- a/src/errors.jl
+++ b/src/errors.jl
@@ -1647,7 +1647,7 @@ end
 struct ThunkCallError <: Exception
     thunk::Type
     fn::Type
-    args::(NTuple{N, Type} where N)
+    args::(NTuple{N, Type} where {N})
     correct::Type
     hint::String
 end
@@ -1656,17 +1656,17 @@ function Base.showerror(io::IO, e::ThunkCallError)
     print(io, "ThunkCallError:\n")
     print(io, "  No method matching:\n    ")
     Base.show_signature_function(io, e.thunk)
-    Base.show_tuple_as_call(io, :var"", Tuple{e.fn, e.args...}, hasfirst=false)
+    Base.show_tuple_as_call(io, :var"", Tuple{e.fn, e.args...}, hasfirst = false)
     println(io)
     println(io)
     print(io, "  Expected:\n    ")
     Base.show_signature_function(io, e.thunk)
-    Base.show_tuple_as_call(io, :function, e.correct; hasfirst=false, kwargs=nothing)
+    Base.show_tuple_as_call(io, :function, e.correct; hasfirst = false, kwargs = nothing)
     println(io)
     println(io)
 
     printstyled(io, "Hint"; bold = true, color = :cyan)
-    printstyled(
+    return printstyled(
         io,
         ": " * e.hint * "\n",
         color = :cyan,
diff --git a/test/errors.jl b/test/errors.jl
index 3a23b80a..9e70cc26 100644
--- a/test/errors.jl
+++ b/test/errors.jl
@@ -8,15 +8,15 @@ end
 
 
 function sumsin(x)
-	return sin(sum(x))
+    return sin(sum(x))
 end
 
 @testset "Incorrect thunk arguments" begin
-	fwd, rev = Enzyme.autodiff_thunk(ReverseSplitNoPrimal, Const{typeof(sumsin)}, Active, Duplicated{Vector{Float64}})
+    fwd, rev = Enzyme.autodiff_thunk(ReverseSplitNoPrimal, Const{typeof(sumsin)}, Active, Duplicated{Vector{Float64}})
 
-	@test_throws Enzyme.Compiler.ThunkCallError fwd(Duplicated([1.0], [2.0]))
-	
-	@test_throws Enzyme.Compiler.ThunkCallError fwd(Const(sumsin), Duplicated([1.0], [2.0]), Active(3.14))
+    @test_throws Enzyme.Compiler.ThunkCallError fwd(Duplicated([1.0], [2.0]))
+
+    @test_throws Enzyme.Compiler.ThunkCallError fwd(Const(sumsin), Duplicated([1.0], [2.0]), Active(3.14))
 end
 
 

@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.96%. Comparing base (05d589a) to head (5ec28ce).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/errors.jl 6.66% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2780      +/-   ##
==========================================
+ Coverage   68.94%   68.96%   +0.01%     
==========================================
  Files          58       58              
  Lines       19961    19994      +33     
==========================================
+ Hits        13763    13788      +25     
- Misses       6198     6206       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

Benchmark Results

main 5ec28ce... main / 5ec28ce...
basics/make_zero/namedtuple 0.067 ± 0.0096 μs 0.0675 ± 0.011 μs 0.992 ± 0.22
basics/make_zero/struct 0.259 ± 0.018 μs 0.263 ± 0.015 μs 0.987 ± 0.09
basics/overhead 3.18 ± 0.003 ns 3.46 ± 0.002 ns 0.919 ± 0.001
basics/remake_zero!/namedtuple 0.227 ± 0.02 μs 0.226 ± 0.014 μs 1 ± 0.11
basics/remake_zero!/struct 0.228 ± 0.016 μs 0.23 ± 0.017 μs 0.993 ± 0.1
fold_broadcast/multidim_sum_bcast/1D 11 ± 0.39 μs 11.1 ± 1.2 μs 0.989 ± 0.11
fold_broadcast/multidim_sum_bcast/2D 12.2 ± 0.45 μs 12.4 ± 0.47 μs 0.991 ± 0.052
time_to_load 1.39 ± 0.011 s 1.39 ± 0.019 s 1 ± 0.016

Benchmark Plots

A plot of the benchmark results has been uploaded as an artifact at https://github.com/EnzymeAD/Enzyme.jl/actions/runs/19353197931/artifacts/4564249973.

@wsmoses wsmoses merged commit ab96c82 into main Nov 14, 2025
47 of 54 checks passed
@wsmoses wsmoses deleted the terr branch November 14, 2025 05:44
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.

2 participants