ggml-cpu : fix rms_norm_back wrong output under in-place aliasing#24305
Merged
Conversation
08856ac to
3bddfef
Compare
|
Hi @devYRPauli, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
ggerganov
approved these changes
Jun 8, 2026
ggerganov
reviewed
Jun 9, 2026
anaisbetts
pushed a commit
to anaisbetts/llama.cpp
that referenced
this pull request
Jun 16, 2026
…ml-org#24305) * ggml-cpu : fix rms_norm_back wrong output under in-place aliasing * cont : clean-up comment --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> (cherry picked from commit fd3271e)
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.
Overview
ggml_compute_forward_rms_norm_back_f32could produce wrong results when the destination aliases an input.GGML_OP_RMS_NORM_BACKis listed inggml_op_can_inplace, so the scheduler may reusesrc0(dz) orsrc1(x)'s buffer fordx. The old multi-stepcpy/scale/acc/scalesequence overwrote that buffer in thedx := xstep and then re-read it in the+= dzstep. This replaces it with a single fused read-before-write loop, which is safe under either aliasing.Additional information
Requested by @ggerganov in ggml-org/ggml#1519, where I originally reported and fixed this (#1491). Submitting the single ops.cpp change here as asked; no regression test per that thread. Built
ggml-cpulocally on macOS to confirm it compiles.Requirements