-
Notifications
You must be signed in to change notification settings - Fork 13.2k
[CANN] Optimize RMS_NORM using cache #15419
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
Merged
Merged
Conversation
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
Opt Test:Backend 1/2: CANN0
Device description: Ascend910B4
Device memory: 30196 MB (29851 MB free)
new_pool_for_device: device 0 use vmm pool
RMS_NORM(type=f32,ne=[64,5,4,3],v=0,eps=0.000000): OK
RMS_NORM(type=f32,ne=[64,5,4,3],v=1,eps=0.000000): OK
RMS_NORM(type=f32,ne=[64,5,4,3],v=0,eps=0.000001): OK
RMS_NORM(type=f32,ne=[64,5,4,3],v=1,eps=0.000001): OK
RMS_NORM(type=f32,ne=[64,5,4,3],v=0,eps=0.000100): OK
RMS_NORM(type=f32,ne=[64,5,4,3],v=1,eps=0.000100): OK
RMS_NORM(type=f32,ne=[64,5,4,3],v=0,eps=0.100000): OK
RMS_NORM(type=f32,ne=[64,5,4,3],v=1,eps=0.100000): OK
10844/10844 tests passed
Backend CANN0: OK
Backend 2/2: CPU
Skipping
2/2 backends passed
OK Model Test:Script ./bin/llama-cli -m /home/lichenguang25/.ollama/models/blobs/sha256-6f96e01a3f550ca08aea1e5725bb8d5a7eccc6f281c30417e9d380b8c46467bd -p "Building a website can be done in 10 steps:" -ngl 32 -fa
|
hipudding
reviewed
Aug 20, 2025
Signed-off-by: noemotiovon <757486878@qq.com>
Signed-off-by: noemotiovon <757486878@qq.com>
485fd39
to
c24b995
Compare
Signed-off-by: noemotiovon <757486878@qq.com>
hipudding
approved these changes
Aug 22, 2025
qnixsynapse
pushed a commit
to menloresearch/llama.cpp
that referenced
this pull request
Aug 25, 2025
* [CANN] Optimize RMS_NORM using cache Signed-off-by: noemotiovon <757486878@qq.com> * fix typo Signed-off-by: noemotiovon <757486878@qq.com> * fix review comment Signed-off-by: noemotiovon <757486878@qq.com> * codestyle adjustment Signed-off-by: noemotiovon <757486878@qq.com> --------- Signed-off-by: noemotiovon <757486878@qq.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Ascend NPU
issues specific to Ascend NPUs
ggml
changes relating to the ggml tensor library for machine learning
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.
Description:
This PR introduces a cache-based optimization for the RMS_NORM operator in the CANN backend. By reusing pre-allocated zero and one float32 tensors, it reduces redundant memory allocations and improves runtime performance for RMS normalization operations.
What does this PR do?
Initializes a reusable cache for zero-filled and one-filled float32 tensors.
Expands the cache dynamically if the requested tensor size exceeds the current cache capacity.
Modifies RMS_NORM computations to utilize the cache, reducing memory operations.
Improves performance for large-scale tensor normalization in CANN backend.
Why is this needed?
Avoids frequent memory allocation and deallocation during RMS normalization.
Reduces overhead and latency in tensor computations, especially for large models.
Performance Impact:
Significant reduction in memory allocation overhead for RMS_NORM.
Faster execution for large tensors due to cache reuse.