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

Fix scatter, reduce #1300

Merged
merged 25 commits into from
Aug 22, 2024
Merged

Fix scatter, reduce #1300

merged 25 commits into from
Aug 22, 2024

Conversation

awni
Copy link
Member

@awni awni commented Jul 31, 2024

  • Fixes scatter for large sizes
  • Probably will be part of a fix for some reductions for large sizes

TODO: measure impact on runtime to see if we need to specialize this.

@awni awni changed the title Fix scatter / atomics to have a size_t offset Fix scatter, reduce, RoPE and RandomBits for arrays > UINT_MAX elements Jul 31, 2024
@awni awni changed the title Fix scatter, reduce, RoPE and RandomBits for arrays > UINT_MAX elements Fix scatter, reduce Jul 31, 2024
@angeloskath
Copy link
Member

Ok I think this is ready for a review at least the reduction part (or I am just tired of improving it). I will add some benchmarks and then go ahead and benchmark the scatter that is also in this PR.

It is a bit big and there are several changes on various parts so sorry about that. I will also write a long running test and a fuzzer to make sure that every size is properly checked in our nightly tests.

All reduce

When the array is big everything practically gets the memory bandwidth so it's all the same. But there is a difference for int8.

all_reduce

Row reduce

row_reduce
row_reduce_pre

Col reduce

col_reduce
col_reduce_pre

@awni
Copy link
Member Author

awni commented Aug 22, 2024

🤤

@awni
Copy link
Member Author

awni commented Aug 22, 2024

I don't know what kind of magic you did here..but those graphs are pretty amazing.

mlx/ops.cpp Outdated Show resolved Hide resolved
@angeloskath angeloskath merged commit 98b6ce3 into main Aug 22, 2024
3 checks passed
@angeloskath angeloskath deleted the fix_scatter branch August 22, 2024 23:03
@angeloskath angeloskath restored the fix_scatter branch August 23, 2024 00:24
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.

2 participants