SimpleTuner icon indicating copy to clipboard operation
SimpleTuner copied to clipboard

MiniMax Music 3: precompute_rvq_codes.py raises ModuleNotFoundError on main and v4.7.1 (reference_adapter removed in 596646d2)

Open aidiffuser opened this issue 3 months ago • 2 comments

Summary

On main (f1ce2d50) and in the v4.7.1 release, scripts/minimax_music3/precompute_rvq_codes.py line 24 imports a module that is no longer in the tree:

from simpletuner.helpers.models.minimaxmusic.reference_adapter import MiniMaxMusic3ReferenceAdapter  # noqa: E402

simpletuner/helpers/models/minimaxmusic/reference_adapter.py was removed in 596646d2 ("cleanup / remove more experimental code, update docs", -934 lines) together with tests/test_minimaxmusic_reference_adapter.py (-194). The importing script was left behind. The import is at module scope, so the script fails before argparse runs — --help raises too.

The reason I think this is worth a report rather than a shrug: the same release added a consumer for that script's output. documentation/OPTIONS.md (--minimax_music_lm_precache_mode) tells users that audio-only and audio+text teacher-force "the sample's ground-truth RVQ codes (audio_tokens_path metadata, raw per-codebook indices)", and simpletuner/helpers/models/minimaxmusic/model.py hard-raises in _lm_load_audio_codes when those are absent. So v4.7.1 shipped the new teacher-forced DiT precache modes and, in the same PR, deleted the only in-repo tool that produces their input.

Reproduction

Static, no environment needed:

git clone https://github.com/bghira/SimpleTuner && cd SimpleTuner
sed -n '24p' scripts/minimax_music3/precompute_rvq_codes.py
ls simpletuner/helpers/models/minimaxmusic/reference_adapter.py

Runtime:

python scripts/minimax_music3/precompute_rvq_codes.py --help

Expected: argparse usage for --source-dir/--pair-ids-file/--output-dir/--raw-codes/....

Actual (derived from a static read of the import graph — I have not executed this in a clean env, so treat the exact text as indicative):

ModuleNotFoundError: No module named 'simpletuner.helpers.models.minimaxmusic.reference_adapter'

Commit archaeology

when (UTC) commit effect
08-20 13:51 df1e16cf "package the RVQ reference adapter": added reference_adapter.py (+934), dropped --collection-dir, rewrote the import to the packaged path — this is the line that is now broken
08-20 18:01 b381ce3e "cleanup, remove controllora experimental code, fix ci": removed nine sibling scripts from scripts/minimax_music3/ and reference_control.py; kept precompute_rvq_codes.py
08-20 19:36 596646d2 removed reference_adapter.py + its test, and in the same commit rewrote documentation/quickstart/MINIMAX_MUSIC.md and its five translations from "Export them with scripts/minimax_music3/precompute_rvq_codes.py --raw-codes" to "...from the dedicated minimax-music3-latent-replanner repository"
08-20 19:36 def7bbc0 PR #3108 merged
08-20 19:51 v4.7.1 596646d2 is an ancestor of the tag, so the break shipped

That docs rewrite reads like the in-repo exporter was retired deliberately and only the file was left behind — which is why I suspect the fix you want is a deletion rather than a repair.

Scope

  • Nothing else on main references reference_adapter or MiniMaxMusic3ReferenceAdapter, and simpletuner/helpers/models/minimaxmusic/__init__.py does not re-export it. One orphaned file.
  • The other three files in scripts/minimax_music3/ (train_latent_replanner.py, _ddp.py, _fewpair.py) import only ...minimaxmusic.vocoder.MiniMaxMusic3DAV, which still exists — they import cleanly and are not affected.
  • scripts/ is excluded from the wheel and sdist, so only source-checkout users hit it.
  • The external copy works: bghira/minimax-music3-latent-replanner/precompute_rvq_codes.py imports the top-level minimax_music3_reference_adapter supplied by minimax-music3-rvq-reference-audio, pinned in its requirements.txt. I diffed that module against the deleted vendored one: 73 lines, all cosmetic (black reflow, itertools.pairwise, one annotation) — functionally identical, --raw-codes included.

Why CI did not catch it

.github/workflows/python-tests.yaml fires only on paths: simpletuner/** and tests/**, so a scripts-only change never runs the suite. The flake8 pre-commit hook excludes ^(scripts/|tests/|\.venv/). And the one test that imported the module was removed in the same commit, so unittest discover has nothing left to fail on.

Suggested fix

Delete scripts/minimax_music3/precompute_rvq_codes.py. The docs already send users to the external repo, nothing else imports it, and nothing packaged changes. Happy to open that PR.

One honest caveat on that recommendation: deleting does not remove the git-only dependency, it just moves it out of sight. minimax-music3-latent-replanner/requirements.txt pulls git+https://github.com/bghira/minimax-music3-rvq-reference-audio.git unpinned, and OPTIONS.md still requires that pipeline's output for the teacher-forced modes. If you keep the deletion, it might be worth having OPTIONS.md name the producer repo the way MINIMAX_MUSIC.md now does, so the trail from "this flag needs audio_tokens_path" to "here is how you make one" stays unbroken.

Two questions before I send a PR:

  1. Should train_latent_replanner{,_ddp,_fewpair}.py go as well? They are not broken, but no docs reference them any more and the canonical trainer lives in the replanner repo. Happy either way — I did not want to bundle a judgement call about experimental code into a one-line-evidence bug fix.
  2. Would you want - "scripts/**" added to the python-tests.yaml paths filter, plus a small AST-only test asserting that every module-level from simpletuner.... import under scripts/ resolves to a real file? That is the only construct that would have caught this. Easy to leave out.

Thanks for the fast turnaround on #3111 — the LM LoRA path built on this has been working well for us.


AI-assisted investigation; every SHA, path and line number above was verified against main at f1ce2d50 before filing.

aidiffuser avatar Aug 21 '26 08:08 aidiffuser

https://github.com/bghira/minimax-music3-rvq-reference-audio has that now, it should be fully removed from this repo. the hf repo should be authoritative on the rvq encoder portion.

bghira avatar Aug 21 '26 13:08 bghira

just to clarify that the reference adapter code is now in bghira/minimax-music3-rvq-reference-audio

the precompute script was for the latent re-planner, which is in this repository

bghira avatar Aug 21 '26 19:08 bghira