Declare an ONNX inference backend for basic-pitch - #18
Open
peterbjohnson wants to merge 1 commit into
Open
Conversation
Basic Pitch chooses a backend at import from whichever of CoreML, TensorFlow, TFLite or ONNX Runtime happens to be installed, and raises NameError while defining ICASSP_2022_MODEL_PATH when it finds none. It declares those backends behind platform markers, so which one arrives depends on the machine doing the install. On linux/arm64 the tensorflow wheel is an empty shim requiring tensorflow-cpu-aws, which never resolved into our lock, so no backend was installed at all. The worker then died at import and the container never started. CI and the AWS build are amd64 and so never saw it. Declare the backend explicitly with the "onnx" extra. ONNX Runtime is the one backend with wheels for every platform we build for. Add tests covering the installed backend, the name whose absence takes the container down, and our own model loader. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #12
Problem
The image builds fine but the container never starts on
linux/arm64. Shimmy waits 15 s for the worker, the worker exits 1, and the container dies:Basic Pitch ships no inference code of its own. It picks a backend at import from whichever of CoreML, TensorFlow, TFLite or ONNX Runtime it finds, and fails while defining
ICASSP_2022_MODEL_PATHif it finds none. Those backends sit behind platform markers, so what you get depends on the machine doing the install:On arm64 the
tensorflowwheel is an empty shim that requirestensorflow-cpu-aws, which Poetry never resolved into our lock. CI and the AWS build are amd64, so neither ever sees this.Approach
Tests first, in
evaluation_function/backend_test.py. Before the change, on this macOS host:Being explicit about what that shows: only the first test can fail on a developer machine, because macOS resolves coremltools and satisfies the other two. The container is the real reproduction, so I built the image from this branch before and after.
Before (
import evaluation_function.evaluationinside the image):After:
These tests live in their own file rather than in
evaluation_test.pybecause they do not exercise this repository's logic. They assert that a usable inference backend is installed, which is a packaging concern rather than pipeline behaviour. The same reasoning applies totransport_test.pyin #17; if both land, folding the two into a singleenvironment_test.pywould be reasonable.Change
One dependency line in
pyproject.toml, plus the relock:The lock change is confined to
onnxruntimeand itsflatbuffersdependency.Verification
Correction to the issue
I wrote in #12 that this would also shrink the image. That was wrong. The
onnxextra adds a backend but does not removetensorflow, which basic-pitch depends on unconditionally for non-Darwin platforms. The arm64 image grew from 1.4 GB to 1.46 GB.Dropping TensorFlow in favour of ONNX Runtime alone would genuinely shrink the amd64 image, but that changes which backend runs in production and needs its own transcription-accuracy check, so it is out of scope here. Worth a separate issue if the image size matters.
🤖 Generated with Claude Code