Skip to content

Recurse through structs to check is_traced #931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 18, 2025
Merged

Conversation

jumerckx
Copy link
Collaborator

fixes #929

@jumerckx jumerckx requested a review from Pangoraw March 16, 2025 18:36
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
giordano added a commit to PRONTOLab/GB-25 that referenced this pull request Mar 16, 2025
giordano added a commit to PRONTOLab/GB-25 that referenced this pull request Mar 16, 2025
if isprimitivetype(x)
return false
else
return any(is_traced, getfield.(Ref(x), fieldnames(T)))
Copy link
Member

Choose a reason for hiding this comment

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

does this properly deal with recursive types? I.e. a linked list node

Copy link
Collaborator Author

@jumerckx jumerckx Mar 16, 2025

Choose a reason for hiding this comment

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

Not the first time I've made this mistake...
I'll add a seen IdSet

giordano added a commit to PRONTOLab/GB-25 that referenced this pull request Mar 16, 2025
jumerckx and others added 2 commits March 16, 2025 23:11
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Member

Choose a reason for hiding this comment

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

You also need to bump the ReactantCore version number, and require that in Reactant

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do I need to bump Reactant itself as well?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, so we can get a new release including this. Side note, in case you missed them, there are more suggestions above. Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Side note, in case you missed them, #931 (review).

Yes, thanks a lot! Didn't wanna disturb CI yet.
I'm a bit puzzled about the one CI failure https://github.com/EnzymeAD/Reactant.jl/actions/runs/13898325850/job/38883950334?pr=931

Copy link
Member

Choose a reason for hiding this comment

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

Oh, sadly the segfaults on the aarch64 runners are kinda expected: rust-lang/rust#135867. Restart those jobs if they only fail because of segfaults.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah, honestly great to hear 😝

jumerckx and others added 3 commits March 17, 2025 06:28
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mosè Giordano <[email protected]>
function is_traced((@nospecialize x::T), seen=(@static if VERSION > v"1.11"
IdSet()
else
Set{UInt}()
Copy link
Member

Choose a reason for hiding this comment

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

why can't we use Idset everywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

doesn't exist in Julia 1.10 AFAICT

Copy link
Member

Choose a reason for hiding this comment

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

can we define it? IdDict definitely exists for lower versions (though apparently not idset)

Copy link
Member

Choose a reason for hiding this comment

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

Was it not exported before? I can do Base.IdSet in Julia v1.7

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Argh, will add, gimme a min

@giordano
Copy link
Member

I'm going to merge this, so we can get the Ninner PR in soon.

@giordano giordano merged commit 6ef8f83 into main Mar 18, 2025
44 of 56 checks passed
@giordano giordano deleted the jm/is_traced_structs branch March 18, 2025 16:38
giordano added a commit to PRONTOLab/GB-25 that referenced this pull request Mar 18, 2025
giordano added a commit to PRONTOLab/GB-25 that referenced this pull request Mar 18, 2025
giordano added a commit to PRONTOLab/GB-25 that referenced this pull request Mar 19, 2025
* Use concrete `Ninner`

* Test EnzymeAD/Reactant.jl#931

* Test CliMA/Oceananigans.jl#4226

* Make Ninner concrete also for run script

* add updated ReactantCore

* Increase Ninner, see if that affects compile time

* Revert "Increase Ninner, see if that affects compile time"

This reverts commit 3abd73d.  The test was successful.

* Switch back to stable Reactant

* Update CompileOrRun.yml

* Update CompileOrRun.yml

* Use stable version of all packages

---------

Co-authored-by: jumerckx <[email protected]>
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.

Generalize ReactantCore.is_traced to structs
3 participants