[executorch][native] Add deserializer bridge (Program -> Method) - #22105
Open
SS-JIA wants to merge 1 commit into
Open
[executorch][native] Add deserializer bridge (Program -> Method)#22105SS-JIA wants to merge 1 commit into
SS-JIA wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22105
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit 3194b01 with merge base 9a2d135 ( NEW FAILURE - The following job has failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 24, 2026
This PR needs a
|
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.
Stack from ghstack (oldest at bottom):
Threads the in-memory IR through the program reader:
ptn::Programnowmaterializes a serialized
native_backend::Programintoptn::Method/Graph/Node/Argument/Value. This is the bridge from the FlatBufferwire form to the in-memory graph the rest of the runtime will consume.
Loading is lazy and keyed by name, mirroring ExecuTorch's own
Program::load_method(name)model:Program::load()parses and verifies the buffer only; it no longer eagerlybuilds anything.
Program::num_methods()/method_names()read the FlatBuffer directly.Program::get_method(name)materializes the method's IR on first request andcaches it (a
mutable unordered_map<string, Method>, so lookups work on aconst Program and returned references stay stable across later insertions);
subsequent calls return the same instance. Throws if the name is absent.
The deserializer itself lives in a new
Deserialize.cpp, keepingProgram.cppthe thin reader. Per method it:
Graph: creates aValueper SSA name (Tensor when the tensorside table carries metadata, else a None value for scalar / symbolic outputs),
a
Nodeper fx node with itsArguments (resolving in-graph SSA names toarena
ValueRefs: tensor refs, symbolic scalar refs, tensor / optional-tensorlists,
getitem-foldedTensor[]outputs intoelem_refs), the graph I/Oref lists, then
reset_schedule()+rebuild_def_use(). Recurses HOPsubgraphs (
GraphArg) into the per-graph subgraph arena.constantsandmutable_buffersbecomeDataBindings (stamping each placeholderValue'srole/data_key;graph inputs not otherwise bound become
UserInput), andoutput_specsresolve their string
targetto atarget_ref(an SSA name forUserInputMutation, an fqn for BufferMutation).
Also adds a
--methodsmode tonative_executorthat dumps each materializedmethod via
Method::to_string().Pure std + flatbuffers only (no ExecuTorch dependency).
Differential Revision: D114426391