vllm_omni.model_executor.models.minimax_music3.dit ¶
Condition encoder and flow-matching transformer for MiniMax Music 3.
Stage 1 turns the AR stage's conditioning frames into a DAC latent in two steps. The condition encoder collapses the eight 4096-wide layer slices of a frame into one 2048-wide vector and stretches the result from the AR frame grid onto the vocoder's latent grid. The transformer is then solved as a flow-matching velocity field: a fixed-step Euler integrator walks Gaussian noise to the latent the vocoder expects, under classifier-free guidance.
Module names mirror the checkpoint's condition_encoder/ and transformer/ component folders key for key, with one deliberate exception: the per-block to_q/to_k/to_v projections are fused into a single to_qkv so each block runs one GEMM instead of three. :func:remap_transformer_state performs that fusion, and is the only place the checkpoint's layout is reinterpreted.
Attention uses the project's diffusion attention layer when its selected backend supports the runtime dtype. This LLM_GENERATION stage does not set a diffusion backend and therefore gets the platform default. CUDA commonly resolves that default to FlashAttention, cuDNN, or FlashInfer, so the model routes its native float32 decode through SDPA while retaining the selected backend for supported lower-precision inputs. An explicitly selected backend remains authoritative.
Attention ¶
Bases: Module
Bidirectional self-attention with partial rotary position embeddings.
Q, K and V are kept in [B, S, H, D], which is the layout the diffusion attention backends consume and return.
FourierFeatures ¶
MiniMaxMusic3ConditionEncoder ¶
Bases: Module
Collapse an AR frame's eight layer slices and resample onto mel time.
layer_weight_logits instance-attribute ¶
layer_weight_logits = nn.Parameter(
torch.zeros(NUM_CODEBOOKS)
)
proj instance-attribute ¶
proj = nn.Conv1d(
BACKBONE_HIDDEN_SIZE,
_CONDITION_DIM,
kernel_size=3,
padding=1,
)
aligned_condition ¶
Project AR hidden states and resample them onto the latent grid.
aligned_mel_length ¶
Return how many vocoder latent frames frames AR frames cover.
AR frames sit on a 24 kHz / 960-hop grid (25 fps) and the vocoder latent on a 44.1 kHz / 512-hop grid (about 86 fps), so one AR frame is roughly 3.445 latent frames. The result is truncated, never rounded.
condition ¶
Project [B, T, 32768] AR frames to [B, 2048, T].
Raises:
| Type | Description |
|---|---|
ValueError | If the conditioning is not |
MiniMaxMusic3FlowMatchingDiT ¶
Bases: Module
Condition encoder plus velocity field, with the Euler solver on top.
forward ¶
forward(
align: Tensor,
*,
generator: Generator,
initial_latent: Tensor | None = None,
initial_condition: Tensor | None = None,
num_steps: int = DEFAULT_DIT_STEPS,
cfg_scale: float = DEFAULT_DIT_CFG_SCALE,
) -> Tensor
Solve an aligned condition into a vocoder latent [1, 128, T_mel].
The previous window's latent is re-imposed at every step rather than only at the start: the leading left frames are pinned to the exact noise-to-latent interpolation the solver would have produced had it generated them, so the two windows join without a seam.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
align | Tensor | Aligned condition, | required |
generator | Generator | Seeded generator for the initial noise draw. | required |
initial_latent | Tensor | None | Previous window's tail latent, or | None |
initial_condition | Tensor | None | Previous window's tail condition, or | None |
num_steps | int | Euler steps. | DEFAULT_DIT_STEPS |
cfg_scale | float | Classifier-free guidance weight. | DEFAULT_DIT_CFG_SCALE |
Returns:
| Type | Description |
|---|---|
Tensor | The solved latent, |
Raises:
| Type | Description |
|---|---|
ValueError | If |
MiniMaxMusic3Transformer1DModel ¶
Bases: Module
The 36-block velocity field: ([B,128,T], [B], [B,2048,T]) -> [B,128,T].
attention_backend_name property ¶
attention_backend_name: str
The attention path the blocks actually run, for startup logging.
postprocess_conv instance-attribute ¶
postprocess_conv = nn.Conv1d(
DIT_LATENT_CHANNELS, DIT_LATENT_CHANNELS, 1, bias=False
)
preprocess_conv instance-attribute ¶
transformer_blocks instance-attribute ¶
transformer_blocks = nn.ModuleList(
TransformerBlock(
_DIM,
head_dim=_HEAD_DIM,
inner_dim=_FF_INNER_DIM,
prefix=f"transformer_blocks.{index}.attn",
)
for index in range(_NUM_LAYERS)
)
forward ¶
Predict the flow velocity at latent x and time t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x | Tensor | Current latent, | required |
t | Tensor | Flow time in | required |
condition | Tensor | Aligned condition, | required |
Returns:
| Type | Description |
|---|---|
Tensor | The velocity, |
TimestepEmbedding ¶
TransformerBlock ¶
Bases: Module
Pre-norm attention followed by a pre-norm gated feed-forward.
remap_transformer_state ¶
Rewrite transformer/ checkpoint keys onto this module tree.
Two rewrites, both confined to the attention block:
attn.to_q/to_k/to_v.weightare concatenated along the output axis intoattn.to_qkv.weight.nn.Linearoutput featureireads weight rowi, and :meth:Attention.forwardsplits the projection withchunk(3, dim=-1)intoq, k, v, so query rows come first and value rows last.attn.to_out.0.weightloses its index: the checkpoint modelsto_outas a two-element list whose second element is a parameterless dropout, and inference only needs the projection.
Every other key is copied through untouched, including the fused ff_in whose halves are consumed as value, gate in that order.
Raises:
| Type | Description |
|---|---|
ValueError | If a block is missing one of its three projections. |