Skip to content
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

Split should_rewrite_ft for call and invoke expressions, and overlay Base._unique_dims #505

Merged
merged 9 commits into from
Jan 15, 2025

Conversation

mofeing
Copy link
Collaborator

@mofeing mofeing commented Jan 10, 2025

This should fix #493 but invokelatest is skipping the method of should_rewrite_invoke for Base.unique?

@mofeing mofeing requested a review from wsmoses January 10, 2025 15:16
src/utils.jl Outdated
Comment on lines 175 to 176
function should_rewrite_invoke(@nospecialize(ft), @nospecialize(args))
Core.println(Core.stderr, "[should_rewrite_invoke] ft = $ft, parameters = $(args)")
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function should_rewrite_invoke(@nospecialize(ft), @nospecialize(args))
Core.println(Core.stderr, "[should_rewrite_invoke] ft = $ft, parameters = $(args)")

Copy link
Member

Choose a reason for hiding this comment

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

probably remove the print?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, i'm using the prints for debugging. invokelatest is just calling the generic should_rewrite_invoke method, and not the specialized one for Base.unique.

will remove them once i fix it.

Copy link
Member

Choose a reason for hiding this comment

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

yeah I'm just suggesting to use https://github.com/JuliaLang/julia/blob/37b8b61ee0bd4b8db1b210a5389cf794a1358ed1/base/essentials.jl#L1062 instead where world is interp.world

end
if Base.invokelatest(should_rewrite_ft, ft) && !is_reactant_method(omi)
argsig = Core.apply_type(Core.Tuple, argsig...)
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably be lazy and do Tuple{argsize...} but sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's the same right?

Copy link
Member

Choose a reason for hiding this comment

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

yeah

@EnzymeAD EnzymeAD deleted a comment from github-actions bot Jan 10, 2025
@wsmoses
Copy link
Member

wsmoses commented Jan 10, 2025

@mofeing what if you change it to invoke_in_world and use the world from the absint/generated fn?

@wsmoses
Copy link
Member

wsmoses commented Jan 10, 2025

I previously tried and failed to get the defn to work with overloads like you have it, but had no luck (and hence there's the weird cuda overload check inside of). cc @gbaraldi if you have any ideas?

@mofeing
Copy link
Collaborator Author

mofeing commented Jan 12, 2025

@mofeing what if you change it to invoke_in_world and use the world from the absint/generated fn?

mmm not sure what you mean. do you mind if i merge, and then we discuss this on wednesday?

@wsmoses
Copy link
Member

wsmoses commented Jan 12, 2025

ah sorry replied in wrong place, but yeah do you mind giving """I'm just suggesting to use https://github.com/JuliaLang/julia/blob/37b8b61ee0bd4b8db1b210a5389cf794a1358ed1/base/essentials.jl#L1062 instead where world is interp.world""" a quick go to see if that fixes things?

@wsmoses
Copy link
Member

wsmoses commented Jan 12, 2025

if not applylatest works

@mofeing
Copy link
Collaborator Author

mofeing commented Jan 14, 2025

@Todorbsc has found that the error still happens with this PR for unique(::Vector{Int64}) (and actually, for any other type)

@wsmoses about the invoke_in_world... do you mean i should substitute call_with_reactant for invoke_in_world?

@mofeing mofeing changed the title Split should_rewrite_ft for call and invoke expressions Split should_rewrite_ft for call and invoke expressions, and overlay Base._unique_dims Jan 15, 2025
@mofeing mofeing merged commit 4b9434e into main Jan 15, 2025
20 of 28 checks passed
@mofeing mofeing deleted the ss/split-invoke-call-rewrite branch January 15, 2025 17:33
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.

Infinite recursion on unique(::Vector{Symbol}) within Reactant
2 participants