Skip to content

Commit 76988cd

Browse files
committed
llama : allow gguf rope keys to be overridden with defaults
1 parent 78c45b7 commit 76988cd

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

llama.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,28 +1673,19 @@ static void llm_load_hparams(
16731673
hparams.n_head_kv = hparams.n_head;
16741674
GGUF_GET_KEY(ctx, hparams.n_head_kv, gguf_get_val_u32, GGUF_TYPE_UINT32, false, kv(LLM_KV_ATTENTION_HEAD_COUNT_KV));
16751675

1676-
// TODO: manually setting rope freq base and scale should override this
1677-
// FIXME: partial fix when the param specified is not the default value, but
1678-
// will not work for overriding the model value to the params default
1679-
16801676
llama_context_params defaults = llama_context_default_params();
16811677

1682-
// rope_freq_base
1683-
{
1684-
float ropebase = 10000.0f;
1685-
GGUF_GET_KEY(ctx, ropebase, gguf_get_val_f32, GGUF_TYPE_FLOAT32, false, kv(LLM_KV_ROPE_FREQ_BASE));
1686-
if (ropebase != 10000.0f && rope_freq_base == defaults.rope_freq_base) {
1687-
rope_freq_base = ropebase;
1688-
}
1678+
// rope_freq_base (optional)
1679+
if (rope_freq_base == 0.0f) {
1680+
rope_freq_base = 10000.0f;
1681+
GGUF_GET_KEY(ctx, rope_freq_base, gguf_get_val_f32, GGUF_TYPE_FLOAT32, false, kv(LLM_KV_ROPE_FREQ_BASE));
16891682
}
16901683

16911684
// rope_freq_scale (inverse of the kv) is optional
1692-
{
1685+
if (rope_freq_scale == 0.0f) {
16931686
float ropescale = 1.0f;
16941687
GGUF_GET_KEY(ctx, ropescale, gguf_get_val_f32, GGUF_TYPE_FLOAT32, false, kv(LLM_KV_ROPE_SCALE_LINEAR));
1695-
if (ropescale != 1.0f && rope_freq_scale == defaults.rope_freq_scale) {
1696-
rope_freq_scale = 1.0f/ropescale;
1697-
}
1688+
rope_freq_scale = 1.0f/ropescale;
16981689
}
16991690

17001691
// sanity check for n_rot (optional)
@@ -6187,8 +6178,8 @@ struct llama_context_params llama_context_default_params() {
61876178
/*.n_gpu_layers =*/ 0,
61886179
/*.main_gpu =*/ 0,
61896180
/*.tensor_split =*/ nullptr,
6190-
/*.rope_freq_base =*/ 10000.0f,
6191-
/*.rope_freq_scale =*/ 1.0f,
6181+
/*.rope_freq_base =*/ 0.0f,
6182+
/*.rope_freq_scale =*/ 0.0f,
61926183
/*.progress_callback =*/ nullptr,
61936184
/*.progress_callback_user_data =*/ nullptr,
61946185
/*.low_vram =*/ false,

0 commit comments

Comments
 (0)