Export an MLX model for the iOS demo build - #22297
Open
shoumikhin wants to merge 2 commits into
Open
Conversation
The mv3 demo app is gaining an MLX option, and its Xcode project bundles mv3_mlx.pte, so this job has to produce that file or the build fails on a missing resource. MLX has no examples/ export script of its own yet, so lower it inline the same way the script already drives the portable, Core ML and XNNPACK exports. Lowering is ahead of time: neither the partitioner nor the preprocess step imports the mlx runtime package, so this runs on the existing runner without new dependencies.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22297
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit c9e6e49 with merge base 9b558d9 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Review found four things. There is a second staging path, scripts/test_ios.sh, that clones the same demo and moves the same wildcard, so it needs the same export or the demo fails on a missing build input once it requires the resource. The MPS removal edited both scripts in one commit; do the same here. save_pte_program logs write failures rather than raising, and `mv $MODEL_NAME*.pte` would still stage a truncated file, so assert the result is nonempty. Verified the guard fires for a missing file and for a zero-byte one, and passes otherwise. The heredoc marker was unquoted, the only one of its kind here: the other python heredoc in this directory uses 'PY'. The shell was rewriting the python body, so a future dollar sign or backtick would be eaten silently. Quote the marker and read the model name from argv. The lowering took the default edge compile config while all three sibling exports disable dim order for a stated iOS reason. Match them.
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.
The mv3 Apple demo is gaining an MLX option (meta-pytorch/executorch-examples#260), and that change bundles
mv3_mlx.pteinto both the app and the test target. Both iOS staging paths in this repository produce only the portable, Core ML and XNNPACK models, so once the demo change lands a missing file becomes a hard Xcode build-input error.Nothing is failing today, and it is worth being precise about that:
build-demo-iosis green both at this head and at the merge base, the demo project on the examples default branch has no MLX reference, and the change that adds it is still open. This lands first so the resource exists when the demo starts asking for it.What changed
Both
.ci/scripts/test_ios_ci.shandscripts/test_ios.shget the export. They clone the same demo and stage with the same wildcard move, so both need it; the MPS removal in fd677f3 edited the two together for the same reason.MLX has no
examples/export script of its own yet, so the model is lowered inline, with_skip_dim_order=Trueto match the three sibling exports.Why this runs on the existing runner
Lowering is ahead of time. Neither
backends/mlx/partitioner.pynorbackends/mlx/preprocess.pyimports themlxruntime package, measured as zero matches for a module-level mlx import in each. So no new dependency and no Metal toolchain needed at export time.The result is checked
save_pte_programlogs write failures instead of raising, and the wildcard move would still stage a truncated file, so the scripts assert the output is nonempty. Verified the guard fires for a missing file and a zero-byte file, and passes for a real one.Known gap
Nothing in CI opens the produced file, so this proves the export runs, not that the program carries an
MLXBackenddelegate or executes through it. The partitioner only warns when it tags nothing, and the demo's three existing tests cover the other backends, so an MLX runtime failure would stay green. An iOS test that loads the MLX model belongs with the demo change.