-
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
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 |
Ok I was not reading the specification carefully. Here what it says
So it is the word |
For the benefit of readers, this is the source: https://openxla.org/stablehlo/spec#semantics_71 |
Run JuliaFormatter on the code to fix the formatter ci |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #840 +/- ##
===========================================
+ Coverage 21.66% 39.82% +18.15%
===========================================
Files 46 104 +58
Lines 8048 16919 +8871
===========================================
+ Hits 1744 6738 +4994
- Misses 6304 10181 +3877 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Could you add a docstring explaining the difference with Julia's reduce? |
hmm.. the latest update from upstream branch seems to break this, specifically for macOS. Anyone has any suggestion? |
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.