feat: support packed INT4 convrot models (#2276)

Co-authored-by: noctrex <noctrex@gmail.com>
This commit is contained in:
leejetandnoctrex authored and GitHub committed 2026-11-06 00:35:58 +08:00
1 parent 58bb3c1b1c
commit 7952693004
48 files changed
+2003 -102

No files matched your search

+9 -8
View File
@@ -518,7 +518,7 @@ SDVersion ModelLoader::get_sd_version() const {
}
if (tensor_storage.name.find("model.diffusion_model.transformer_blocks.0.img_mod.1.weight") != std::string::npos) {
auto img_in = tensor_storage_map.find("model.diffusion_model.img_in.weight");
if (img_in != tensor_storage_map.end() && img_in->second.ne[0] == 128) {
if (img_in != tensor_storage_map.end() && img_in->second.logical_ne0() == 128) {
return VERSION_MAGE_FLOW;
}
if (tensor_storage_map.find("model.diffusion_model.time_text_embed.addition_t_embedding.weight") != tensor_storage_map.end()) {
@@ -593,7 +593,7 @@ SDVersion ModelLoader::get_sd_version() const {
}
}
auto connector = tensor_storage_map.find("embeddings_connectors.proj.weight");
if (connector != tensor_storage_map.end() && connector->second.ne[0] == 12800 &&
if (connector != tensor_storage_map.end() && connector->second.logical_ne0() == 12800 &&
connector->second.ne[1] == 5120 && tensor_storage_map.count("embeddings_connectors.sink_embedding")) {
return VERSION_P_H3_IMAGE;
}
@@ -660,7 +660,7 @@ SDVersion ModelLoader::get_sd_version() const {
tensor_storage.name.find("unet.up_blocks.2.attentions.1") != std::string::npos) {
has_output_block_71 = true;
if (tensor_storage.name.find("model.diffusion_model.output_blocks.7.1.transformer_blocks.0.attn1.to_k.weight") != std::string::npos) {
if (tensor_storage.ne[0] == 1024)
if (tensor_storage.logical_ne0() == 1024)
has_attn_1024 = true;
}
}
@@ -721,16 +721,16 @@ SDVersion ModelLoader::get_sd_version() const {
if (has_distilled_guidance) {
return VERSION_CHROMA;
}
if (context_ebedding_weight.ne[0] == 3584) {
if (context_ebedding_weight.logical_ne0() == 3584) {
return VERSION_LONGCAT;
} else {
if (input_block_weight.ne[0] == 384) {
if (input_block_weight.logical_ne0() == 384) {
return VERSION_FLUX_FILL;
}
if (input_block_weight.ne[0] == 128) {
if (input_block_weight.logical_ne0() == 128) {
return VERSION_FLUX_CONTROLS;
}
if (input_block_weight.ne[0] == 196) {
if (input_block_weight.logical_ne0() == 196) {
return VERSION_FLEX_2;
}
return VERSION_FLUX;
@@ -1651,7 +1651,8 @@ bool ModelLoader::load_tensors(std::map<std::string, ggml_tensor*>& tensors,
bool ModelLoader::tensor_should_be_converted(const TensorStorage& tensor_storage, ggml_type type) const {
const std::string& name = tensor_storage.name;
if (tensor_storage.is_int8_tensorwise) {
if (tensor_storage.is_int8_tensorwise || tensor_storage.w4_convrot_kind != 0 ||
ends_with(name, ".weight_codebook") || ends_with(name, ".weight_s_channel") || ends_with(name, ".weight_s_rel")) {
return false;
}
if (type != GGML_TYPE_COUNT) {