Skip to content

ETRecord: capture delegate _delegate_info_meta into ETRecord#21379

Open
Gasoonjia wants to merge 1 commit into
mainfrom
export-D113189648
Open

ETRecord: capture delegate _delegate_info_meta into ETRecord#21379
Gasoonjia wants to merge 1 commit into
mainfrom
export-D113189648

Conversation

@Gasoonjia

Copy link
Copy Markdown
Contributor

Summary:
Backends can attach arbitrary per-delegate info during lowering via
PreprocessResult._delegate_info_meta, which to_backend copies onto
lowered_module.meta["_delegate_info_meta"]. Until now that info dead-ended on
the lowered module and never reached the ETRecord. This diff carries it the last
mile so it can be inspected after an ETRecord is parsed back.

What changed:

  • ETRecord gains a delegate_info: Dict[str, Any] field, stored as a single
    JSON blob (reserved name delegate_info), keyed by f"{method}/{lowered_name}".
  • Extraction lives entirely inside ETRecord (no delegate-specific logic in
    _program.py). _maybe_extract_delegate_info is called from
    add_edge_dialect_program and add_executorch_program, gated so it runs only
    when (a) the ETRecord has no delegate_info yet and (b) the incoming graph
    actually carries it. All recorded graphs are the same model, so it is captured
    exactly once. It walks lowered submodules (recursing into control-flow
    submodules) and skips non-JSON-serializable values (with a warning) so a
    backend cannot break ETRecord saving.
  • Covers both flows: to_edge_transform_and_lower(...) (captured at
    add_edge_dialect_program) and to_edge(...).to_backend(...) (captured at
    add_executorch_program, since the delegated graph is only available there).
  • Example backend now logs a minimal, non-static fingerprint
    (sha256(processed_bytes)) via _delegate_info_meta as the reference pattern
    for other backends (Arm/XNNPACK) to follow.

Note: exir/program/_program.py is intentionally untouched.

Differential Revision: D113189648

Summary:
Backends can attach arbitrary per-delegate info during lowering via
`PreprocessResult._delegate_info_meta`, which `to_backend` copies onto
`lowered_module.meta["_delegate_info_meta"]`. Until now that info dead-ended on
the lowered module and never reached the ETRecord. This diff carries it the last
mile so it can be inspected after an ETRecord is parsed back.

What changed:
- `ETRecord` gains a `delegate_info: Dict[str, Any]` field, stored as a single
  JSON blob (reserved name `delegate_info`), keyed by `f"{method}/{lowered_name}"`.
- Extraction lives entirely inside ETRecord (no delegate-specific logic in
  `_program.py`). `_maybe_extract_delegate_info` is called from
  `add_edge_dialect_program` and `add_executorch_program`, gated so it runs only
  when (a) the ETRecord has no delegate_info yet and (b) the incoming graph
  actually carries it. All recorded graphs are the same model, so it is captured
  exactly once. It walks lowered submodules (recursing into control-flow
  submodules) and skips non-JSON-serializable values (with a warning) so a
  backend cannot break ETRecord saving.
- Covers both flows: `to_edge_transform_and_lower(...)` (captured at
  `add_edge_dialect_program`) and `to_edge(...).to_backend(...)` (captured at
  `add_executorch_program`, since the delegated graph is only available there).
- Example backend now logs a minimal, non-static fingerprint
  (`sha256(processed_bytes)`) via `_delegate_info_meta` as the reference pattern
  for other backends (Arm/XNNPACK) to follow.

Note: `exir/program/_program.py` is intentionally untouched.

Differential Revision: D113189648
@pytorch-bot

pytorch-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21379

Note: Links to docs will display an error until the docs builds have been completed.

❌ 4 New Failures, 41 Unrelated Failures

As of commit 210a94d with merge base e2c9a48 (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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 Jul 24, 2026
@meta-codesync

meta-codesync Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@Gasoonjia has exported this pull request. If you are a Meta employee, you can view the originating Diff in D113189648.

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

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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant