forked from Blizaine/Maestro
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add local MiniMax Music3 generation #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
60b946f
fix: compare local code health with PR base
IAnMove 249c578
feat: add local MiniMax Music3 generation
IAnMove 97033e7
fix: keep Music3 captions, shards, duration and local generate ready
IAnMove 9328718
fix: pass Music3 writer target and clamp Wizard song duration
IAnMove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "model": { | ||
| "name": "MiniMax-Music3", | ||
| "architecture": "minimax_music3", | ||
| "description": "MiniMax-Music3 creates complete stereo songs from lyrics and a detailed music caption, with expressive vocals, evolving arrangements, and long-form structure up to five minutes. The official converted components require about 28 GB of storage and are streamed through HocusPocus's single-GPU memory manager.", | ||
| "selector_help": "Best for full songs with detailed lyric sections and arrangement control. First use downloads about 28 GB. 24 GB VRAM is the practical target with offload; lower VRAM is possible only with aggressive CPU offload and much slower generation. Model weights use the MiniMax-Music3 Community License.", | ||
| "URLs": [ | ||
| "https://huggingface.co/MiniMaxAI/MiniMax-Music3/resolve/bd348f9c49ea3c1b39f33ace3436f8fad435f24e/modular_model_index.json" | ||
| ], | ||
| "source_repo": "https://huggingface.co/MiniMaxAI/MiniMax-Music3", | ||
| "license_name": "MiniMax-Music3 Community License", | ||
| "license_url": "https://huggingface.co/MiniMaxAI/MiniMax-Music3/blob/main/LICENSE", | ||
| "resource_requirements": { | ||
| "storage_gb": 28, | ||
| "vram_gb": 24, | ||
| "platform": "NVIDIA CUDA", | ||
| "backend": "Diffusers modular pipeline", | ||
| "tier": "stable", | ||
| "note": "Con CPU offload puede caber en menos VRAM, pero la generación será mucho más lenta." | ||
| }, | ||
| "model_size_gb": 28, | ||
| "required_model_assets": [ | ||
| "minimax_music3/LICENSE", | ||
| "minimax_music3/tokenizer/tokenizer.json", | ||
| "minimax_music3/language_model/model-00001-of-00004.safetensors", | ||
| "minimax_music3/language_model/model-00002-of-00004.safetensors", | ||
| "minimax_music3/language_model/model-00003-of-00004.safetensors", | ||
| "minimax_music3/language_model/model-00004-of-00004.safetensors", | ||
| "minimax_music3/rvq_depth_decoder/diffusion_pytorch_model.safetensors", | ||
| "minimax_music3/condition_encoder/diffusion_pytorch_model.safetensors", | ||
| "minimax_music3/transformer/diffusion_pytorch_model-00001-of-00002.safetensors", | ||
| "minimax_music3/transformer/diffusion_pytorch_model-00002-of-00002.safetensors", | ||
| "minimax_music3/vocoder/diffusion_pytorch_model.safetensors" | ||
| ] | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| }, | ||
| "prompt": "[Verse]\nMorning light filters through the pines\nEvery quiet road is yours and mine\n[Chorus]\nSoftly the whole world starts to breathe\nStay for one more song with me\n[Outro]", | ||
| "alt_prompt": "### Global Metadata\nWarm acoustic pop at 96 BPM in C major; intimate and hopeful, growing into a wide final chorus; polished natural production.\n\n### Vocal Details\nSoft, close female lead with breathy verses, clear diction, and light stacked harmonies in the chorus.\n\n### Arrangement\nFingerpicked acoustic guitar and soft piano open the song. Brushed drums and upright bass enter in the chorus; strings bloom gently before a sparse outro.", | ||
| "duration_seconds": 120, | ||
| "num_inference_steps": 30, | ||
| "guidance_scale": 1.7 | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| heartmula_handler, | ||
| index_tts2_handler, | ||
| kugelaudio_handler, | ||
| minimax_music3_handler, | ||
| qwen3_handler, | ||
| yue_handler, | ||
| ) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # MiniMax-Music3 notices | ||
|
|
||
| The neural-network class definitions in this directory are adapted from the | ||
| MiniMax-Music3 integration contributed by the MiniMax and Hugging Face teams | ||
| to Diffusers and retain their Apache License 2.0 headers. | ||
|
|
||
| MiniMax-Music3 model weights are not distributed in the HocusPocus repository. | ||
| They are downloaded on first use from | ||
| <https://huggingface.co/MiniMaxAI/MiniMax-Music3> and are governed by the | ||
| [MiniMax-Music3 Community License](https://huggingface.co/MiniMaxAI/MiniMax-Music3/blob/main/LICENSE) | ||
| and its Acceptable Use Policy. HocusPocus downloads a copy of that license next | ||
| to the model components. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """Native MiniMax-Music3 components used by HocusPocus. | ||
|
|
||
| The neural-network definitions are adapted from the Apache-2.0 Diffusers | ||
| integration contributed by the MiniMax and Hugging Face teams. Model weights | ||
| remain governed by MiniMax's Music3 Community License and are downloaded from | ||
| the official MiniMaxAI Hugging Face repository on first use. | ||
| """ | ||
|
|
||
| from .condition_encoder import MiniMaxMusic3ConditionEncoder | ||
| from .pipeline import MiniMaxMusic3Pipeline | ||
| from .rvq_depth_decoder import MiniMaxMusic3RVQDepthDecoder | ||
| from .transformer import MiniMaxMusic3Transformer1DModel | ||
| from .vocoder import MiniMaxMusic3Vocoder | ||
|
|
||
| __all__ = [ | ||
| "MiniMaxMusic3ConditionEncoder", | ||
| "MiniMaxMusic3Pipeline", | ||
| "MiniMaxMusic3RVQDepthDecoder", | ||
| "MiniMaxMusic3Transformer1DModel", | ||
| "MiniMaxMusic3Vocoder", | ||
| ] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Copyright 2026 The MiniMax Team and The HuggingFace Team. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import torch | ||
| import torch.nn as nn | ||
| import torch.nn.functional as F | ||
|
|
||
| from diffusers.configuration_utils import ConfigMixin, register_to_config | ||
| from diffusers.models.modeling_utils import ModelMixin | ||
|
|
||
|
|
||
| class MiniMaxMusic3ConditionEncoder(ModelMixin, ConfigMixin): | ||
| r""" | ||
| Projects the per-frame hidden states of the autoregressive stage onto the Flow-VAE latent timeline. | ||
|
|
||
| Each generated frame carries `num_condition_layers` hidden states of size `condition_hidden_dim` (one from the | ||
| language model and one per residual codebook step). They are mixed with learned softmax weights, projected, and | ||
| resampled from the language-model frame rate to the latent frame rate with nearest-neighbor interpolation. | ||
| """ | ||
|
|
||
| @register_to_config | ||
| def __init__( | ||
| self, | ||
| condition_hidden_dim: int = 4096, | ||
| num_condition_layers: int = 8, | ||
| out_dim: int = 2048, | ||
| input_sampling_rate: int = 24000, | ||
| input_hop_length: int = 960, | ||
| output_sampling_rate: int = 44100, | ||
| output_hop_length: int = 512, | ||
| ): | ||
| super().__init__() | ||
| self.layer_weight_logits = nn.Parameter(torch.zeros(num_condition_layers)) | ||
| self.layer_scale = nn.Parameter(torch.ones(1)) | ||
| self.proj = nn.Conv1d(condition_hidden_dim, out_dim, kernel_size=3, padding=1) | ||
|
|
||
| def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: | ||
| r""" | ||
| Args: | ||
| hidden_states (`torch.Tensor` of shape `(batch, frames, num_condition_layers * condition_hidden_dim)`): | ||
| Concatenated per-frame hidden states from the autoregressive stage. | ||
|
|
||
| Returns: | ||
| `torch.Tensor` of shape `(batch, latent_length, out_dim)`: the latent-aligned conditioning sequence. | ||
| """ | ||
| batch_size, num_frames, _ = hidden_states.shape | ||
| num_layers = self.config.num_condition_layers | ||
| hidden_states = hidden_states.transpose(1, 2) | ||
| hidden_states = hidden_states.reshape(batch_size, num_layers, self.config.condition_hidden_dim, num_frames) | ||
| layer_weights = torch.softmax(self.layer_weight_logits, dim=0).to(hidden_states.dtype) | ||
| hidden_states = torch.einsum("blht,l->bht", hidden_states, layer_weights) | ||
| hidden_states = self.layer_scale.to(hidden_states.dtype) * hidden_states | ||
| hidden_states = self.proj(hidden_states) | ||
| latent_length = max( | ||
| 1, | ||
| int( | ||
| num_frames | ||
| * self.config.output_sampling_rate | ||
| / self.config.input_sampling_rate | ||
| * self.config.input_hop_length | ||
| / self.config.output_hop_length | ||
| ), | ||
| ) | ||
| hidden_states = F.interpolate(hidden_states, size=latent_length, mode="nearest") | ||
| return hidden_states.transpose(1, 2) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.