-
Notifications
You must be signed in to change notification settings - Fork 13.3k
CANN: optimize rope cache #15436
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
CANN: optimize rope cache #15436
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2216,16 +2216,14 @@ static void aclnn_cache_init(ggml_backend_cann_context& ctx, ggml_tensor* dst, | |||||||||
ggml_cann_release_resources(ctx, acl_theta_scale_tensor,acl_theta_scale); | ||||||||||
} | ||||||||||
|
||||||||||
if(ctx.sin_ptr == nullptr) { | ||||||||||
int64_t theta_length = theta_scale_length * ctx.max_prompt_length; | ||||||||||
ACL_CHECK(aclrtMalloc(&ctx.sin_ptr, theta_length * sizeof(float_t), ACL_MEM_MALLOC_HUGE_FIRST)); | ||||||||||
ACL_CHECK(aclrtMalloc(&ctx.cos_ptr, theta_length * sizeof(float_t), ACL_MEM_MALLOC_HUGE_FIRST)); | ||||||||||
} | ||||||||||
if(position_length > ctx.max_prompt_length) { | ||||||||||
ctx.max_prompt_length = position_length; | ||||||||||
int64_t theta_length = theta_scale_length * ctx.max_prompt_length; | ||||||||||
ACL_CHECK(aclrtFree(ctx.sin_ptr)); | ||||||||||
ACL_CHECK(aclrtFree(ctx.cos_ptr)); | ||||||||||
|
||||||||||
if (ctx.sin_ptr != nullptr) | ||||||||||
ACL_CHECK(aclrtFree(ctx.sin_ptr)); | ||||||||||
if (ctx.cos_ptr != nullptr) | ||||||||||
ACL_CHECK(aclrtFree(ctx.cos_ptr)); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The conditional check for ctx.cos_ptr != nullptr is missing braces around the ACL_CHECK(aclrtFree(ctx.cos_ptr)) call on line 2226. This creates a logic error where the free operation is always executed regardless of the null check.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine because there's only one line in |
||||||||||
ACL_CHECK(aclrtMalloc(&ctx.sin_ptr, theta_length * sizeof(float_t), ACL_MEM_MALLOC_HUGE_FIRST)); | ||||||||||
ACL_CHECK(aclrtMalloc(&ctx.cos_ptr, theta_length * sizeof(float_t), ACL_MEM_MALLOC_HUGE_FIRST)); | ||||||||||
} | ||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.