Skip to content

v0.9.1: discovery tolerates broken host ML deps

Choose a tag to compare

@queelius queelius released this 15 Apr 02:32
· 930 commits to main since this release

Point release fixing a discovery bug that could hide every bundled
model from muse models list.

The bug

Four model scripts (sd_turbo, all_minilm_l6_v2, qwen3_embedding_0_6b,
nv_embed_v2) had heavy ML imports at module top level:

try:
    import torch
    from diffusers import AutoPipelineForText2Image
except ImportError:
    torch = None
    AutoPipelineForText2Image = None

Two ways this failed:

  1. Broken host deps. If the supervisor env has a stale diffusers
    pinned to a transformers version that removed MT5Tokenizer,
    diffusers' _LazyModule wraps the failure as a RuntimeError, not
    an ImportError. The except ImportError does not catch it and the
    module-level import raises. Discovery catches the exception per
    script but the sibling models vanish from the listing along with the
    broken one. This is what users were actually hitting.

  2. Supervisor env legitimately lacks per-model deps. The supervisor
    runs in an env that does NOT have torch/diffusers/transformers
    installed. Those live in per-model venvs at ~/.muse/venvs/<id>/,
    created by muse pull. A top-level import that assumes otherwise is
    just wrong.

The fix

Each of the four scripts now follows the pattern the three audio scripts
(kokoro_82m, soprano_80m, bark_small) already used: module-level
None sentinels plus a per-symbol lazy _ensure_deps() called from
Model.__init__. Per-symbol import means tests can patch one module
attr without affecting the other.

Regression guard

New test test_bundled_model_scripts_import_without_any_ml_deps
installs a meta-path finder that raises on all four top-level ML
package roots and verifies every bundled model is still discovered.
Would have caught this at review time.

Upgrade

pip install -U -e ".[server]"

Or in production with a per-model venv setup, nothing changes in the
venvs: the fix only affects what the supervisor env sees during
discovery.

Tests: 419 pass.