Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LostRuins committed Mar 5, 2024
1 parent 4eb3a95 commit d910f23
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion koboldcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ def togglehorde(a,b,c):

# Image Gen Tab
images_tab = tabcontent["Image Gen"]
makefileentry(images_tab, "Stable Diffusion Model (f16 safetensors):", "Select Stable Diffusion Model File", sd_model_var, 1, filetypes=[("*.safetensors","*.safetensors")], tooltiptxt="Select a .safetensors Stable Diffusion model file on disk to be loaded.")
makefileentry(images_tab, "Stable Diffusion Model (safetensors/gguf):", "Select Stable Diffusion Model File", sd_model_var, 1, filetypes=[("*.safetensors *.gguf","*.safetensors *.gguf")], tooltiptxt="Select a .safetensors or .gguf Stable Diffusion model file on disk to be loaded.")
makecheckbox(images_tab, "Quick Mode (Low Quality)", sd_quick_var, 4,tooltiptxt="Force optimal generation settings for speed.")
makelabelentry(images_tab, "Image threads:" , sd_threads_var, 6, 50,"How many threads to use during image generation.\nIf left blank, uses same value as threads.")
makecheckbox(images_tab, "Compress Weights (Saves Memory)", sd_quant_var, 8,tooltiptxt="Quantizes the SD model weights to save memory. May degrade quality.")
Expand Down
6 changes: 6 additions & 0 deletions otherarch/ggml_v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -20058,6 +20058,12 @@ struct gguf_v3_context * gguf_v3_init_from_file(const char * fname, struct gguf_
fprintf(stderr, "%s: GGUFv1 is deprecated. please update if possible.\n", __func__);
}

// sanity-checks to prevent from integer/buffer overflows

ok = ok && (ctx->header.n_tensors < (SIZE_MAX/2)/sizeof(struct gguf_v3_tensor_info));
ok = ok && (ctx->header.n_tensors < (SIZE_MAX/2)/ggml_v3_tensor_overhead());
ok = ok && (ctx->header.n_kv < (SIZE_MAX/2)/sizeof(struct gguf_v3_kv));

if (!ok) {
fprintf(stderr, "%s: failed to read header\n", __func__);
fclose(file);
Expand Down
11 changes: 7 additions & 4 deletions otherarch/sdcpp/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,13 @@ bool ModelLoader::init_from_file(const std::string& file_path, const std::string
} else if (is_safetensors_file(file_path)) {
LOG_INFO("load %s using safetensors format", file_path.c_str());
return init_from_safetensors_file(file_path, prefix);
} else if (is_zip_file(file_path)) {
LOG_INFO("load %s using checkpoint format", file_path.c_str());
return init_from_ckpt_file(file_path, prefix);
} else {
}
//disable ckpt loading
// else if (is_zip_file(file_path)) {
// LOG_INFO("load %s using checkpoint format", file_path.c_str());
// return init_from_ckpt_file(file_path, prefix);
// } else
{
LOG_WARN("unknown format %s", file_path.c_str());
return false;
}
Expand Down

0 comments on commit d910f23

Please sign in to comment.