CANN: add RoPE cache preload before ACL graph capture#20747
Merged
hipudding merged 1 commit intoggml-org:masterfrom Mar 23, 2026
Merged
CANN: add RoPE cache preload before ACL graph capture#20747hipudding merged 1 commit intoggml-org:masterfrom
hipudding merged 1 commit intoggml-org:masterfrom
Conversation
Collaborator
Author
|
Test Log: |
ACL graph capture disallows host-to-device memcpy and device memory malloc/free on the captured stream. Pre-load the RoPE cache before capture so that: - Host-to-device copies and allocations run on the non-captured stream - Cache metadata is populated and memory pool is warmed up - During capture, only on-device computations are recorded; host-side and allocation branches are skipped
hipudding
reviewed
Mar 20, 2026
| // Run the full cache init on the non-captured stream. This performs all | ||
| // host-to-device memcpy, aclrtMalloc/Free, and on-device computations | ||
| // so that the memory pool is warmed up and cache metadata is populated. | ||
| aclnn_rope_cache_init(ctx, dst, corr_dims, ext_factor, theta_scale, freq_scale, attn_factor, is_neox, sections, |
Contributor
There was a problem hiding this comment.
cache init do a lot of pre calculation, here we only need cache all cpu calculation results. You may refactor it later.
Collaborator
Author
There was a problem hiding this comment.
Yes, I took a shortcut here and directly reused the existing method. Later, I will customize the initialization process for the host data in RoPE.
| } | ||
|
|
||
| if (node->op == GGML_OP_SCALE || node->op == GGML_OP_UNARY || node->op == GGML_OP_GLU) { | ||
| if (node->op == GGML_OP_SCALE || node->op == GGML_OP_UNARY || node->op == GGML_OP_GLU || node->op == GGML_OP_ROPE){ |
Contributor
There was a problem hiding this comment.
Why there is not a problem before since ROPE param is not stored.
Collaborator
Author
There was a problem hiding this comment.
Previously, RoPE was not compared during graph matching because, in model inference, it’s unnecessary to compare the parameters since they are consistent. After adding it, RoPE can now pass precision tests in ACL graph mode.
hipudding
approved these changes
Mar 23, 2026
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.
ACL graph capture disallows host-to-device memcpy and device memory malloc/free on the captured stream. Pre-load the RoPE cache before capture so that:
Make sure to read the contributing guidelines before submitting a PR