add rule for complex logdet#664
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Thanks for this! There should be a block of tests at the bottom of the lapack src file which specifies tests specific to getrf. Would it be possible to also extend them to test the complex version? (On my phone, so can't easily point to the code directly, apologies!!) |
|
Ah, they were in source file, that's why I couldn't find them! No problem, done. |
|
I thought everything was working because the test for But the same happens with a plain numerical matrix, independently of my additions. Compare: julia> gradient(x -> real(tr(x'x)), AutoMooncake(), randn(2,2))
2×2 Matrix{Float64}:
0.434831 3.09532
-1.09911 -2.19635
julia> gradient(x -> real(tr(x'x)), AutoMooncake(), randn(ComplexF64, 2,2))
2×2 Matrix{Mooncake.Tangent{@NamedTuple{re::Float64, im::Float64}}}:
Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.847196, im = -0.810308)) … Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.548862, im = 0.833737))
Tangent{@NamedTuple{re::Float64, im::Float64}}((re = -0.269572, im = 1.98935)) Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 1.83858, im = 0.926595)) |
Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com>
The gradient format is due to #472. |
Cc @willtebbutt |
|
The checks which are failing are the "is the gradient numerically correct" checks -- see Line 513 in 05cdce1
|
|
I did check that the result was correct for the complex case. The gradient of logdet is simply the inverse. Ill conditioning is a possibility, how do I see which matrices were used in the failing tests? Then I could check them manually. |
|
Sadly your best bet is probably to include print statements strategically in the code. |
|
I can't make heads or tails of the tests, but it's certainly not an actual error, because the tests succeed for plain matrices. It's just a formatting issue. Look: julia> using LinearAlgebra; using DifferentiationInterface; import Mooncake; import Mooncake.Tangent; import Mooncake.NoTangent
julia> f(x) = real(logdet(x));
julia> z0 = randn(ComplexF64, 3, 3); @views y0 = z0[1:2, 1:2]; x0 = Matrix(y0);
julia> inv(x0)'
2×2 adjoint(::Matrix{ComplexF64}) with eltype ComplexF64:
0.0729042+0.947071im 0.556282-0.362036im
0.335595-0.15118im 0.460689-0.136424im
julia> gradient(f, AutoMooncake(), x0)
2×2 Matrix{Tangent{@NamedTuple{re::Float64, im::Float64}}}:
Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.0729042, im = 0.947071)) … Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.556282, im = -0.362036))
Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.335595, im = -0.15118)) Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.460689, im = -0.136424))
julia> gradient(f, AutoMooncake(), y0)
Tangent{@NamedTuple{parent::Matrix{Tangent{@NamedTuple{re::Float64, im::Float64}}}, indices::NoTangent, offset1::NoTangent, stride1::NoTangent}}((parent = Tangent{@NamedTuple{re::Float64, im::Float64}}[Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.07290416524300863, im = 0.9470706523876997)) Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.5562823767358989, im = -0.3620364530936287)) Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.0, im = 0.0)); Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.3355953622333809, im = -0.1511804723798711)) Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.46068937497050844, im = -0.13642443117666486)) Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.0, im = 0.0)); Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.0, im = 0.0)) Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.0, im = 0.0)) Tangent{@NamedTuple{re::Float64, im::Float64}}((re = 0.0, im = 0.0))], indices = NoTangent(), offset1 = NoTangent(), stride1 = NoTangent()))When I do it with a plain matrix the result is exactly correct, no complex conjugation missing. When I do it with a |
|
#683 will address the gradient format issue and unblock this PR. |
|
Just had a look at this. The problem is a bug in |
|
@araujoms main now contains fixes to arrayify which ought to fix the problems in this PR. Would you be happy to update this PR (or create a new one with the relevant changes from this one on top of main if it's easier), and see if everything is working? |
Signed-off-by: Mateus Araújo <maltusan@gmail.com>
|
The test failures are the same as in main, so I think everything is indeed working now. Specially rrules/lapack, which was failing before. The tests report a performance regression for |
|
Thanks for separating out the testing -- I think this is basically done now. I think you just need to run the formatter to make the "quality" checks happy. |
willtebbutt
left a comment
There was a problem hiding this comment.
I'm of the view that this is now good-to-go, so I'll merge once CI passes if you're happy for me to do so @araujoms .
Also, thanks for your contribution, I really appreciate it.
|
I'm happy with merging, thanks for all the help. |
#733) * Fix changelog version (#693) * remove `const M` (#696) * remove const M * fix formatting * Update Project.toml Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update README.md (#697) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * minimal print io output (#699) * minimal print * vers bump * remove prev tests * include show in derived * Update algorithmic_differentiation.md (#703) I noticed a typo. I likely won't look at this again for a week or so, so please feel free to merge for me. Signed-off-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> * Fix 660 (#705) * Fix + tests * Bump patch version * Use _stable_typeof directly * Comment on the use of _stable_typeof * Extend arrayify for complex numbers (#706) * Fix + tests * Bump patch version * Use _stable_typeof directly * Add arrayify tests * Widen permitted types * Bump patch version again * Formatting * Uncomment blas tests * Create contribution guidelines in copilot-instructions.md (#713) Added contribution guidelines for the automatic differentiation package. Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Set tangent_type for AbstractLogger to NoTangent (#710) * Initial plan * Set tangent_type for Logging.ConsoleLogger to NoTangent Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add ConsoleLogger test to verify AbstractLogger tangent type coverage Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add Base.CoreLogging.SimpleLogger to type union Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update test/tangents.jl Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add better error messages for tangent accessors when types are passed (#707) * Initial plan * Add better error messages for tangent accessors when types are passed Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Tidy up (#715) * Tidy up error-generating methods * Remove redundant tests * Remove more redundant test cases * Bump patch version * add rule for complex logdet (#664) * working complex logdet * bump version * proper getrf! tests * improve tests * move tests * generalize tests * formatting and version --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Delete .github/copilot-instructions.md (#722) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Uncomment b_binv_test_case for PlanarLayer (#727) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add DiffEq integration test for Mooncake (#726) * Initial plan * Add DiffEq integration test with original example from issue Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Finalize DiffEq integration test with comprehensive structure Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Remove @info and @test_broken statements to reduce clutter Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * fix formatting (#728) * Fix DiffEq integration test by restricting to reverse mode only (#731) * Initial plan * Fix DiffEq integration test by testing reverse mode only Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * formatting --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> * Fix IR docs duplication and improve documentation structure (#718) * Initial plan * Update IR docs title and remove duplication, add comparison section Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Address PR feedback: update title and simplify Optics reference Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Restore IRCode field details that were incorrectly removed Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Initial plan * Add Julia version-dependent JET version selection to CI workflow Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Improve JET version handling to support complex constraints and remove need for explicit version on Julia 1.12+ Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update CI.yml Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Penelope Yong <penelopeysm@gmail.com> Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: Astitva Aggarwal <84859349+AstitvaAggarwal@users.noreply.github.com> Co-authored-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: Mateus Araújo <maltusan@gmail.com>
…ng compat) (#691) * CompatHelper: bump compat for JET in [weakdeps] to 0.10, (keep existing compat) * Set tangent_type for AbstractLogger to NoTangent (#710) * Initial plan * Set tangent_type for Logging.ConsoleLogger to NoTangent Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add ConsoleLogger test to verify AbstractLogger tangent type coverage Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add Base.CoreLogging.SimpleLogger to type union Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update test/tangents.jl Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add better error messages for tangent accessors when types are passed (#707) * Initial plan * Add better error messages for tangent accessors when types are passed Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Tidy up (#715) * Tidy up error-generating methods * Remove redundant tests * Remove more redundant test cases * Bump patch version * add rule for complex logdet (#664) * working complex logdet * bump version * proper getrf! tests * improve tests * move tests * generalize tests * formatting and version --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Delete .github/copilot-instructions.md (#722) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Uncomment b_binv_test_case for PlanarLayer (#727) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add DiffEq integration test for Mooncake (#726) * Initial plan * Add DiffEq integration test with original example from issue Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Finalize DiffEq integration test with comprehensive structure Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Remove @info and @test_broken statements to reduce clutter Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * fix formatting (#728) * Fix DiffEq integration test by restricting to reverse mode only (#731) * Initial plan * Fix DiffEq integration test by testing reverse mode only Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * formatting --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> * Fix IR docs duplication and improve documentation structure (#718) * Initial plan * Update IR docs title and remove duplication, add comparison section Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Address PR feedback: update title and simplify Optics reference Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Restore IRCode field details that were incorrectly removed Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add robust Julia version-dependent JET version handling to CI workflow (#733) * Fix changelog version (#693) * remove `const M` (#696) * remove const M * fix formatting * Update Project.toml Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update README.md (#697) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * minimal print io output (#699) * minimal print * vers bump * remove prev tests * include show in derived * Update algorithmic_differentiation.md (#703) I noticed a typo. I likely won't look at this again for a week or so, so please feel free to merge for me. Signed-off-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> * Fix 660 (#705) * Fix + tests * Bump patch version * Use _stable_typeof directly * Comment on the use of _stable_typeof * Extend arrayify for complex numbers (#706) * Fix + tests * Bump patch version * Use _stable_typeof directly * Add arrayify tests * Widen permitted types * Bump patch version again * Formatting * Uncomment blas tests * Create contribution guidelines in copilot-instructions.md (#713) Added contribution guidelines for the automatic differentiation package. Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Set tangent_type for AbstractLogger to NoTangent (#710) * Initial plan * Set tangent_type for Logging.ConsoleLogger to NoTangent Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add ConsoleLogger test to verify AbstractLogger tangent type coverage Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add Base.CoreLogging.SimpleLogger to type union Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update test/tangents.jl Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add better error messages for tangent accessors when types are passed (#707) * Initial plan * Add better error messages for tangent accessors when types are passed Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Tidy up (#715) * Tidy up error-generating methods * Remove redundant tests * Remove more redundant test cases * Bump patch version * add rule for complex logdet (#664) * working complex logdet * bump version * proper getrf! tests * improve tests * move tests * generalize tests * formatting and version --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Delete .github/copilot-instructions.md (#722) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Uncomment b_binv_test_case for PlanarLayer (#727) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add DiffEq integration test for Mooncake (#726) * Initial plan * Add DiffEq integration test with original example from issue Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Finalize DiffEq integration test with comprehensive structure Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Remove @info and @test_broken statements to reduce clutter Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * fix formatting (#728) * Fix DiffEq integration test by restricting to reverse mode only (#731) * Initial plan * Fix DiffEq integration test by testing reverse mode only Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * formatting --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> * Fix IR docs duplication and improve documentation structure (#718) * Initial plan * Update IR docs title and remove duplication, add comparison section Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Address PR feedback: update title and simplify Optics reference Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Restore IRCode field details that were incorrectly removed Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Initial plan * Add Julia version-dependent JET version selection to CI workflow Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Improve JET version handling to support complex constraints and remove need for explicit version on Julia 1.12+ Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update CI.yml Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Penelope Yong <penelopeysm@gmail.com> Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: Astitva Aggarwal <84859349+AstitvaAggarwal@users.noreply.github.com> Co-authored-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: Mateus Araújo <maltusan@gmail.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Signed-off-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Co-authored-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Penelope Yong <penelopeysm@gmail.com> Co-authored-by: Astitva Aggarwal <84859349+AstitvaAggarwal@users.noreply.github.com>
* Initial plan * Add Julia v1.12 compatibility for BBCode and IR infrastructure Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add 'pre' version to CI workflow Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Fix inlining_policy function name for Julia v1.12+ compatibility and format code Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * CompatHelper: bump compat for JET in [weakdeps] to 0.10, (keep existing compat) (#691) * CompatHelper: bump compat for JET in [weakdeps] to 0.10, (keep existing compat) * Set tangent_type for AbstractLogger to NoTangent (#710) * Initial plan * Set tangent_type for Logging.ConsoleLogger to NoTangent Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add ConsoleLogger test to verify AbstractLogger tangent type coverage Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add Base.CoreLogging.SimpleLogger to type union Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update test/tangents.jl Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add better error messages for tangent accessors when types are passed (#707) * Initial plan * Add better error messages for tangent accessors when types are passed Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Tidy up (#715) * Tidy up error-generating methods * Remove redundant tests * Remove more redundant test cases * Bump patch version * add rule for complex logdet (#664) * working complex logdet * bump version * proper getrf! tests * improve tests * move tests * generalize tests * formatting and version --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Delete .github/copilot-instructions.md (#722) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Uncomment b_binv_test_case for PlanarLayer (#727) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add DiffEq integration test for Mooncake (#726) * Initial plan * Add DiffEq integration test with original example from issue Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Finalize DiffEq integration test with comprehensive structure Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Remove @info and @test_broken statements to reduce clutter Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * fix formatting (#728) * Fix DiffEq integration test by restricting to reverse mode only (#731) * Initial plan * Fix DiffEq integration test by testing reverse mode only Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * formatting --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> * Fix IR docs duplication and improve documentation structure (#718) * Initial plan * Update IR docs title and remove duplication, add comparison section Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Address PR feedback: update title and simplify Optics reference Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Restore IRCode field details that were incorrectly removed Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add robust Julia version-dependent JET version handling to CI workflow (#733) * Fix changelog version (#693) * remove `const M` (#696) * remove const M * fix formatting * Update Project.toml Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update README.md (#697) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * minimal print io output (#699) * minimal print * vers bump * remove prev tests * include show in derived * Update algorithmic_differentiation.md (#703) I noticed a typo. I likely won't look at this again for a week or so, so please feel free to merge for me. Signed-off-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> * Fix 660 (#705) * Fix + tests * Bump patch version * Use _stable_typeof directly * Comment on the use of _stable_typeof * Extend arrayify for complex numbers (#706) * Fix + tests * Bump patch version * Use _stable_typeof directly * Add arrayify tests * Widen permitted types * Bump patch version again * Formatting * Uncomment blas tests * Create contribution guidelines in copilot-instructions.md (#713) Added contribution guidelines for the automatic differentiation package. Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Set tangent_type for AbstractLogger to NoTangent (#710) * Initial plan * Set tangent_type for Logging.ConsoleLogger to NoTangent Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add ConsoleLogger test to verify AbstractLogger tangent type coverage Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add Base.CoreLogging.SimpleLogger to type union Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update test/tangents.jl Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add better error messages for tangent accessors when types are passed (#707) * Initial plan * Add better error messages for tangent accessors when types are passed Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Tidy up (#715) * Tidy up error-generating methods * Remove redundant tests * Remove more redundant test cases * Bump patch version * add rule for complex logdet (#664) * working complex logdet * bump version * proper getrf! tests * improve tests * move tests * generalize tests * formatting and version --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Delete .github/copilot-instructions.md (#722) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Uncomment b_binv_test_case for PlanarLayer (#727) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add DiffEq integration test for Mooncake (#726) * Initial plan * Add DiffEq integration test with original example from issue Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Finalize DiffEq integration test with comprehensive structure Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Remove @info and @test_broken statements to reduce clutter Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * fix formatting (#728) * Fix DiffEq integration test by restricting to reverse mode only (#731) * Initial plan * Fix DiffEq integration test by testing reverse mode only Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * formatting --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> * Fix IR docs duplication and improve documentation structure (#718) * Initial plan * Update IR docs title and remove duplication, add comparison section Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Address PR feedback: update title and simplify Optics reference Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Restore IRCode field details that were incorrectly removed Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Initial plan * Add Julia version-dependent JET version selection to CI workflow Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Improve JET version handling to support complex constraints and remove need for explicit version on Julia 1.12+ Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update CI.yml Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Penelope Yong <penelopeysm@gmail.com> Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: Astitva Aggarwal <84859349+AstitvaAggarwal@users.noreply.github.com> Co-authored-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: Mateus Araújo <maltusan@gmail.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Signed-off-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Co-authored-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Penelope Yong <penelopeysm@gmail.com> Co-authored-by: Astitva Aggarwal <84859349+AstitvaAggarwal@users.noreply.github.com> * Prevent exporting names already declared as public This is disallowed by the language and results in an error. * Extend required interface CC.add_edges_impl! * Adapt to stackless inference change (using CC.Future etc) * Always return a boolean from `src_inlining_policy` * Fix relocation of a few Experimental functions to CC * Fix `_ir_abstract_constant_propagation` rename * Adjust to `ir_abstract_constant_propagation` changes * Support `invoke` CodeInstance arguments * Adjust to opaque macro behavior change * Define better slotnames for debugging * Fix opaque closure construction * Adjust to 1.12 opaque closure creation change * More fixes * Fix IRCode construction bug * Adjust to binding changes for primal type extraction * Rules for new intrinsics * Set appropriate world bounds on the `CodeInfo` * Optimize opaque closures * Avoid failures on <1.12 * Don't attempt to set bounds if no inferred code is available * More <1.12 fixes * Don't optimize if IR interp can't be performed * More fixes/tests * Revert use of `Base.allocations` It is not defined on <1.12, and the macro form seems fine. * Fix bad line info information * Make line info logic more robust, fix a few more things * [WIP] add rules for `svec` and `_svec_len` * Don't add _svec_len rule for < 1.12 * Try to avoid error in IRInterp * Allow type unstability for `compute_oc_signature` * Attempt to fix allocations * Still use the same Tuple type for < 1.12 * Unconditionally set ir.argtypes[1] to an accurate Tuple * Fix `primal_type` bug * Fix construction error for IRCode * Fix more issues * Discard unwanted change * Make version check static * Add some @zero_derivatives for logging (#815) * Mark Base.fixup_stdlib_path as having @zero_derivative This comes up because in Julia 1.12 logmsg_code gets the folder of Core.Compiler if needed to resolve paths, which results in a ccall with no known rule. See JuliaLang/julia#57274. * Make Base.CoreLogging.handle_message_nothrow as having @zero_derivative This comes up in logmsg_code, because in Julia v1.12 handle_message_nothrow got a try-catch structure, which creates an UpsilonNode that Mooncake can't handle. * Update avoiding_non_differentiable_code.jl Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * fix format * Fix handle_message_nothrow @zero_derivative rule * Improve a comment * Fix duplicate svec rule after merge * Remove JET version adjustment from CI workflow Removed JET version adjustment step based on Julia version from CI workflow. Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Fix typo in 1.12- * Also test buildkit and ext on 1.12? * Use an eval to avoid duplicating BBCode * Remove useless line (thanks Copilot) * Update get_primal_type for GlobalRef * Update isva comment * Require Julia 1.12.1 or newer * Fix stdin reference not working in 1.11 * Update patch_for_319 following Julia 1.12 changes * Binding partitions are lazily populated! * Set the IR's valid worlds to only the interpreter world (#832) * Try to set the IR valid worlds to only the interpreter world * Add explanation to set_valid_worlds! * Tweak comment * Update dispatch_doctor.jl Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Import _Utils from DispatchDoctor in tests Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * reformat * Use a single world for inference * Disable JET tests for Julia 1.12 temporarily. Julia 1.12 has a few Base functions that are not type-stable, causing false-positive JET test failures in Mooncake. Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * re-enable JET test for Julia 1.12 and format. * Mark compute_oc_signature as unstable Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Add documentation for resolve_unbound_globalrefs function Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> * Add unstable block for version-specific functions Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update allocation tests for Julia version compatibility Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update frule allocation tests for Julia version compatibility * refactor count_allocs * Update JET version to include 0.11 (#841) Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * fix allocation counts for primals (plus `_new_` frule) (#843) * Fix allocation counters for `sum` and `rand` primals This fixes: - `sum(abs2, randn(11))` on 1.12 - `rand(rng, Float64)` on 1.10 and 1.11 * Use `eval` instead * Fix for `_new_` (I think) * Just get rid of the varargs in count_allocs * Add a warning * Fix all the horrible edge cases * Final fixes (please don't let me down) * Format * Skip certain stability and performance tests for 1.12 (#844) * Refactor stability rules for Float types in Julia Updated stability and allocation rules for Float types based on Julia version. Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Remove Float16 cases from test cases Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update avoiding_non_differentiable_code.jl Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * reformat --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Clarify GlobalRef resolution docs Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Fix for TwicePrecision allocs (#845) * Add rules for LAPACK.lacpy! and BLAS.trsv! (#839) * Add rules for LAPACK.lacpy! * LAPACK.lacpy! is exclusive to Julia 1.11+ * Add rule for BLAS.trsv! * Isolate sensitive trsm! rule --------- Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> * re-enable F16, only F32 and F64 are type unstable on 1.12 Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> * Update Project.toml Co-authored-by: Markus Hauru <mhauru@turing.ac.uk> Signed-off-by: Bruno Ploumhans <13494793+Technici4n@users.noreply.github.com> --------- Signed-off-by: Hong Ge <3279477+yebai@users.noreply.github.com> Signed-off-by: Mateus Araújo <maltusan@gmail.com> Signed-off-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Signed-off-by: Bruno Ploumhans <13494793+Technici4n@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yebai <3279477+yebai@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org> Co-authored-by: Hong Ge <hg344@cam.ac.uk> Co-authored-by: Will Tebbutt <3628294+willtebbutt@users.noreply.github.com> Co-authored-by: Mateus Araújo <maltusan@gmail.com> Co-authored-by: Penelope Yong <penelopeysm@gmail.com> Co-authored-by: Astitva Aggarwal <84859349+AstitvaAggarwal@users.noreply.github.com> Co-authored-by: serenity4 <cedric.bel@hotmail.fr> Co-authored-by: Markus Hauru <mhauru@turing.ac.uk> Co-authored-by: Bruno Ploumhans <13494793+Technici4n@users.noreply.github.com>
Closes #662
Let's not let perfect be the enemy of good, I don't actually need
logdet(Hermitian(x)).