Skip to content

Commit 0f71589

Browse files
committed
Model: Warn user if wrong model type option is used
1 parent 14206fd commit 0f71589

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

model.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,11 +820,20 @@ bool ModelLoader::init_from_gguf_file(const std::string& file_path, const std::s
820820

821821
size_t total_size = 0;
822822
size_t data_offset = gguf_get_data_offset(ctx_gguf_);
823+
823824
for (int i = 0; i < n_tensors; i++) {
824825
std::string name = gguf_get_tensor_name(ctx_gguf_, i);
825826
struct ggml_tensor* dummy = ggml_get_tensor(ctx_meta_, name.c_str());
826827
size_t offset = data_offset + gguf_get_tensor_offset(ctx_gguf_, i);
827828

829+
if(i==0 && starts_with(name,prefix)){
830+
LOG_WARN("Tensors have built-in %s prefix.\n", prefix);
831+
if(prefix == "model.diffusion_model."){
832+
// the user probably used `--diffusion-model` instead of `-m`
833+
LOG_WARN("Try using `-m`or `--model` instead of `--diffusion-model`\n");
834+
}
835+
}
836+
828837
// LOG_DEBUG("%s", name.c_str());
829838

830839
TensorStorage tensor_storage(prefix + name, dummy->type, dummy->ne, ggml_n_dims(dummy), file_index, offset);
@@ -903,6 +912,7 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
903912

904913
nlohmann::json header_ = nlohmann::json::parse(header_buf.data());
905914

915+
int i =0;
906916
for (auto& item : header_.items()) {
907917
std::string name = item.key();
908918
nlohmann::json tensor_info = item.value();
@@ -953,6 +963,14 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
953963
n_dims = 1;
954964
}
955965

966+
if(i++==0 && starts_with(name,prefix)){
967+
LOG_WARN("Tensors have built-in %s prefix.\n", prefix);
968+
if(prefix == "model.diffusion_model."){
969+
// the user probably used `--diffusion-model` instead of `-m`
970+
LOG_WARN("Try using `-m`or `--model` instead of `--diffusion-model`\n");
971+
}
972+
}
973+
956974
TensorStorage tensor_storage(prefix + name, type, ne, n_dims, file_index, ST_HEADER_SIZE_LEN + header_size_ + begin);
957975
tensor_storage.reverse_ne();
958976

@@ -1332,6 +1350,13 @@ bool ModelLoader::init_from_ckpt_file(const std::string& file_path, const std::s
13321350
{
13331351
std::string name = zip_entry_name(zip);
13341352
size_t pos = name.find("data.pkl");
1353+
if(i==0 && starts_with(name,prefix)){
1354+
LOG_WARN("Tensors have built-in %s prefix.\n", prefix);
1355+
if(prefix == "model.diffusion_model."){
1356+
// the user probably used `--diffusion-model` instead of `-m`
1357+
LOG_WARN("Try using `-m`or `--model` instead of `--diffusion-model`\n");
1358+
}
1359+
}
13351360
if (pos != std::string::npos) {
13361361
std::string dir = name.substr(0, pos);
13371362
void* pkl_data = NULL;

0 commit comments

Comments
 (0)