Skip to content

Conversation

@KristofferC
Copy link
Collaborator

@KristofferC KristofferC commented Nov 25, 2025

I dusted off my four-year-old https://github.com/KristofferC/HyperHessians.jl, and it seems to still be quite good. Benchmarks run on 1.10 due to JuliaLang/julia#60241 and JuliaLang/julia#60243.

The package has had very little real world use but seems to work here at least and be quite a bit better.

# Fdiff
Single: 11.576176 seconds (1.00 M allocations: 2.434 GiB, 2.04% gc time)
Multi:   5.107421 seconds (994.12 k allocations: 2.397 GiB, 0.85% gc time)
Time for ∇²F! in multi: 0.195347 seconds (92.65 k allocations: 46.968 MiB)


# HyperHessians
Single:  8.298370 seconds (10.95 k allocations: 1.731 GiB, 2.51% gc time)
Multi:    3.529221 seconds (88.96 k allocations: 1.739 GiB, 0.37% gc time)
Time for ∇²F! in multi: 0.114557 seconds (2.65 k allocations: 282.797 KiB)

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.19%. Comparing base (65773c2) to head (6ad922e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1253   +/-   ##
=======================================
  Coverage   94.19%   94.19%           
=======================================
  Files          40       40           
  Lines        6662     6662           
=======================================
  Hits         6275     6275           
  Misses        387      387           

☔ 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.

Copy link
Member

@termi-official termi-official left a comment

Choose a reason for hiding this comment

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

After some discussion on slack I think I am convinced for now that the typical user won't find a way to trigger perturbation confusion when sticking to this example.

@KristofferC
Copy link
Collaborator Author

Maybe I'll register the package and see if some people have an interest in poking on it before mergin thits.

I would also like to get a reverse AD backend working on this to see what effect it has on performance. I started a DifferentiationInterface rewrite (17edffa#diff-bd098a9030f95d6512cf21c19a06a92acd264a6ca5b80f683ca379a0832abec5) but I got into troubles with every reverse AD backend I tried...

@gdalle
Copy link

gdalle commented Nov 26, 2025

Let me know if I can help with DI integration!

@KristofferC
Copy link
Collaborator Author

The DI integration works fine and was very easy (great job) . It's just that no backend work... 😅

@gdalle
Copy link

gdalle commented Nov 26, 2025

If you have Mooncake issues, don't hesitate to open them on the repo! It's a small team but they do their best!

@KristofferC
Copy link
Collaborator Author

Ok, opened chalk-lab/Mooncake.jl#867.

@gdalle
Copy link

gdalle commented Nov 26, 2025

Thanks! What kind of error do you get with Enzyme?

@KristofferC
Copy link
Collaborator Author

Testing backend: Enzyme
┌ Error: Backend Enzyme failed
│   exception =
│    TaskFailedException
│    
│        nested task error: AssertionError: ety == eltype(vt)
│        Stacktrace:
│          [1] sret_ty(fn::LLVM.Function, idx::Int64)
│            @ Enzyme ~/.julia/packages/Enzyme/OhLFb/src/utils.jl:556
│          [2] removeDeadArgs!(mod::LLVM.Module, tm::LLVM.TargetMachine, post_gc_fixup::Bool)
│            @ Enzyme.Compiler ~/.julia/packages/Enzyme/OhLFb/src/llvm/transforms.jl:2476
│          [3] optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine)
│            @ Enzyme.Compiler ~/.julia/packages/Enzyme/OhLFb/src/compiler/optimize.jl:191
│          [4] compile_unhooked(output::Symbol, job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget{GPUCompiler.NativeCompilerTarget}, Enzyme.Compiler.EnzymeCompilerParams{Enzyme.Compiler.PrimalCompilerParams}})
│            @ Enzyme.Compiler ~/.julia/packages/En

EnzymeAD/Enzyme.jl#2794 might be a smaller MWE.

@wsmoses
Copy link

wsmoses commented Nov 30, 2025

just for fun what if you use Enzyme from within reactant (the sret stuff above doesn't matter there)

@KristofferC
Copy link
Collaborator Author

I don't know what that means :)

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.

5 participants