Commit 4449fcb for stable-diffusion.cpp
commit 4449fcb1e1fa183e8ea9aef0704ee27df4dd220a
Author: leejet <leejet714@gmail.com>
Date: Sun Dec 6 12:39:35 2026 +0800
fix: reduce MiniMax H3 segmented workspace usage (#2537)
diff --git a/src/model/diffusion/minimax_h3.hpp b/src/model/diffusion/minimax_h3.hpp
index bd26d82..b0b5bd7 100644
--- a/src/model/diffusion/minimax_h3.hpp
+++ b/src/model/diffusion/minimax_h3.hpp
@@ -838,6 +838,7 @@ namespace MiniMaxH3 {
auto pe = ggml_concat(ctx->ggml_ctx, c, ns, 0);
pe = ggml_concat(ctx->ggml_ctx, pe, s, 0);
pe = ggml_concat(ctx->ggml_ctx, pe, c, 0);
+ sd::ggml_graph_cut::mark_graph_cut(pe, "minimax_h3.prelude", "rope");
return ggml_reshape_4d(ctx->ggml_ctx, pe, 2, 2, angles->ne[0], angles->ne[1]);
}
@@ -947,6 +948,8 @@ namespace MiniMaxH3 {
}
}
GGML_ASSERT(h != nullptr);
+ // Keep input packing out of the first transformer block's workspace.
+ sd::ggml_graph_cut::mark_graph_cut(h, "minimax_h3.prelude", "hidden_states");
auto t_emb = time_embedding(ctx,
timestep_features,
@@ -954,7 +957,8 @@ namespace MiniMaxH3 {
curve_indices,
curve_upper_indices,
curve_fractions);
- auto pe = build_rope(ctx, position_ids);
+ sd::ggml_graph_cut::mark_graph_cut(t_emb, "minimax_h3.prelude", "t_emb");
+ auto pe = build_rope(ctx, position_ids);
for (int64_t i = 0; i < config.num_layers; ++i) {
auto block = std::dynamic_pointer_cast<TransformerBlock>(blocks["blocks." + std::to_string(i)]);
h = block->forward(ctx, h, t_emb, segments, pe);