Files
ba3c05f71d model: add Muse Spark Open (text, vision and audio) (#30616)
* model: add Muse Spark Open (text, vision and audio)

Muse Spark Open is a latent space MoE: the residual stream stays at 8192
while the 256 experts live in 4096, with a projection down and up around
them, top-8 sigmoid routing with a correction bias. Attention interleaves
three sliding layers at a 2048 window with rope for one global layer
without rope, with a sigmoid output gate and a weightless QK-norm.
Residuals are norm preserving, their gate is folded at conversion time.

Vision reuses the Muse Glimmer tower. Audio is a causal convolutional
pyramid with no attention and no spectrogram, four stages folding 16, 6,
5 and 4 samples into the channel dim, one embedding per 80 ms of 24 kHz.

The quantizer keeps the latent projections and the attention gate at
Q8_0, a little over 1% of the weights, since the whole residual stream
passes through them and the low-bit types turned the output into a
repeating loop. The model saver writes the post norm epsilon, and the
arch is registered in test-llama-archs.

Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>

* Muse Spark: drop the redundant forward expand

* Muse Spark: drop the redundant forward expand and tighten the comments

* Update src/llama-quant.cpp

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co>

* Update src/llama-graph.cpp

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co>

* Update conversion/muse_spark.py

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co>

* Update conversion/muse_spark.py

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co>

* Update conversion/muse_spark.py

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co>

* Update conversion/muse_spark.py

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co>

---------

Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co>
2026-10-15 23:27:12 +02:00

67 lines
2.7 KiB
C++

#include "models.h"
// Muse Spark audio tower: a causal conv pyramid over the raw waveform, no attention and no spectrogram
// each stage folds `patch` samples into the channel dim, projects, then runs `depth` residual blocks (depthwise causal conv, RMS norm, GELU MLP)
ggml_cgraph * clip_graph_muse_spark_audio::build() {
const int kernel = hparams.audio_conv_kernel_size;
const int n_stage = (int) hparams.audio_patch_sizes.size();
// shape [1, n_samples], so the first stage folds the same way as the others
ggml_tensor * cur = build_inp_raw(1);
cur = ggml_reshape_2d(ctx0, cur, 1, img.nx());
cb(cur, "inp_raw", -1);
int bid = 0;
for (int stage = 0; stage < n_stage; ++stage) {
const int patch = hparams.audio_patch_sizes[stage];
const auto & pe = model.a_patches[stage];
// fold `patch` positions into the channel dim
cur = ggml_reshape_2d(ctx0, cur, cur->ne[0] * patch, cur->ne[1] / patch);
cb(cur, "patch_folded", stage);
GGML_ASSERT(pe.proj_w->ne[1] == hparams.audio_hidden_sizes[stage]);
cur = ggml_mul_mat(ctx0, pe.proj_w, cur);
cur = ggml_add(ctx0, cur, pe.proj_b);
cur = build_norm(cur, pe.norm_w, nullptr, NORM_TYPE_RMS, hparams.eps, stage);
cb(cur, "patch_embd", stage);
for (int i = 0; i < hparams.audio_depths[stage]; ++i, ++bid) {
const auto & layer = model.layers[bid];
ggml_tensor * residual = cur;
// depthwise conv over time, pad on the left so it is causal
ggml_tensor * conv = ggml_cont(ctx0, ggml_transpose(ctx0, cur));
conv = ggml_pad_ext(ctx0, conv, kernel - 1, 0, 0, 0, 0, 0, 0, 0);
conv = ggml_conv_1d_dw(ctx0, layer.conv_w, conv, 1, 0, 1);
conv = ggml_cont(ctx0, ggml_transpose(ctx0, conv));
conv = ggml_add(ctx0, conv, layer.conv_b);
cb(conv, "conv", bid);
cur = build_norm(conv, layer.conv_norm_w, nullptr, NORM_TYPE_RMS, hparams.eps, bid);
cur = build_ffn(cur,
layer.ff_up_w, layer.ff_up_b,
nullptr, nullptr,
layer.ff_down_w, layer.ff_down_b,
FFN_GELU_ERF, bid);
cb(cur, "ffn_out", bid);
cur = ggml_add(ctx0, cur, residual);
cb(cur, "block_out", bid);
}
}
cur = build_norm(cur, model.pre_ln_w, nullptr, NORM_TYPE_RMS, hparams.eps, -1);
cb(cur, "enc_norm", -1);
// straight into the text hidden size, no adapter
cur = ggml_mul_mat(ctx0, model.mm_fc_w, cur);
cur = ggml_add(ctx0, cur, model.mm_fc_b);
cur = build_norm(cur, model.post_ln_w, nullptr, NORM_TYPE_RMS, hparams.eps, -1);
cb(cur, "projected", -1);
ggml_build_forward_expand(gf, cur);
return gf;
}