Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: correct scaling calculations in rope_cache_init
  • Loading branch information
chraac committed Nov 27, 2025
commit 4ddb8a449cbe057d67b684b7c34192e69f743d30
11 changes: 6 additions & 5 deletions ggml/src/ggml-hexagon/htp/rope-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,18 @@ static void rope_cache_init(const float theta_base,
// Get n-d rotational scaling corrected for extrapolation
float theta_interp = freq_scale * theta_extrap;
float theta2 = theta_interp;
float mscale2 = mscale;

if (ext_factor != 0.0f) {
float ramp_mix = rope_yarn_ramp(corr_dims[0], corr_dims[1], i0) * ext_factor;
theta2 = theta_interp * (1 - ramp_mix) + theta_extrap * ramp_mix;

// Get n-d magnitude scaling corrected for interpolation
mscale *= 1.0f + 0.1f * logf(1.0f / freq_scale);
mscale2 *= 1.0f + 0.1f * logf(1.0f / freq_scale);
}

cache[i0 + 0] = cosf(theta2) * mscale;
cache[i0 + 1] = sinf(theta2) * mscale;
cache[i0 + 0] = cosf(theta2) * mscale2;
cache[i0 + 1] = sinf(theta2) * mscale2;

theta *= theta_scale;
}
Expand Down Expand Up @@ -337,8 +338,8 @@ static void rope_hex_f32(struct rope_th_ctx * rope_ctx,
}
}

src_loc += is_neox ? (rope_ctx->n_dims / 2) : 0;
dst_data_loc += is_neox ? (rope_ctx->n_dims / 2) : 0;
src_loc += (is_neox ? (rope_ctx->n_dims / 2) : 0);
dst_data_loc += (is_neox ? (rope_ctx->n_dims / 2) : 0);
for (uint32_t i0 = rope_ctx->n_dims; i0 < ne0; i0 += 2) {
dst_data_loc[0] = src_loc[0];
dst_data_loc[1] = src_loc[1];
Expand Down