Skip to content

Export an MLX model for the iOS demo build - #22297

Open
shoumikhin wants to merge 2 commits into
mainfrom
ios-ci-mlx-export
Open

Export an MLX model for the iOS demo build#22297
shoumikhin wants to merge 2 commits into
mainfrom
ios-ci-mlx-export

Conversation

@shoumikhin

@shoumikhin shoumikhin commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

The mv3 Apple demo is gaining an MLX option (meta-pytorch/executorch-examples#260), and that change bundles mv3_mlx.pte into 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-ios is 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.sh and scripts/test_ios.sh get 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=True to match the three sibling exports.

Why this runs on the existing runner

Lowering is ahead of time. Neither backends/mlx/partitioner.py nor backends/mlx/preprocess.py imports the mlx runtime 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_program logs 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 MLXBackend delegate 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.

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.
Copilot AI lite review requested due to automatic review settings August 29, 2026 04:45
@pytorch-bot

pytorch-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown

🔗 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 Failures

As of commit c9e6e49 with merge base 9b558d9 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.
Copilot AI review requested due to automatic review settings August 29, 2026 11:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@shoumikhin shoumikhin added the release notes: none Do not include this in the release notes label Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants