Commit b3319c0 for stable-diffusion.cpp

commit b3319c02f7a7cd724fb17aa4463f03ce981aa886
Author: leejet <leejet714@gmail.com>
Date:   Mon Nov 30 01:29:50 2026 +0800

    feat: support pi-H3 adapters in DGL (#2468)

diff --git a/docs/dgl-builtins.md b/docs/dgl-builtins.md
index 1cedb5b..c9a830b 100644
--- a/docs/dgl-builtins.md
+++ b/docs/dgl-builtins.md
@@ -43,12 +43,12 @@ Optional parameters are marked with `?`. Default values follow `=`. See [DGL syn
 | `load_audio_encoder` (resource) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `linear_type?: string = "auto"` | `audio_encoder` |
 | `load_audio_vae` (resource) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `family_from?: string = ""`, `linear_type?: string = "auto"` | `audio_vae` |
 | `load_detector` (resource) | `path: string`, `backend?: string = ""`, `params_backend?: string = ""`, `linear_type?: string = "auto"` | `detector` |
-| `load_dit` (resource) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `linear_type?: string = "auto"` | `denoiser` |
+| `load_dit` (resource) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `linear_type?: string = "auto"`, `weights_override?: string = ""` | `denoiser` |
 | `load_latent_upscaler` (resource) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `linear_type?: string = "auto"` | `latent_upscaler` |
 | `load_lora` (resource) | `path: string` | `lora` |
 | `load_tae` (resource) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `family_from?: string = ""`, `decode_only?: bool = false`, `linear_type?: string = "auto"` | `vae` |
 | `load_text_encoder` (resource) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `family_from?: string = ""`, `tokenizer?: string = ""`, `vision_path?: string = ""`, `projection_path?: string = ""`, `connectors_path?: string = ""`, `t5_path?: string = ""`, `clip_l_path?: string = ""`, `clip_g_path?: string = ""`, `linear_type?: string = "auto"` | `text_encoder` |
-| `load_unet` (resource) (alias of `load_dit`) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `linear_type?: string = "auto"` | `denoiser` |
+| `load_unet` (resource) (alias of `load_dit`) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `linear_type?: string = "auto"`, `weights_override?: string = ""` | `denoiser` |
 | `load_upscaler` (resource) | `path: string`, `tile_size?: int = 128`, `backend?: string = ""`, `params_backend?: string = ""`, `direct?: bool = false`, `linear_type?: string = "auto"` | `upscaler` |
 | `load_vae` (resource) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `family_from?: string = ""`, `vae_format?: string = "auto"`, `linear_type?: string = "auto"` | `vae` |
 | `load_vision_encoder` (resource) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `linear_type?: string = "auto"` | `vision_encoder` |
diff --git a/docs/dgl/README.md b/docs/dgl/README.md
index c1b9623..2f25476 100644
--- a/docs/dgl/README.md
+++ b/docs/dgl/README.md
@@ -91,7 +91,7 @@ and [NumPy tensor files](../dgl.md#tensor-files).
 | [LingBot-Video](../models/lingbot_video.md) | [Dens 1.3B text to video](lingbot_video/lingbot-video-dens-1-3b-txt2video.dgl) |
 | [LTX-2.3](../models/ltx2.md) | [2.3 text to video](ltx2/ltx-2-3-dev-txt2video.dgl) · [2.3 image to video](ltx2/ltx-2-3-dev-img2video.dgl) · [2.3 first/last frames](ltx2/ltx-2-3-dev-first-last-frame.dgl) · [2.3 spatial latent upscale](ltx2/ltx-2-3-spatial-upscale.dgl) |
 | [LTX-2.5](../models/ltx2.md) | [2.5 text to video](ltx2/ltx-2-5-dev-txt2video.dgl) · [2.5 image to video](ltx2/ltx-2-5-dev-img2video.dgl) · [2.5 spatial latent upscale](ltx2/ltx-2-5-spatial-upscale.dgl) |
-| [MiniMax-H3](../models/minimax_h3.md) | [Text to audio/video](minimax_h3/minimax-h3-text-to-av.dgl) · [First/last-frame conditioning](minimax_h3/minimax-h3-first-last-frame.dgl) · [Reference to audio/video](minimax_h3/minimax-h3-reference-to-av.dgl) · [Interpolated latent hires](minimax_h3/minimax-h3-latent-hires.dgl) · [Learned latent hires](minimax_h3/minimax-h3-learned-hires.dgl) · [Audio/video continuation](minimax_h3/minimax-h3-av-continuation.dgl) |
+| [MiniMax-H3](../models/minimax_h3.md) | [Text to audio/video](minimax_h3/minimax-h3-text-to-av.dgl) · [pi-H3 four-step text to audio/video](minimax_h3/pi-h3-text-to-av.dgl) · [First/last-frame conditioning](minimax_h3/minimax-h3-first-last-frame.dgl) · [Reference to audio/video](minimax_h3/minimax-h3-reference-to-av.dgl) · [Interpolated latent hires](minimax_h3/minimax-h3-latent-hires.dgl) · [Learned latent hires](minimax_h3/minimax-h3-learned-hires.dgl) · [Audio/video continuation](minimax_h3/minimax-h3-av-continuation.dgl) |
 | [Wan 2.1](../models/wan.md) | [Text to video, 1.3B](wan/wan2-1-t2v-1-3b.dgl) · [Text to video, 14B](wan/wan2-1-t2v-14b.dgl) · [Image to video, 14B](wan/wan2-1-i2v-14b.dgl) · [First/last frames, 14B](wan/wan2-1-first-last-frame-14b.dgl) |
 | [Wan 2.1 VACE 1.3B](../models/wan.md) | [Text to video](wan/wan2-1-vace-1-3b-txt2video.dgl) · [Reference to video](wan/wan2-1-vace-1-3b-ref2video.dgl) · [Video to video](wan/wan2-1-vace-1-3b-video2video.dgl) |
 | [Wan 2.1 VACE 14B](../models/wan.md) | [Text to video](wan/wan2-1-vace-14b-txt2video.dgl) · [Reference to video](wan/wan2-1-vace-14b-ref2video.dgl) · [Video to video](wan/wan2-1-vace-14b-video2video.dgl) |
diff --git a/docs/dgl/minimax_h3/pi-h3-text-to-av.dgl b/docs/dgl/minimax_h3/pi-h3-text-to-av.dgl
new file mode 100644
index 0000000..02265dd
--- /dev/null
+++ b/docs/dgl/minimax_h3/pi-h3-text-to-av.dgl
@@ -0,0 +1,57 @@
+# version: 0.0.0
+# docs/models/minimax_h3.md — pi-H3 four-step generation
+
+var {
+    model_path = "../models/diffusion_models/minimax_h3_fl2va_pruned-Q4_K_M.gguf"
+    adapter_path = "../models/loras/minimax/pi_h3_4step_adapter.safetensors"
+    text_path = "../models/text_encoders/qwen3vl_32b_minimax_h3-Q4_K_M.gguf"
+    vae_path = "../models/vae/minimax_h3_video_vae_fp16.safetensors"
+    audio_vae_path = "../models/vae/minimax_h3_audio_vae_fp32.safetensors"
+
+    output_path = "pi-h3-output.avi"
+
+    prompt = "A red fox trots through a snowy pine forest. Snow crunches underfoot and birds chirp in the distance."
+    seed = 42
+    width = 864
+    height = 480
+    frames = 56
+    fps = 24
+}
+
+fn main() {
+    base_model = load_dit(model_path, family = "minimax_h3", params_backend = "cpu", weights_override = adapter_path)
+    model = apply_lora(base_model, load_lora(adapter_path), weight = 1.0)
+    text = load_text_encoder(text_path, family = "minimax_h3", params_backend = "cpu")
+    vae = load_vae(vae_path, family = "minimax_h3", params_backend = "cpu")
+    audio_vae = load_audio_vae(audio_vae_path, family = "minimax_h3", params_backend = "cpu")
+
+    video_shape = latent_shape(vae, width = width, height = height, frames = frames)
+    audio_shape = audio_latent_shape(audio_vae, frames = frames, fps = fps)
+    audio_count = math::product(audio_shape)
+    plane_size = video_shape[0] * video_shape[1] * video_shape[2]
+    tail_channels = math::ceil_div(audio_count, plane_size)
+    tail_shape = [video_shape[0], video_shape[1], video_shape[2], tail_channels, 1]
+
+    condition = encode_prompt(text, prompt, width = width, height = height)
+    predict = predictor(model, condition, audio_length = audio_shape[0], video_sigma_shift = 12, audio_sigma_shift = 3)
+    # Raw sigmas run from 0.96 to 0.96 * 0.6 / (3 + 0.6) before the H3 video shift.
+    raw = tensor::vector([0.96, 0.6933333333, 0.4266666667, 0.16, 0.0], dtype = "f32")
+    sigmas = tensor::div(tensor::mul(raw, 12), tensor::affine(raw, scale = 11, offset = 1))
+    rng = make_rng("cpu", seed = seed)
+    video_noise = tensor::randn_like(tensor::zeros(video_shape), rng = rng)
+    audio_noise = tensor::randn_like(tensor::zeros([audio_count]), rng = rng)
+    # The sampler carries audio latents scaled by video sigma / audio sigma.
+    audio_carrier = tensor::mul(audio_noise, 4 - 3 * sigmas[0])
+    audio_tail = tensor::pad(audio_carrier, [0, plane_size * tail_channels - audio_count])
+    start = tensor::concat([video_noise, tensor::reshape(audio_tail, tail_shape)], axis = 3)
+    latent = sample(start, sigmas, predict = predict, method = "euler", rng = rng)
+
+    video_latent = latent[:, :, :video_shape[2], :video_shape[3]]
+    output_frames = vae_decode(vae, dit_to_vae_latents(vae, video_latent))
+    tail = latent[:, :, :, video_shape[3]:]
+    sound = tensor::reshape(tail, [tensor::numel(tail)])
+    sound_latent = tensor::div(tensor::reshape(sound[:audio_count], audio_shape), 4)
+    audio = audio_vae_decode(audio_vae, sound_latent)
+    video::save(output_path, {frames = output_frames, fps_num = fps, fps_den = 1}, audio = audio, trim_audio = true)
+    return {video = {frames = output_frames, fps_num = fps, fps_den = 1}, latent = latent, audio = audio}
+}
diff --git a/docs/models/minimax_h3.md b/docs/models/minimax_h3.md
index 3d15cae..2c410ec 100644
--- a/docs/models/minimax_h3.md
+++ b/docs/models/minimax_h3.md
@@ -129,6 +129,7 @@ Select optional components when required by your checkpoint or task.
 | Example | Description |
 | --- | --- |
 | [Text to audio/video](../dgl/minimax_h3/minimax-h3-text-to-av.dgl) | Generate video and its soundtrack together. |
+| [pi-H3 text to audio/video](../dgl/minimax_h3/pi-h3-text-to-av.dgl) | Generate video and its soundtrack in four Euler steps with the native H3 VAEs. |
 | [First/last-frame conditioning](../dgl/minimax_h3/minimax-h3-first-last-frame.dgl) | Guide the video with endpoint images. |
 | [Reference to audio/video](../dgl/minimax_h3/minimax-h3-reference-to-av.dgl) | Use image, video and audio references. |
 | [Interpolated latent hires](../dgl/minimax_h3/minimax-h3-latent-hires.dgl) | Resize the draft latent, then run a second sampling pass. |
@@ -157,6 +158,17 @@ to validate syntax and types without loading weights. See the
 [shared run instructions](../dgl/README.md#run-an-example) for build paths
 and the server's file-access rules.

+#### pi-H3 four-step generation
+
+Use a pruned MiniMax-H3 FL2VA transformer such as `minimax_h3_fl2va_pruned-Q4_K_M.gguf`.
+Save the [four-step pi-H3 adapter](https://huggingface.co/Lakonik/pi-H3/tree/main/pi_h3_4step_adapter)
+as `pi_h3_4step_adapter.safetensors` under `models/loras/minimax/` or set
+`adapter_path` in the script. Keep the MiniMax-H3 text encoder and both VAEs.
+The script applies the adapter's full-weight replacements and its LoRA at
+strength `1.0`. It uses the four-step pi-H3 schedule with video shift `12`,
+audio shift `3`, maximum raw sigma `0.96`, and final step size scale `0.6`.
+The adapter with `dwd` in its name requires a separate decoder head.
+
 #### Audio/video continuation

 The continuation example saves the finished video as `continuation-joined.avi`
diff --git a/src/dgl/bindings/component_loader.cpp b/src/dgl/bindings/component_loader.cpp
index 4796854..ca7fceb 100644
--- a/src/dgl/bindings/component_loader.cpp
+++ b/src/dgl/bindings/component_loader.cpp
@@ -105,7 +105,9 @@ namespace sd::dgl {
             read_model_params(args),
         };
         PreparedResource prepared;
-        prepared.key  = normalized_model_params(params.model, prepared);
+        prepared.key                  = normalized_model_params(params.model, prepared);
+        params.model.weights_override = file_key(get_string(args, "weights_override"), prepared.revision);
+        prepared.key["weights_override"] = params.model.weights_override;
         prepared.load = [params = std::move(params)](ResourceLoadRequest& request) mutable {
             const auto path = params.model.path;
             auto model      = load_model<models::DiT>(request, std::move(params), path);
diff --git a/src/dgl/bindings/registration.cpp b/src/dgl/bindings/registration.cpp
index 6624e99..52e2430 100644
--- a/src/dgl/bindings/registration.cpp
+++ b/src/dgl/bindings/registration.cpp
@@ -424,7 +424,9 @@ namespace sd::dgl {
         const auto family_from = model_path("family_from", false);
         register_lora_operations(registry);

-        registry["load_dit"] = component_loader<models::DiffusionModel>(SDBackendModule::DIFFUSION, family, load_dit);
+        auto dit_loader = component_loader<models::DiffusionModel>(SDBackendModule::DIFFUSION, family, load_dit);
+        dit_loader.arguments.push_back(model_path("weights_override", false));
+        registry["load_dit"] = std::move(dit_loader);
         registry.alias("load_unet", "load_dit");

         auto tokenizer                = optional("tokenizer", Kind::String, "");
diff --git a/src/dgl/models/component_sources.cpp b/src/dgl/models/component_sources.cpp
index bcc3466..e576556 100644
--- a/src/dgl/models/component_sources.cpp
+++ b/src/dgl/models/component_sources.cpp
@@ -234,6 +234,10 @@ namespace sd::dgl::models {
             LOG_ERROR("cannot identify component family for '%s'; specify family", path.c_str());
             return false;
         }
+        if (!params.weights_override.empty() &&
+            !loader.add_file(params.weights_override, "model.diffusion_model.", nullptr, false, ModelLoader::FileScope::Overlay)) {
+            return false;
+        }
         loader.set_wtype_override(sd_type_to_ggml_type(params.wtype), params.tensor_type_rules.c_str());
         return true;
     }
diff --git a/src/dgl/models/model_load_params.h b/src/dgl/models/model_load_params.h
index 1ad7ca0..9e9255d 100644
--- a/src/dgl/models/model_load_params.h
+++ b/src/dgl/models/model_load_params.h
@@ -14,6 +14,7 @@ namespace sd::dgl::models {

     struct ModelLoadParams {
         std::string path;
+        std::string weights_override;
         SDVersion family = VERSION_COUNT;
         std::string family_from;
         std::string backend;
diff --git a/src/model_loader.h b/src/model_loader.h
index d644977..86113be 100644
--- a/src/model_loader.h
+++ b/src/model_loader.h
@@ -43,6 +43,7 @@ public:
     using FileId       = uint64_t;
     using FileVersions = std::map<FileId, uint64_t>;
     enum class FileScope { Catalog,
+                           Overlay,
                            Isolated };

     struct FileStamp {
diff --git a/src/model_loader_files.cpp b/src/model_loader_files.cpp
index 30bc4d4..e2bc14c 100644
--- a/src/model_loader_files.cpp
+++ b/src/model_loader_files.cpp
@@ -75,7 +75,7 @@ void ModelLoader::rebuild_catalog() {
     tensor_storage_map.clear();
     metadata_.clear();
     for (const auto& file : files_) {
-        if (file.scope == FileScope::Isolated)
+        if (file.scope != FileScope::Catalog)
             continue;
         if (!names_converted_ || version_ == VERSION_COUNT)
             for (auto& entry : prefixed_tensors(file.tensors, file.prefix)) {
@@ -90,7 +90,7 @@ void ModelLoader::rebuild_catalog() {
         const SDVersion version = version_ == VERSION_COUNT ? get_sd_version() : version_;
         tensor_storage_map.clear();
         for (const auto& file : files_) {
-            if (file.scope == FileScope::Isolated)
+            if (file.scope != FileScope::Catalog)
                 continue;
             for (auto& entry : prefixed_tensors(file.tensors, file.prefix)) {
                 TensorStorage tensor            = std::move(entry.second);
@@ -98,6 +98,50 @@ void ModelLoader::rebuild_catalog() {
                 tensor_storage_map[tensor.name] = std::move(tensor);
             }
         }
+        for (const auto& file : files_) {
+            if (file.scope != FileScope::Overlay)
+                continue;
+            std::map<std::string, const TensorStorage*> replacements;
+            for (const auto& [name, tensor] : file.tensors) {
+                auto normalized = convert_tensor_name(name, version);
+                if (!tensor_storage_map.count(normalized) && !starts_with(normalized, file.prefix))
+                    normalized = convert_tensor_name(file.prefix + name, version);
+                replacements.insert_or_assign(std::move(normalized), &tensor);
+            }
+            bool matched = false;
+            for (const auto& [name, tensor] : replacements) {
+                auto target = tensor_storage_map.find(name);
+                if (target == tensor_storage_map.end())
+                    continue;
+                const auto& base = target->second;
+                if (tensor->logical_ne0() != base.logical_ne0() ||
+                    !std::equal(tensor->ne + 1, tensor->ne + SD_MAX_DIMS, base.ne + 1)) {
+                    throw std::runtime_error("weight override '" + file.path + "' has an incompatible shape for '" + name + "'");
+                }
+                target->second      = *tensor;
+                target->second.name = name;
+                matched             = true;
+                if (!ends_with(name, ".weight"))
+                    continue;
+                if (tensor->is_int8_tensorwise && !replacements.count(name + "_scale")) {
+                    throw std::runtime_error("weight override '" + file.path + "' is missing the INT8 scale for '" + name + "'");
+                }
+                // Quantization companions describe the replacement weight's stored values.
+                for (const char* suffix : {"_scale", "_codebook", "_s_channel", "_s_rel"}) {
+                    const auto companion_name = name + suffix;
+                    auto companion            = replacements.find(companion_name);
+                    if (companion == replacements.end()) {
+                        tensor_storage_map.erase(companion_name);
+                    } else {
+                        auto& storage = tensor_storage_map[companion_name];
+                        storage       = *companion->second;
+                        storage.name  = companion_name;
+                    }
+                }
+            }
+            if (!matched)
+                throw std::runtime_error("weight override '" + file.path + "' has no matching model weights");
+        }
     }
     std::set<size_t> used_files;
     for (const auto& file : files_) {
@@ -219,7 +263,7 @@ bool ModelLoader::add_file_impl(const std::string& path, const std::string& pref
     } else {
         *existing = std::move(record);
     }
-    rebuild_catalog();
+    invalidate_file_data();
     return true;
 }

@@ -238,6 +282,7 @@ bool ModelLoader::add_file(const std::string& path, const std::string& prefix, F
     if (!candidate.add_file_impl(path, prefix, &added_id, force, scope)) {
         return false;
     }
+    candidate.rebuild_catalog();
     *this = std::move(candidate);
     if (id != nullptr) {
         *id = added_id;
@@ -312,6 +357,7 @@ bool ModelLoader::refresh_files(bool include_isolated) {
             return false;
         }
     }
+    candidate.rebuild_catalog();
     *this = std::move(candidate);
     return true;
 }
diff --git a/src/name_conversion.cpp b/src/name_conversion.cpp
index 6da7aea..1dc095d 100644
--- a/src/name_conversion.cpp
+++ b/src/name_conversion.cpp
@@ -1116,6 +1116,10 @@ std::string convert_diffusers_dit_to_original_minimax_h3(std::string name) {
     static const std::vector<std::pair<std::string, std::string>> prefix_map = {
         {"transformer_blocks.", "blocks."},
         {"token_refiner.refiner_blocks.", "token_refiner.blocks."},
+        {"norm_out.norm.", "final_layer.norm."},
+        {"norm_out.linear.", "final_layer.adaln_proj.linear."},
+        {"proj_out.", "final_layer.video_out."},
+        {"audio_proj_out.", "final_layer.audio_out."},
     };
     static const std::vector<std::pair<std::string, std::string>> name_map = {
         {".attn.to_q.weight", ".attn.qkv_proj.weight"},