Skip to content

feat: download models from our mirror first and verify SHA-256 (v0.48.0) - #317

Merged
beveradb merged 2 commits into
mainfrom
feat/sess-20261029-1144-model-source-integrity
Oct 29, 2026
Merged

beveradb merged 2 commits into
mainfrom
feat/sess-20261029-1144-model-source-integrity

Conversation

@beveradb

Copy link
Copy Markdown
Collaborator

Summary

  • Mirror first. Every model file is now fetched from this repo's model-configs release first, with the original source as fallback (UVR's TRvlvr/model_repo, or Meta's CDN for Demucs). Before this, the UVR repo was tried first even though we host identical copies, so about half the models, including karaoke-gen's default RoFormer models, always came from a third-party repo. VIP models still come from Anjok07's repo first.
  • SHA-256 verification. New audio_separator/model-checksums.json lists all 243 published model files, which covers all 273 file references in the supported-model list. A download that doesn't match is discarded and the next source is tried. Cached files are checked once per process (cached by path, size and mtime) and re-downloaded if they don't match. Files with no published checksum are still accepted, so newly added UVR models keep working until the manifest is regenerated. Mutable metadata lists such as download_checks.json are never checked.
  • Atomic downloads. Downloads go to <file>.<pid>.partial and are renamed only after they pass verification. Before this, an interrupted download left a truncated file that every later run treated as present.
  • Maintenance. tools/update-model-checksums.py regenerates the manifest after new uploads. It only hashes files it doesn't already have, unless --rehash is passed.
  • README: new "Where Models Are Downloaded From" section. Version bumped to 0.48.0.

Follow-up to #316 (GHSA-4g2m-m2pr-7g4g): with this, a compromised upstream can't swap in a different file at all, malicious or just corrupted.

How the manifest was built

Every asset in all three release repos (331) plus the 7 Demucs files on Meta's CDN was streamed and hashed on the build host, about 108 GB in total.

  • Every byte count matches GitHub's listed asset size.
  • The 89 filenames published in more than one place are byte-identical everywhere, so the fallback sources verify against the same hashes.
  • The Demucs hashes match the checksums embedded in their filenames.

Testing

  • New tests/unit/test_model_download_integrity.py covers source order (mirror / upstream / VIP / MDXC yaml), tampered downloads falling through to the next source, all sources tampered, tampered cached files being replaced, verified cached files not being re-hashed, files without a checksum, metadata not being checked, and the bundled manifest covering the default models.
  • Unit suite: 571 passed. The 2 test_mps_native_fp16 failures also happen on main.
  • Real download of UVR-MDX-NET-Inst_HQ_4.onnx: fetched from the mirror and verified. Re-verifying it in a new process took 0.03 s. After appending a byte, it was detected and re-downloaded.
  • Built the wheel and confirmed it contains model-checksums.json.
  • Local CodeRabbit, 2 cycles. Fixed: per-process partial path, retries in the checksum tool. Skipped: keeping a failed-checksum file around, since it would be refused anyway.

@coderabbitai ignore

🤖 Generated with Claude Code

https://claude.ai/code/session_012RYLVTA9CYSnmncNv3GRHJ

beveradb and others added 2 commits October 29, 2026 12:07
Model files were fetched from the UVR repo (TRvlvr/model_repo) first even
when our model-configs release had an identical copy, and nothing was
verified apart from Demucs's filename checksums.

- Try the audio-separator model-configs release first for every file,
  falling back to the original source (UVR repo, Meta's CDN). VIP models
  still come from Anjok07's repo first.
- Ship model-checksums.json: SHA-256 for all 243 published model files,
  covering every file the library can download. Downloads that don't
  match are discarded and the next source is tried; cached files are
  checked once per process and replaced if they don't match.
- Download to a .partial file and rename when complete, so an
  interrupted download no longer leaves a truncated model that later
  runs treat as present.
- tools/update-model-checksums.py regenerates the manifest after new
  uploads (only hashes files it doesn't already know).

Hashes were streamed from all three release repos plus Meta's CDN on the
build host: every byte count matches GitHub's listed size, the 89 files
published in more than one place are byte-identical everywhere, and the
Demucs hashes match the checksums embedded in their filenames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012RYLVTA9CYSnmncNv3GRHJ
…cksum tool

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012RYLVTA9CYSnmncNv3GRHJ
@beveradb
beveradb merged commit 4dd3477 into main Oct 29, 2026
35 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant