Skip to content

Commit

Permalink
clip quantize skip problematic layer
Browse files Browse the repository at this point in the history
  • Loading branch information
LostRuins committed Dec 19, 2024
1 parent ee486ba commit fbf1345
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/llava/clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2722,6 +2722,7 @@ bool clip_image_batch_encode(clip_ctx * ctx, const int n_threads, const clip_ima
return true;
}

static bool avoid_problematic_indivisible = true;
bool clip_model_quantize(const char * fname_inp, const char * fname_out, const int itype) {
ggml_type type = GGML_TYPE_Q4_1;

Expand Down Expand Up @@ -2782,6 +2783,15 @@ bool clip_model_quantize(const char * fname_inp, const char * fname_out, const i
// quantize only 2D tensors
quantize &= (ggml_n_dims(cur) == 2);

//kcpp fix: do not quantize certain tensors if they are indivisible!
if(avoid_problematic_indivisible)
{
if(name=="v.position_embd.weight")
{
quantize = false;
}
}

if (quantize) {
new_type = type;
if (new_type >= GGML_TYPE_Q2_K && name.find("embd") != std::string::npos) {
Expand Down

0 comments on commit fbf1345

Please sign in to comment.