File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -4901,7 +4901,6 @@ static void llm_load_hparams(
4901
4901
} break;
4902
4902
case LLM_ARCH_PHI3:
4903
4903
{
4904
- ml.get_key(LLM_KV_ATTENTION_SLIDING_WINDOW, hparams.n_swa);
4905
4904
ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps);
4906
4905
4907
4906
switch (hparams.n_layer) {
@@ -4910,6 +4909,22 @@ static void llm_load_hparams(
4910
4909
case 40: model.type = e_model::MODEL_14B; break;
4911
4910
default: model.type = e_model::MODEL_UNKNOWN;
4912
4911
}
4912
+
4913
+ // for backward compatibility ; see: https://github.com/ggerganov/llama.cpp/pull/8931
4914
+ if ((hparams.n_layer == 32 || hparams.n_layer == 40) && hparams.n_ctx_train == 4096) {
4915
+ // default value for Phi-3-mini-4k-instruct and Phi-3-medium-4k-instruct
4916
+ hparams.n_swa = 2047;
4917
+ } else if (hparams.n_layer == 32 && hparams.n_head_kv(0) == 32 && hparams.n_ctx_train == 131072) {
4918
+ // default value for Phi-3-mini-128k-instruct
4919
+ hparams.n_swa = 262144;
4920
+ } else if (hparams.n_layer == 40 && hparams.n_ctx_train == 131072) {
4921
+ // default value for Phi-3-medium-128k-instruct
4922
+ hparams.n_swa = 131072;
4923
+ }
4924
+ bool found_swa = ml.get_key(LLM_KV_ATTENTION_SLIDING_WINDOW, hparams.n_swa, false);
4925
+ if (!found_swa && hparams.n_swa == 0) {
4926
+ throw std::runtime_error("invalid value for sliding_window");
4927
+ }
4913
4928
} break;
4914
4929
case LLM_ARCH_PLAMO:
4915
4930
{
You can’t perform that action at this time.
0 commit comments