Skip to content

Commit fe14626

Browse files
committed
add support for Qwen Image Pruning
From leejet/stable-diffusion.cpp#874 .
1 parent 2fa28fd commit fe14626

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

otherarch/sdcpp/qwen_image.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,22 @@ namespace Qwen {
492492
bool flash_attn = false)
493493
: GGMLRunner(backend, offload_params_to_cpu) {
494494
qwen_image_params.flash_attn = flash_attn;
495+
496+
int model_layers = 60;
497+
int num_layers = 1;
498+
for (int layer = model_layers; layer > num_layers; layer--) {
499+
for (auto pair : tensor_types) {
500+
if (pair.first.find("model.diffusion_model.transformer_blocks." + std::to_string(layer-1) + ".attn.add_k_proj.bias") != std::string::npos) {
501+
num_layers = layer;
502+
break;
503+
}
504+
}
505+
}
506+
if (num_layers < model_layers) {
507+
LOG_INFO("Qwen Image: some layers missing, assuming pruned model");
508+
}
509+
510+
qwen_image_params.num_layers = num_layers;
495511
qwen_image = QwenImageModel(qwen_image_params);
496512
qwen_image.init(params_ctx, tensor_types, prefix);
497513
}

0 commit comments

Comments
 (0)