Add scatter_mul#650
Merged
Merged
Conversation
Mul reduction. `out=None` initializes to ones (multiplicative identity); `out=` multiplies into the caller's buffer. CUDA `atomicMul` lands as a CAS-loop family in `atomics.cuh` covering all `AT_DISPATCH_ALL_TYPES_AND2` dtypes (int8/16/32/64, Half, BFloat16, float, double). Backward is `(grad_out * out).gather(dim, index) / src`, masked with `where(src != 0)` to keep gradients zero where `src == 0` (mirrors upstream: when one bucket contributor is 0, the bucket product is 0 so every contributor's gradient is 0).
0e1d6d2 to
33d92f1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mul reduction.
out=Noneinitializes to ones (multiplicative identity);out=multiplies into the caller's buffer. CUDAatomicMullands as aCAS-loop family in
atomics.cuhcovering allAT_DISPATCH_ALL_TYPES_AND2dtypes (int8/16/32/64, Half, BFloat16, float, double). Backward is
(grad_out * out).gather(dim, index) / src, masked withwhere(src != 0)to keep gradients zero where
src == 0(mirrors upstream: when one bucketcontributor is 0, the bucket product is 0 so every contributor's gradient
is 0).