Skip to content

Commit 0481e5f

Browse files
author
Joan Martinez
committed
fix: fix linting issues
1 parent 4bce30c commit 0481e5f

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

convert-hf-to-gguf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def get_vocab_base_pre(self, tokenizer) -> str:
422422
# don't edit the hashes manually!
423423
if chkhsh == "0ef9807a4087ebef797fc749390439009c3b9eda9ad1a097abbe738f486c01e5":
424424
# ref: https://huggingface.co/meta-llama/Meta-Llama-3-8B
425-
res = "llama-bpe"
425+
res = "llama-bpe"
426426
if chkhsh == "049ecf7629871e3041641907f3de7c733e4dbfdc736f57d882ba0b0845599754":
427427
# ref: https://huggingface.co/deepseek-ai/deepseek-llm-7b-base
428428
res = "deepseek-llm"

llama.cpp

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,16 +4653,7 @@ static void llm_load_vocab(
46534653

46544654
// for now, only BPE models have pre-tokenizers
46554655
if (vocab.type == LLAMA_VOCAB_TYPE_BPE) {
4656-
if (tokenizer_pre.empty()) {
4657-
LLAMA_LOG_WARN("%s: missing pre-tokenizer type, using: 'default'\n", __func__);
4658-
LLAMA_LOG_WARN("%s: \n", __func__);
4659-
LLAMA_LOG_WARN("%s: ************************************ \n", __func__);
4660-
LLAMA_LOG_WARN("%s: GENERATION QUALITY WILL BE DEGRADED! \n", __func__);
4661-
LLAMA_LOG_WARN("%s: CONSIDER REGENERATING THE MODEL \n", __func__);
4662-
LLAMA_LOG_WARN("%s: ************************************ \n", __func__);
4663-
LLAMA_LOG_WARN("%s: \n", __func__);
4664-
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_DEFAULT;
4665-
} else if (
4656+
if (
46664657
tokenizer_pre == "default") {
46674658
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_DEFAULT;
46684659
} else if (
@@ -4715,7 +4706,8 @@ static void llm_load_vocab(
47154706
tokenizer_pre == "smaug-bpe") {
47164707
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_SMAUG;
47174708
} else {
4718-
throw std::runtime_error(format("unknown pre-tokenizer type: '%s'", tokenizer_pre.c_str()));
4709+
LLAMA_LOG_WARN("%s: missing or unrecognized pre-tokenizer type, using: 'default'\n", __func__);
4710+
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_DEFAULT;
47194711
}
47204712
} else {
47214713
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_DEFAULT;
@@ -5569,7 +5561,7 @@ static bool llm_load_tensors(
55695561
layer.attn_norm_2 = ml.create_tensor(ctx_layer, tn(LLM_TENSOR_ATTN_NORM_2, "weight", i), {n_embd}, llama_model_loader::TENSOR_NOT_REQUIRED);
55705562
layer.attn_norm_2_b = ml.create_tensor(ctx_layer, tn(LLM_TENSOR_ATTN_NORM_2, "bias", i), {n_embd}, llama_model_loader::TENSOR_NOT_REQUIRED);
55715563

5572-
layer.ffn_up = ml.create_tensor(ctx_split, tn(LLM_TENSOR_FFN_UP, "weight", i), {n_embd, n_ff});
5564+
layer.ffn_up = ml.create_tensor(ctx_split, tn(LLM_TENSOR_FFN_UP, "weight", i), {n_embd, n_ff});
55735565
layer.ffn_gate = ml.create_tensor(ctx_split, tn(LLM_TENSOR_FFN_GATE, "weight", i), {n_embd, n_ff});
55745566

55755567
layer.ffn_down = ml.create_tensor(ctx_split, tn(LLM_TENSOR_FFN_DOWN, "weight", i), {n_ff, n_embd});
@@ -6631,7 +6623,7 @@ static int llama_model_load(const std::string & fname, llama_model & model, llam
66316623
}
66326624
} catch (const std::exception & err) {
66336625
LLAMA_LOG_ERROR("%s: error loading model: %s\n", __func__, err.what());
6634-
return -1;
6626+
throw;
66356627
}
66366628

66376629
return 0;
@@ -16254,16 +16246,23 @@ struct llama_model * llama_load_model_from_file(
1625416246
}
1625516247
model->rpc_servers.push_back(servers);
1625616248
}
16257-
int status = llama_model_load(path_model, *model, params);
16258-
GGML_ASSERT(status <= 0);
16259-
if (status < 0) {
16260-
if (status == -1) {
16261-
LLAMA_LOG_ERROR("%s: failed to load model\n", __func__);
16262-
} else if (status == -2) {
16263-
LLAMA_LOG_INFO("%s: cancelled model load\n", __func__);
16249+
16250+
try {
16251+
int status = llama_model_load(path_model, *model, params);
16252+
GGML_ASSERT(status <= 0);
16253+
if (status < 0) {
16254+
if (status == -1) {
16255+
LLAMA_LOG_ERROR("%s: failed to load model\n", __func__);
16256+
} else if (status == -2) {
16257+
LLAMA_LOG_INFO("%s: cancelled model load\n", __func__);
16258+
}
16259+
delete model;
16260+
return nullptr;
1626416261
}
16262+
} catch (...) {
16263+
LLAMA_LOG_ERROR("%s: exception loading model\n", __func__);
1626516264
delete model;
16266-
return nullptr;
16265+
throw;
1626716266
}
1626816267

1626916268
return model;

0 commit comments

Comments
 (0)