minimax_music3: performance pack — native rope/SwiGLU lowering + opt-in CFG reuse, chunk hop, batched ensemble takes, q4_k depth - #321
Open
iamwavecut wants to merge 13 commits into
Conversation
…-cache eviction on release, pipeline buffer reuse
…priority CUDA stream
…s probe (MM3_DC_VERIFY)
…iew-aliasing corruption) + b1 determinism diagnostics (MM3_DC_B1_*), MMQ fixup-buffer zeroing
…U, overlap auto-off on long requests, delta-cache interval=2 default
…; K=1 byte-equivalence force probe; per-stage AR timings
…e philox top-k sampler (MM3_DEPTH_GPU_SAMPLE) and full GPU frame with device residual-ids and hidden accumulation (MM3_DEPTH_GPU_FRAME); exports the ggml CUDA backend stream
…nd: -24% depth, ~-6% wall; q8_0 stays available)
…ix at batch 2, batched decode KV export/replication, shared flow seed under the lock
…tic algo cache, static workspace, GemmEx fallback). Measured neutral vs MMQ q4 on the DiT shapes — kept as an option; also links cublasLt
… seams audible; kept for hybrid experiments)
…th consistently rederived crops/carry; defaults hop=150 + delta-cache interval=3 (flow -40%, 60s solo 74.1s, K=6 ensemble 46.9s/song)
flow_uncond_interval back to 1 (exact reference trajectory), flow_chunk_hop_frames back to the model config (100), depth decoder back to q8_0. Out of the box this branch changes only the flow lowering (native NEOX rope + fused swapped SwiGLU; spectrally equivalent and faster, MM3_LEGACY_ROPE/MM3_LEGACY_GLU restore the previous path) — everything else is opt-in via request/session options.
Owner
|
@iamwavecut Thanks for the PR. One issue I recently found is that some optimizations were rejected by me because, on my setup, they only showed noise-level performance changes, while on different hardware the gains could be significant. So I may miss many useful optimizations. RTX 5090:
I’m not a CI expert, so I’m not sure whether the new cuBLASLt dependency could break Docker images or prebuilts. I need a bit more time to investigate. |
Owner
|
Also I think the changes to external/ggml/src/ggml-cuda/mmq.cuh was merged already. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A performance pack for MiniMax Music 3 (improving the existing family per CONTRIBUTING, building on #241/#243/#271 by @JoeMattie). 13 focused commits; out of the box only the flow lowering changes — everything else is opt-in and the defaults reproduce the current upstream trajectory.
Default-on (changes flow internals, spectrally equivalent):
ggml_rope_extNEOX lowering instead of the slice/concat rope chains, both flow batches. Also works around a gallocr view-aliasing hazard we bisected: a freshly allocated batch-1 flow graph corrupts its first ~4 invocations, bitwise-reproducibly (batch 2 is saved by an explicitggml_repeat). Repro/diagnostics ship asMM3_DC_B1_*envs;MM3_LEGACY_ROPE=1restores the old lowering.ggml_swiglu_swappedfor the flow FFN (our layout is[states|gate]— plainggml_swiglusilences the wrong half, mel 25 dB off; the swapped variant is exact).MM3_LEGACY_GLU=1restores.Opt-in (upstream defaults preserved):
flow_uncond_interval=N— reuse the CFG guidance delta between steps. N=2: flow −25-30%, mel-L1 ~0.3 dB vs exact; N=1 (default) = exact trajectory.flow_chunk_hop_frames— the stock chunking (200-frame chunks, hop 100) denoises every second twice. hop=150: flow −35%; crops and the carry window are rederived consistently (hop=100 reproduces the stock geometry byte-for-byte).ensemble_takes=K(1..16) — decode K takes of one prompt in a single batched AR pass. The LM+depth stages are weight-bandwidth-bound, so K takes cost far less than K runs; flow/vocoder run per take, outputs land astake_NNvia--out-dir. Adds an additiveexport_batched_decode_state()to the Qwen decode runtime (no behavior change for existing callers).ensemble_prefix_frames=N— intro-lock: the first N frames decode once as a shared master trajectory, then takes fork (take_01 continues the master exactly). "One intro, K continuations."q4_k(upstream file): −24% depth-stage time, panel-clean; option only, default staysq8_0.Numbers (fresh run on a clean A40 SECURE pod, driver 580.159.04, this branch, CUDA)
60 s track, 30 flow steps, one seed, single run each (fresh clone of this branch, canonical build script):
flow_uncond_interval=2flow_chunk_hop_frames=150ensemble_takes=6, combo options20 s sanity pair: native lowering 33.9 s vs
MM3_LEGACY_ROPE/GLU36.2 s (−6% from the lowering itself).From the longer campaign behind this: the ensemble K-curve on a 60 s track runs 89.3/72.4/67.2/64.4/63.7 s per AR pass for K=1/3/6/10/16 (LM+depth are weight-bandwidth-bound, so extra takes are nearly free until flow dominates). Every recipe step was gated on a spectral panel (chroma/harmonicity/dynamics/onsets staying in the reference band) plus human listening.
Build / run
Baseline run (upstream defaults, only the flow lowering differs):
Full opt-in recipe (what
combo60in the table runs):Ensemble: add
--request-option ensemble_takes=6 --out-dir out/(takes land astake_NN.wav).Validation
minimax_music3_graph_release_policy_test,minimax_music3_lm_head_test,minimax_music3_pipeline_buffers_test: pass.Spectrograms from the fresh run (branch
evidence/mm3-perf-20260827holds these + the raw table):defaults (95.9 s) vs full opt-in recipe (68.3 s), same seed:
legacy lowering vs native lowering (20 s, same seed — diverged takes, same character):
Known limitations
MM3_LEGACY_ROPE/GLUkeep the exact old path if you need it.ensemble_takespeak VRAM grows ~0.7 GB per take at 60 s (K=6 ≈ 12.4 GB total on A40).