Repository navigation
Conversation
CoreAIPartitioner(multifunction=True) lowers every Core AI partition of every method into one Core AI model with one function per partition, named <method>_<partition index> (forward_0, prefill_0, and forward_1 after a graph break). CoreAIBackend.preprocess_multimethod converts all partitions with one TorchConverter, saves or AOT-compiles once, embeds the bundle once, and writes one manifest per delegate naming its function and ordered I/O. Weights shared between methods are stored once, and because function bindings are not part of the runtime cache key, the delegates share one cache entry: the first load specializes and the rest restore from the same bookmark. No runtime or manifest format change is needed. Every partition must carry identical compile specs, and input_enumerations is not supported with the option yet. Without the option, lowering is unchanged.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24476
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New Failures, 1 Unclassified FailureAs of commit 92c2805 with merge base 822cb60 ( NEW FAILURES - The following jobs have failed:
UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This branch was previously deployed
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.
Adds an opt-in way to export several ExecuTorch methods (and graph-broken partitions) as one Core AI model with multiple functions, so methods that share weights ship and cache them once.
Stacked on #24474.
Usage
Each Core AI partition becomes one function named
<method>_<partition index>: hereforward_0andprefill_0, and a graph break addsforward_1,prefill_1, and so on. Graph breaks are allowed; partitions running on CPU stay in ExecuTorch as usual.How it works
CoreAIBackend.preprocess_multimethodreceives every method's partitions at once.TorchConverter(one entrypoint per partition), callsto_coreai()once, and saves (or AOT-compiles withcoreai-build) once.NamedDataStoreonce, under a singleexport_hash.function,input_namesandoutput_names; all manifests point at the same bundle.preprocessand the multi-method path now share the conversion and delivery helpers, and the existing tests still pass.input_enumerationsis combined with the option. Enumerated shapes rename functions internally and need their own design.Results
Two-method model (8 ×
Linear(1024, 1024), fp32;forwardwith 1 row,prefillwith 16 rows), run on an M4 Max with a standalone C++ runner:multifunction=Truemultifunction=True+ graph break (4 functions)Shared weights are stored once: in a direct converter check, adding a second function to an 8.4 MB model added 2.9 KB.
Process memory after loading and running is about the same either way (~184 MB), because each delegate still loads its own model instance. In-process sharing of one loaded model could be a follow-up if it turns out to matter.
Test plan
backends/apple/coreai/test/test_multifunction.py:input_enumerations.export_hash,path, files, data-store keys) withforward_0/prefill_0, and the combined bundle is about the size of a single method's.forward_0,forward_1,prefill_0,prefill_1in one bundle.mainmodel per delegate (as today).coreai-build(one build, sharedarchs) and with the realcoreai-build.coreai_fp32377 passed,coreai_fp16368 passed, 0 failures.