refactor: replace manual gated activations with native ggml GLU (#2250)

This commit is contained in:
leejet authored and GitHub committed 2026-10-30 01:32:46 +08:00
1 parent 37bc88b5e9
commit e239e4b0fd
13 files changed
+33 -53

No files matched your search

+2 -2
View File
@@ -134,8 +134,8 @@ namespace MiniMaxH3 {
auto w1 = std::dynamic_pointer_cast<Linear>(blocks["w1"]);
auto w2 = std::dynamic_pointer_cast<Linear>(blocks["w2"]);
x = norm->forward(ctx, x);
auto gate = ggml_ext_gelu(ctx->ggml_ctx, w0->forward(ctx, x), true);
return w2->forward(ctx, ggml_mul(ctx->ggml_ctx, gate, w1->forward(ctx, x)));
auto gate = w0->forward(ctx, x);
return w2->forward(ctx, ggml_geglu_split(ctx->ggml_ctx, gate, w1->forward(ctx, x)));
}
};
+2 -5
View File
@@ -316,11 +316,8 @@ namespace MiniMaxH3VAE {
ggml_tensor* forward(GGMLRunnerContext* ctx, ggml_tensor* x) {
auto w1 = std::dynamic_pointer_cast<Linear>(blocks["w1"]);
auto w2 = std::dynamic_pointer_cast<Linear>(blocks["w2"]);
auto gate = ggml_ext_chunk(ctx->ggml_ctx, w1->forward(ctx, x), 2, 0);
return w2->forward(ctx,
ggml_mul(ctx->ggml_ctx,
ggml_silu(ctx->ggml_ctx, gate[0]),
gate[1]));
auto gate = ggml_swiglu(ctx->ggml_ctx, w1->forward(ctx, x));
return w2->forward(ctx, gate);
}
};