Skip to content

Fix IR docs duplication and improve documentation structure#718

Merged
yebai merged 4 commits intomainfrom
copilot/fix-549
Aug 28, 2025
Merged

Fix IR docs duplication and improve documentation structure#718
yebai merged 4 commits intomainfrom
copilot/fix-549

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 27, 2025

This PR addresses the documentation improvements outlined in issue #549 for the IR representation documentation.

Changes Made

Updated Documentation Title

  • Changed from "Mooncake's IR Representation and Code Transformations" to "IR Representations and Code Transformations" to better reflect that the document covers both Julia's IR and Mooncake's approach

Enhanced Documentation Structure

  • Maintained practical IRCode field reference and forward-mode specific guidance in reverse_mode_design.md that provides field-by-field details not covered elsewhere
  • Added cross-reference to the comprehensive IR representation document for additional transformation examples
  • Removed speculative content about alternative approaches based on reviewer feedback

Enhanced Content Based on Community Feedback

  • Added "Comparison with Alternative Approaches" section with a factual reference to Diffractor's approach for IR transformations
  • Included references to additional learning materials from Scientific Programming in Julia course
  • These additions respond to suggestions from @yebai in the issue comments

Documentation Structure Improvements

The changes create a clearer information architecture:

  • ir_representation.md serves as the comprehensive guide to Julia's IR concepts and transformation examples
  • reverse_mode_design.md contains practical IRCode field reference and forward-mode specific guidance that complements the general documentation
  • Cross-references properly connect related topics while each document maintains its unique valuable content

Impact

  • Provides readers with both conceptual understanding and practical field-level reference details
  • Eliminates speculation while maintaining factual references to alternative approaches
  • Maintains comprehensive coverage with proper cross-referencing between documents

Fixes #549.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: yebai <3279477+yebai@users.noreply.github.com>

While Mooncake's `BBCode` was designed specifically to make control flow graph transformations easier for reverse-mode AD, exploring whether Optics could provide a more principled and composable approach to IR transformations could be an interesting direction for future development. Such an approach might potentially unify the IR transformation needs of both forward and reverse mode AD under a single framework.

For readers interested in learning more about Julia's IR representation beyond what's covered here, the [Scientific Programming in Julia course materials](https://github.com/JuliaTeachingCTU/Scientific-Programming-in-Julia/blob/2023W/docs/src/lecture_09/ircode.md) provide additional valuable context.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a helpful link.

Copilot AI changed the title [WIP] IR Docs Todo Fix IR docs duplication and improve documentation structure Aug 27, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI requested a review from yebai August 27, 2025 17:20
Comment on lines +558 to +562
### Comparison with Alternative Approaches

It's worth noting that other automatic differentiation systems have taken different approaches to IR manipulation. For example, [Diffractor.jl](https://github.com/JuliaDiff/Diffractor.jl) uses an "Optics" approach for IR transformations ([see their reading list](https://github.com/JuliaDiff/Diffractor.jl/blob/41fcdf2b6291a628886709f21734b73275c4c0cb/docs/src/reading_list.md?plain=1#L15)). The Optics approach provides a functional lens-based method for composable transformations of nested data structures.

While Mooncake's `BBCode` was designed specifically to make control flow graph transformations easier for reverse-mode AD, exploring whether Optics could provide a more principled and composable approach to IR transformations could be an interesting direction for future development. Such an approach might potentially unify the IR transformation needs of both forward and reverse mode AD under a single framework.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This whole thing is speculative at best -- unless you @yebai have an understanding of the optics thing that diffractor uses, I wouldn't be comfortable having any of this in the docs because I have no idea whether it's true, and it's unclear to me whether it really adds anything.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot, can you remove this block and keep only a mere reference to optics in Diffractor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the speculative content about Optics and simplified the section to include only a brief reference to Diffractor's approach as requested. Commit: 5b34f0b

@@ -1,4 +1,4 @@
# IR Representation
# Mooncake's IR Representation and Code Transformations
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This might be better renamed to

Suggested change
# Mooncake's IR Representation and Code Transformations
# IR Representations and Code Transformations

since only part of this document is about how Mooncake represents things (the other half is about how Julia IR)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the title to "IR Representations and Code Transformations" as suggested since the document covers both Julia's IR and Mooncake's representations. Commit: 5b34f0b

For detailed information about manipulating `IRCode` and `BBCode` data structures, including their fields, structure, and how to transform them, see [Mooncake's IR Representation and Code Transformations](@ref).

Examples of how line-by-line transformations can be done, are defined in [`Mooncake.make_ad_stmts!`](@ref).
The `IRCode` nodes are not explicitly documented in <https://docs.julialang.org/en/v1/devdocs/ast/#Lowered-form> or <https://docs.julialang.org/en/v1/devdocs/ssair/#Main-SSA-data-structure>. Might need completion of official docs, but Mooncake docs in the meantime.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't understand why it thinks this is redundant. Any ideas?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The content has been restored as it contains valuable practical guidance specific to forward-mode AD that complements the general IR documentation. Commit: 7f8ff8f

Comment on lines -55 to -70
To manipulate `IRCode`, check out the fields:

- `ir.argtypes` is the signature. Some are annotated with `Core.Const` to facilitate constant propagation for instance. Other annotations are `PartialStruct`, `Conditional`, `PartialTypeVar`. `Core.Compiler.widenconst` is used to extract types from these.
- `ir.stmts` is a `Core.Compiler.InstructionStream`. This represents a sequence of instructions via 5 vectors of the same length:
- `stmts.stmt` is a vector of expressions (or other IR node types), see [AST docs](https://docs.julialang.org/en/v1/devdocs/ast/#Lowered-form)
- `stmts.type` is a vector of types for the left-hand side of the assignment
- three others
- `ir.cfg` is the Control Flow Graph of type `Core.Compiler.CFG`
- `ir.meta` is metadata, not important
- `ir.new_nodes` is an optimization buffer, not important
- `ir.sptypes` is for type parameters of the called function

We must maintain coherence between the various components of `IRCode` (especially `ir.stmts` and `ir.cfg`). That is the reason behind `BBCode`, to make coherence easier.
We can deduce the CFG from the statements but not the other way around: it's only composed of blocks of statement indices.
In forward mode we shouldn't have to modify anything but `ir.stmts`.
Do line by line transformation of the statements and then possibly refresh the CFG.
Copy link
Copy Markdown
Collaborator

@willtebbutt willtebbutt Aug 27, 2025

Choose a reason for hiding this comment

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

@copilot This is definitely not redundant, sine it's not really discussed in the other bit of the docs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're absolutely right - I've restored the IRCode field details and forward-mode specific guidance. This content provides practical field-by-field reference information that isn't covered in the general IR representation document. Commit: 7f8ff8f

@yebai
Copy link
Copy Markdown
Member

yebai commented Aug 27, 2025

@willtebbutt you can coach @copilot what to do by adding @copilot in review comments.

@github-actions
Copy link
Copy Markdown
Contributor

Mooncake.jl documentation for PR #718 is available at:
https://chalk-lab.github.io/Mooncake.jl/previews/PR718/

Co-authored-by: yebai <3279477+yebai@users.noreply.github.com>
@willtebbutt
Copy link
Copy Markdown
Collaborator

Hmm sadly it doesn't seem to work for me -- could it be that you're the only one able to talk to it because you instructed it to open the PR?

@yebai
Copy link
Copy Markdown
Member

yebai commented Aug 27, 2025

I think it only works for new comments, which is a silly limitation.

Co-authored-by: yebai <3279477+yebai@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Performance Ratio:
Ratio of time to compute gradient and time to compute function.
Warning: results are very approximate! See here for more context.

┌────────────────────────────┬──────────┬──────────┬─────────────┬─────────┬─────────────┬─────────┐
│                      Label │   Primal │ Mooncake │ MooncakeFwd │  Zygote │ ReverseDiff │  Enzyme │
│                     String │   String │   String │      String │  String │      String │  String │
├────────────────────────────┼──────────┼──────────┼─────────────┼─────────┼─────────────┼─────────┤
│                   sum_1000 │ 100.0 ns │      1.8 │         1.8 │     1.1 │        5.61 │    8.11 │
│                  _sum_1000 │ 941.0 ns │     6.68 │        1.01 │  1370.0 │        33.7 │    1.09 │
│               sum_sin_1000 │  6.57 μs │     2.19 │        1.39 │    1.68 │        10.6 │    2.18 │
│              _sum_sin_1000 │  5.21 μs │     2.67 │        2.21 │   272.0 │        13.2 │     2.5 │
│                   kron_sum │ 328.0 μs │     42.6 │        2.89 │    4.96 │       223.0 │    8.25 │
│              kron_view_sum │ 318.0 μs │     44.2 │        3.52 │    11.3 │       243.0 │    6.74 │
│      naive_map_sin_cos_exp │  2.32 μs │     2.03 │        1.29 │ missing │        6.63 │    2.16 │
│            map_sin_cos_exp │  2.12 μs │     2.44 │        1.46 │     1.6 │        6.21 │    2.89 │
│      broadcast_sin_cos_exp │  2.24 μs │      2.3 │        1.37 │    2.35 │        1.47 │    2.25 │
│                 simple_mlp │ 215.0 μs │     5.95 │         3.0 │     1.7 │        11.0 │    3.47 │
│                     gp_lml │ 258.0 μs │     8.35 │        2.01 │    3.55 │     missing │    5.26 │
│ turing_broadcast_benchmark │  1.96 ms │     3.85 │        3.04 │ missing │        25.2 │ missing │
│         large_single_block │ 390.0 ns │     4.42 │        1.98 │  4320.0 │        29.8 │    2.18 │
└────────────────────────────┴──────────┴──────────┴─────────────┴─────────┴─────────────┴─────────┘

@yebai yebai marked this pull request as ready for review August 28, 2025 10:36
@yebai yebai merged commit 315911a into main Aug 28, 2025
86 of 88 checks passed
@yebai yebai deleted the copilot/fix-549 branch August 28, 2025 10:36
yebai added a commit that referenced this pull request Aug 28, 2025
#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>
yebai added a commit that referenced this pull request Aug 28, 2025
…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>
sunxd3 pushed a commit that referenced this pull request Nov 11, 2025
* 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>
yebai added a commit that referenced this pull request Mar 25, 2026
* 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>
yebai added a commit that referenced this pull request Mar 25, 2026
* 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>
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.

IR Docs Todo

3 participants