Comfy-Org/ComfyUI · error · RuntimeError

MiniMax Music3 DAV cannot encode audio

Error message

MiniMax Music3 DAV cannot encode audio

What it means

The MiniMax Music3 DAV is a decoder-only audio VAE: it has no encoder, so VAE.encode paths are wired to a stub that raises this RuntimeError. The class sets memory_used_encode to a function whose only job is to fail loudly if anything tries to encode audio through this model. Decoding latents to audio is supported.

Source

Thrown at comfy/sd.py:534

        self.format_encoded = None

        self.audio_sample_rate = 44100

        if config is None:
            if "dec_in_proj.weight" in sd and "decoder.model.0.weight_g" in sd:  # MiniMax Music3 DAV
                self.first_stage_model = comfy.ldm.minimax_music.dav.MiniMaxMusic3DAV(operations=comfy.ops.disable_weight_init)
                self.latent_channels = 128
                self.output_channels = 2
                self.upscale_ratio = 512
                self.downscale_ratio = 512
                self.latent_dim = 1
                self.process_output = lambda audio: audio
                self.process_input = lambda audio: audio
                self.working_dtypes = [torch.float32]
                self.disable_offload = True
                self.memory_used_decode = lambda shape, dtype: (shape[-1] * 512 * 1400 + 800_000_000) * model_management.dtype_size(dtype)
                def _no_encode(*args, **kwargs):
                    raise RuntimeError("MiniMax Music3 DAV cannot encode audio")
                self.memory_used_encode = _no_encode
            elif "decoder.mid.block_1.mix_factor" in sd:
                encoder_config = {'double_z': True, 'z_channels': 4, 'resolution': 256, 'in_channels': 3, 'out_ch': 3, 'ch': 128, 'ch_mult': [1, 2, 4, 4], 'num_res_blocks': 2, 'attn_resolutions': [], 'dropout': 0.0}
                decoder_config = encoder_config.copy()
                decoder_config["video_kernel_size"] = [3, 1, 1]
                decoder_config["alpha"] = 0.0
                self.first_stage_model = AutoencodingEngine(regularizer_config={'target': "comfy.ldm.models.autoencoder.DiagonalGaussianRegularizer"},
                                                            encoder_config={'target': "comfy.ldm.modules.diffusionmodules.model.Encoder", 'params': encoder_config},
                                                            decoder_config={'target': "comfy.ldm.modules.temporal_ae.VideoDecoder", 'params': decoder_config})
            elif "taesd_decoder.1.weight" in sd:
                if isinstance(metadata, dict) and "tae_latent_channels" in metadata:
                    self.latent_channels = metadata["tae_latent_channels"]
                else:
                    self.latent_channels = sd["taesd_decoder.1.weight"].shape[1]
                self.first_stage_model = comfy.taesd.taesd.TAESD(latent_channels=self.latent_channels)
            elif "vquantizer.codebook.weight" in sd: #VQGan: stage a of stable cascade
                self.first_stage_model = StageA()
                self.downscale_ratio = 4

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Use the latent-generation path for MiniMax Music3 (sample latents from the model, then VAEDecode); never call VAEEncode on it.
  2. Branch workflow code on the VAE type (or on vae.first_stage_model class) before choosing encode vs decode.
  3. If audio-conditioned generation is needed, pick a VAE that actually has an encoder (e.g. a Stable Audio-style VAE).

Example fix

# before
latent = vae.encode(audio)  # RuntimeError for MiniMax Music3 DAV

# after
if isinstance(vae.first_stage_model, comfy.ldm.minimax_music.dav.MiniMaxMusic3DAV):
    raise SystemExit('Music3 DAV is decode-only; start from sampled latents')
latent = vae.encode(audio)
Defensive patterns

Strategy: validation

Validate before calling

encode_ok = not isinstance(
    vae.first_stage_model,
    comfy.ldm.minimax_music.dav.MiniMaxMusic3DAV,
)
assert encode_ok, 'MiniMax Music3 DAV is decode-only; build latents from the model instead of encoding audio'

Type guard

def vae_supports_encode(vae) -> bool:
    return not isinstance(getattr(vae, 'first_stage_model', None),
                          __import__('comfy.ldm.minimax_music.dav', fromlist=['MiniMaxMusic3DAV']).MiniMaxMusic3DAV)

Try / catch

try:
    latent = vae.encode(audio)
except RuntimeError as e:
    if 'cannot encode audio' in str(e):
        raise SystemExit('This VAE is decode-only: generate latents with the Music3 model, then VAEDecode.')
    raise

Prevention

When it happens

Trigger: Connecting the MiniMax Music3 VAE to VAEEncode / VAEEncodeTiled or any node calling VAE.encode; API code that assumes every VAE object supports encode(); building a text-to-audio workflow that starts from raw audio instead of empty latents.

Common situations: Trying img2img-style audio workflows (encode reference audio, then decode) with Music3; reusing generic VAE pipeline code for all models; custom nodes that call vae.encode unconditionally.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/e41d08ad491027e8. Report an issue: GitHub.