Skip to content

[Native] Carry named metadata in native packages - #24943

Draft
metascroy wants to merge 1 commit into
offgraph-kv-interactivefrom
offgraph-kv-ptn-metadata
Draft

metascroy wants to merge 1 commit into
offgraph-kv-interactivefrom
offgraph-kv-ptn-metadata

Conversation

@metascroy

@metascroy metascroy commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Stack

Off-graph KV cache for the native ggml engine, through serving Muse Glimmer on it. Review bottom-up; each PR builds and passes its tests on its own.

Summary

A .ptn had no way to carry facts the graph doesn't, such as an LLM's per-layer sliding windows, which a PTE publishes as constant methods. This adds the counterpart:

  • to_native(programs, metadata={...}) saves a metadata.json member: names mapped to a bool, number, string, or a flat list of those. write_ptn validates it and rejects non-finite floats.
  • exir.native.read_metadata(path) reads it back.
  • Package validates the member's structure at load and reads values by name with metadata_int / metadata_ints, which reject integers outside int64.
  • backends/native/README.md documents the member. LLM exports reuse the constant-method names from extension/llm/export/model_metadata.py (get_windows, ...).

Test plan

  • exir/native/test/test_native.py: metadata round-trips, no member without metadata, invalid names and values rejected.
  • test_package.cpp: reads by name, rejects wrong types and malformed members. Run through a local CMake build; that file is only built by Buck.

Authored with Claude Code.

@pytorch-bot

pytorch-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 136 New Failures, 7 Unrelated Failures, 10 Unclassified Failures

As of commit f387dc6 with merge base c7f7931 (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

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

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 Nov 12, 2026
This was referenced Nov 12, 2026
to_native takes metadata, the package's counterpart to a PTE's constant
methods, and save writes it as a metadata.json member: names mapped to a
bool, number, string, or flat list of those. Package validates the member
at load and reads integers and integer lists by name; exir.native's
read_metadata reads it back in Python. LLM exports can then publish facts
the graph does not carry, such as the per-layer sliding windows of an
off-graph KV cache, under the names extension/llm/export/model_metadata.py
already defines.

This branch had an error being deployed

1 failed deployment
cadence — f387dc60 Deployed Nov 14, 2026 by metascroy via hifi-build / hifi4 #38326
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