Repository navigation
Keep the caller's numpy when setting up the Core ML backend - #24090
Merged
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24090
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit ca8f53f with merge base d533adf ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Gasoonjia
reviewed
Oct 23, 2026
| CXX="$HOST_CXX" \ | ||
| CFLAGS="$HOST_CFLAGS" \ | ||
| CXXFLAGS="$HOST_CXXFLAGS" \ | ||
| python -m pip install -r "$COREMLTOOLS_DIR_PATH/reqs/build.pip" |
Contributor
There was a problem hiding this comment.
is there any othr places using build.pip if that's out of date now? if not maybe we need to remove build.pip if that's a et controled file?
Contributor
Author
There was a problem hiding this comment.
build.pip is not an ExecuTorch file. It comes from Apple's coremltools repo, which this script clones at the 9.0 tag. After this change nothing in ExecuTorch uses it, so there is nothing for us to remove.
shoumikhin
force-pushed
the
coreml-keep-numpy
branch
from
October 23, 2026 08:01
60f908a to
7ed5383
Compare
backends/apple/coreml/scripts/install_requirements.sh clones coremltools and installs its reqs/build.pip before building the mlmodel library. That file pins numpy==2.0.0 for Python 3.9 to 3.12, so running the script silently downgrades numpy in the caller's environment. pandas 3.1.0 (released October 22, 2026) requires numpy>=2.0.2, so after the downgrade `import pandas` fails, and anything that imports the ExecuTorch devtools (for example examples/apple/coreml/scripts/export.py) breaks with "Please upgrade numpy to >= 2.0.2". Most Core ML jobs in CI hit this. The coremltools 9.0 CMake build only needs numpy (it asks numpy for its include path) and setuptools (it builds the bundled kmeans1d helper with setup.py). Install just those, unpinned, so an existing numpy is left alone. This also fixes a plain Python 3.12 venv, which has no setuptools: there the old script stopped at the CMake configure step. The comment next to COREMLTOOLS_VERSION now points at setup.py, where the coremltools pin lives, and asks to re-check this package list on a bump. Test plan: - Python 3.12 venv with numpy 2.4.6, pandas 3.1.0 and setuptools, script before and after this change. Before: mlmodel builds, numpy drops to 2.0.0, `import pandas` fails. After: mlmodel builds, numpy stays 2.4.6, `import pandas` works. - Brand new Python 3.12 venv with only pip, CMake 3.31: the script installs numpy and setuptools, builds mlmodel and copies the protobuf sources. - Configuring coremltools with only numpy fails at kmeans1d, and with only setuptools fails at the numpy include path, so both are needed.
shoumikhin
force-pushed
the
coreml-keep-numpy
branch
from
October 23, 2026 17:44
7ed5383 to
ca8f53f
Compare
JacobSzwejbka
approved these changes
Oct 23, 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.
Problem
backends/apple/coreml/scripts/install_requirements.shclones coremltools and runspip install -r reqs/build.pipbefore it builds themlmodellibrary. That file pinsnumpy==2.0.0on Python 3.9 to 3.12. So running the script quietly downgrades numpy in whatever environment called it.This used to be harmless. pandas 3.1.0 (released October 22, 2026) requires
numpy>=2.0.2, so after the downgradeimport pandasfails:The ExecuTorch devtools import pandas, so
examples/apple/coreml/scripts/export.pyfails, and so do most Core ML jobs in CI (for exampletest-coreml-delegate,test-models-macos-coreml,build-demo-ios). A few jobs that run the script still pass, because nothing imports pandas after it.Fix
The coremltools 9.0 CMake build only needs two Python packages:
setup.pyInstall just those two, unpinned. If numpy is already installed, pip leaves it alone. A comment says why each one is there.
This also fixes a plain Python 3.12 virtual environment. It has no setuptools, and
build.pipadds setuptools only for Python 3.13 and newer, so there the old script stopped at the CMake configure step.The note next to
COREMLTOOLS_VERSIONnow points atsetup.py, where the coremltools pin lives today, and asks to re-check this package list when the version changes.Testing
On macOS with Python 3.12:
import pandasIn every "yes" row the protobuf sources the runtime needs are copied to
runtime/sdk/format/. The new venv run used CMake 3.31, matching thecmake<4pin inrequirements-dev.txt.To check that both packages are needed, I configured coremltools with only one of them. With only numpy, configure fails building kmeans1d. With only setuptools, it fails to find the numpy include path.
In CI,
test-coreml-delegate,test-models-macos-coreml(all models),test-static-llama-aneandtest-llama-runner-mac (coreml)ran with this install line and passed. Their logs show numpy and setuptools already installed, numpy kept at 2.4.6, andmlmodelbuilt.