Skip to content

Commit d863550

Browse files
committed
llama : allow gguf rope keys to be overridden with defaults
1 parent 6d3be57 commit d863550

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

Diff for: llama.cpp

+8-17
Original file line numberDiff line numberDiff line change
@@ -1617,28 +1617,19 @@ static void llm_load_hparams(
16171617
hparams.n_head_kv = hparams.n_head;
16181618
GGUF_GET_KEY(ctx, hparams.n_head_kv, gguf_get_val_u32, GGUF_TYPE_UINT32, false, kv(LLM_KV_ATTENTION_HEAD_COUNT_KV));
16191619

1620-
// TODO: manually setting rope freq base and scale should override this
1621-
// FIXME: partial fix when the param specified is not the default value, but
1622-
// will not work for overriding the model value to the params default
1623-
16241620
llama_context_params defaults = llama_context_default_params();
16251621

1626-
// rope_freq_base
1627-
{
1628-
float ropebase = 10000.0f;
1629-
GGUF_GET_KEY(ctx, ropebase, gguf_get_val_f32, GGUF_TYPE_FLOAT32, false, kv(LLM_KV_ROPE_FREQ_BASE));
1630-
if (ropebase != 10000.0f && rope_freq_base == defaults.rope_freq_base) {
1631-
rope_freq_base = ropebase;
1632-
}
1622+
// rope_freq_base (optional)
1623+
if (rope_freq_base == 0.0f) {
1624+
rope_freq_base = 10000.0f;
1625+
GGUF_GET_KEY(ctx, rope_freq_base, gguf_get_val_f32, GGUF_TYPE_FLOAT32, false, kv(LLM_KV_ROPE_FREQ_BASE));
16331626
}
16341627

16351628
// rope_freq_scale (inverse of the kv) is optional
1636-
{
1629+
if (rope_freq_scale == 0.0f) {
16371630
float ropescale = 1.0f;
16381631
GGUF_GET_KEY(ctx, ropescale, gguf_get_val_f32, GGUF_TYPE_FLOAT32, false, kv(LLM_KV_ROPE_SCALE_LINEAR));
1639-
if (ropescale != 1.0f && rope_freq_scale == defaults.rope_freq_scale) {
1640-
rope_freq_scale = 1.0f/ropescale;
1641-
}
1632+
rope_freq_scale = 1.0f/ropescale;
16421633
}
16431634

16441635
// sanity check for n_rot (optional)
@@ -5349,8 +5340,8 @@ struct llama_context_params llama_context_default_params() {
53495340
/*.n_gpu_layers =*/ 0,
53505341
/*.main_gpu =*/ 0,
53515342
/*.tensor_split =*/ nullptr,
5352-
/*.rope_freq_base =*/ 10000.0f,
5353-
/*.rope_freq_scale =*/ 1.0f,
5343+
/*.rope_freq_base =*/ 0.0f,
5344+
/*.rope_freq_scale =*/ 0.0f,
53545345
/*.progress_callback =*/ nullptr,
53555346
/*.progress_callback_user_data =*/ nullptr,
53565347
/*.low_vram =*/ false,

0 commit comments

Comments
 (0)