-
Notifications
You must be signed in to change notification settings - Fork 15
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
adding reduce to Ops.jl #840
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deliberately did not test on non-commutative operators—it will fail when tested against Julia's reduce.
Does that mean that the reduce
method introduced here has different semantics than Julia's reduce
? That'd be unideal, asi it can lead to hard-to-track bugs when people write generic code and Reactant suddenly changes their meaning (similar for example to #755)
one thing to note is that methods in the adaptation from StableHLO to Julia semantics is done in the method specializations outside the |
Ah, yes, that's a good point. This is not extending |
yep 😅, but it's because it wraps the |
@@ -2313,4 +2313,50 @@ Produces a [`Reactant.MLIR.Dialects.sdy.sharding_constraint`](@ref) operation wi | |||
end | |||
end | |||
|
|||
@noinline function reduce( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you follow up with a PR to update the mapreduce impl to call this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I'll do that
the cuda reduce tests are failing |
Based on my initial investigation, it seems to be about how the But when using GPU, if the init_values is set to be For example, if we start with with with I am not sure if this is a sematic issue or something else. What I think happens is stablehlo broadcasts the |
I deliberately did not test on non-commutative operators—it will fail when tested against Julia's reduce. I read the discussion on the internet that it is supposed to be so, i.e., reduce should take a commutative operator; otherwise, the result will be non-deterministic, especially in a parallel system.