Repository navigation
metal : add support for GGML_OP_REPEAT_BACK - #26057
Open
wuisabel-gif wants to merge 1 commit into
Open
wuisabel-gif wants to merge 1 commit into
wuisabel-gif wants to merge 1 commit into
Conversation
Add kernel_repeat_back_f32 and wire up pipeline, encode, and supports_op. One threadgroup per output row (i1, i2, i3), threads stride over ne0, each thread sums all tiled copies of its element from the gradient tensor. Offsets computed from byte strides so non-contiguous views work. Reuses ggml_metal_kargs_repeat since the argument layout matches the forward op. F32 only, matching CPU/CUDA. REPEAT previously reached an unconditional return true via fall-through; made it explicit so the new REPEAT_BACK case does not change its behavior. Ref ggml-org#14909
This branch has not been deployed
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.
The Metal backend did not support GGML_OP_REPEAT_BACK, this PR adds it, addressing part of #14909.
REPEAT_BACK is the backward pass of REPEAT. The forward op tiles a source tensor into multiple copies, so during backpropagation each copy carries its own gradient, and all of them originate from the same source element. The backward op therefore reduces the gradient tensor back to the original shape by summing, for each source element, the gradients at every position that copies it.
Only F32 is implemented and tested, matching the type scope of the CPU and CUDA implementations. Other types are not claimed in supports_op.
Tested on Apple M3 at master c0bc859:
Before: all 10 cases reported "not supported". After: 10/10 REPEAT_BACK cases passed against the CPU reference, including non-contiguous input cases.
AI usage disclosure: yes, used Codex Sol 5.6 to review and edit. I reviewed the edit changes and tested on hardware.