Skip to content

[executorch][native] Add deserializer bridge (Program -> Method) - #22105

Open
SS-JIA wants to merge 1 commit into
gh/SS-JIA/594/basefrom
gh/SS-JIA/594/head
Open

[executorch][native] Add deserializer bridge (Program -> Method)#22105
SS-JIA wants to merge 1 commit into
gh/SS-JIA/594/basefrom
gh/SS-JIA/594/head

Conversation

@SS-JIA

@SS-JIA SS-JIA commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Threads the in-memory IR through the program reader: ptn::Program now
materializes a serialized native_backend::Program into ptn::Method /
Graph / Node / Argument / Value. This is the bridge from the FlatBuffer
wire 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 eagerly
    builds anything.
  • Program::num_methods() / method_names() read the FlatBuffer directly.
  • Program::get_method(name) materializes the method's IR on first request and
    caches it (a mutable unordered_map<string, Method>, so lookups work on a
    const 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, keeping Program.cpp
the thin reader. Per method it:

  • Builds the Graph: creates a Value per SSA name (Tensor when the tensor
    side table carries metadata, else a None value for scalar / symbolic outputs),
    a Node per fx node with its Arguments (resolving in-graph SSA names to
    arena ValueRefs: tensor refs, symbolic scalar refs, tensor / optional-tensor
    lists, getitem-folded Tensor[] outputs into elem_refs), the graph I/O
    ref lists, then reset_schedule() + rebuild_def_use(). Recurses HOP
    subgraphs (GraphArg) into the per-graph subgraph arena.
  • Builds the method bindings: constants and mutable_buffers become
    DataBindings (stamping each placeholder Value's role / data_key;
    graph inputs not otherwise bound become UserInput), and output_specs
    resolve their string target to a target_ref (an SSA name for
    UserInputMutation, an fqn for BufferMutation).

Also adds a --methods mode to native_executor that dumps each materialized
method via Method::to_string().

Pure std + flatbuffers only (no ExecuTorch dependency).

Differential Revision: D114426391

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

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

As of commit 3194b01 with merge base 9a2d135 (image):

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.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@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 24, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant