mudler/LocalAI · critical · RuntimeError

generate_music failed

Error message

generate_music failed

What it means

Raised by the ACE-Step backend wrapper after the upstream generate_music() call reports failure (result.success is False). The message is the upstream result.error or result.status_message, or the generic 'generate_music failed' when the result carries neither. It means the music generation pipeline itself failed before producing any output.

Source

Thrown at backend/python/ace-step/backend.py:277

        use_random_seed=bool(payload.get("use_random_seed", True)),
        seeds=payload.get("seeds"),
        lm_batch_chunk_size=max(1, int(payload.get("lm_batch_chunk_size", 8))),
        constrained_decoding_debug=bool(payload.get("constrained_decoding_debug")),
        audio_format=(payload.get("audio_format") or "flac").strip() or "flac",
    )

    save_dir = tempfile.mkdtemp(prefix="ace_step_")
    try:
        result = generate_music(
            dit_handler=dit_handler,
            llm_handler=llm_handler if (llm_handler and getattr(llm_handler, "llm_initialized", False)) else None,
            params=params,
            config=config,
            save_dir=save_dir,
            progress=None,
        )
        if not result.success:
            raise RuntimeError(result.error or result.status_message or "generate_music failed")

        audios = result.audios or []
        if not audios:
            raise RuntimeError("generate_music returned no audio")

        first_path = audios[0].get("path") or ""
        if not first_path or not os.path.isfile(first_path):
            raise RuntimeError("first generated audio path missing or not a file")

        shutil.copy2(first_path, dst_path)
    finally:
        try:
            shutil.rmtree(save_dir, ignore_errors=True)
        except Exception:
            pass


class BackendServicer(backend_pb2_grpc.BackendServicer):

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Inspect the full traceback and the upstream result.error / result.status_message content — the generic message only appears when both are empty.
  2. Verify the ACE-Step model snapshot is complete and the paths in config resolve (see require_snapshot_file errors for how the ref is resolved).
  3. Check GPU memory availability and reduce params (e.g. fewer inference steps, shorter duration) to lower VRAM pressure.
  4. If llm_handler-based generation is intended, confirm llm_handler.llm_initialized is True before the call, otherwise lyrics/tag generation silently runs without the LLM.
Defensive patterns

Strategy: try-catch

Validate before calling

params_ok = dit_handler is not None and (llm_handler is None or getattr(llm_handler, "llm_initialized", False))
import shutil
free = shutil.disk_usage(tempfile.gettempdir()).free
assert params_ok and free > 1 << 30, "preconditions for generate_music not met"

Try / catch

try:
    run_ace_step_generation(params, config)
except RuntimeError as e:
    # message may be upstream result.error or status_message
    logger.error("ace-step generation failed: %s", e)
    raise GenerationError(str(e)) from e

Prevention

When it happens

Trigger: Calling the backend's generation entry point (which invokes generate_music with dit_handler, optional llm_handler, params, config and a temp save_dir) when the diffusion transformer pipeline errors out, is interrupted, or returns success=False with an empty error/status field.

Common situations: Missing or corrupt ACE-Step checkpoint files, out-of-memory on GPU during the DiT pass, an LLM handler that was passed while not fully initialized (the code passes None unless llm_initialized is True), or version drift between the backend and the ace-step pip package changing the result contract.

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/dd95e5b51b8ec7c3. Report an issue: GitHub.