-
Notifications
You must be signed in to change notification settings - Fork 12k
Allow specifying p scale factor for ggml rope and rope_back ops #1967
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
Changes from all commits
bc17e11
4bf45a7
887694a
e92795f
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 |
---|---|---|
|
@@ -1906,13 +1906,16 @@ inline void ggml_cuda_op_rope( | |
const int64_t ne00 = src0->ne[0]; | ||
const int64_t i01_diff = i01_high - i01_low; | ||
|
||
const int n_past = ((int32_t *) src1->data)[0]; | ||
const int n_dims = ((int32_t *) src1->data)[1]; | ||
const int mode = ((int32_t *) src1->data)[2]; | ||
assert(src1->type == GGML_TYPE_F32); | ||
assert(ggml_nelements(src1) == 4); | ||
const int n_past = (int)((float *) src1->data)[0]; | ||
const int n_dims = (int)((float *) src1->data)[1]; | ||
const int mode = (int)((float *) src1->data)[2]; | ||
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. These are UB. 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.
Can you explain in more detail? Are you saying it's illegal to cast Also, just to be clear, those values were originally |
||
const float p_scale = ((float *) src1->data)[3]; | ||
GGML_ASSERT(mode == 0); | ||
|
||
const float theta_scale = powf(10000.0, -2.0f/n_dims); | ||
const float p = ((mode & 1) == 0 ? n_past + i02 : i02); | ||
const float p = p_scale * ((mode & 1) == 0 ? n_past + i02 : i02); | ||
|
||
// compute | ||
rope_f32_cuda(src0_ddf_i, dst_ddf_i, ne00, i01_diff, p, theta_scale, cudaStream_main); | ||
|
Uh oh!
There was an error while loading. Please reload this page.