Skip to content

[Native] Run the HF LLM export on newer transformers - #24946

Draft
metascroy wants to merge 1 commit into
offgraph-kv-mg-opsfrom
offgraph-kv-transformers-compat
Draft

metascroy wants to merge 1 commit into
offgraph-kv-mg-opsfrom
offgraph-kv-transformers-compat

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

export_hf_llm.py failed to import on newer transformers, which no longer re-exports accelerate's init_empty_weights.

  • GGUF-loaded models are built with a local context that puts parameters on the meta device and leaves buffers on the CPU, as init_empty_weights did. A plain meta device would also empty computed buffers such as RoPE frequencies.
  • dtype replaces the deprecated torch_dtype.
  • Newer StaticLayer.lazy_initialization also takes the value states, so the FP16 KV cache passes them where the signature asks.
  • Tests cover both versions: the GGUF mapping test uses eager attention (newer sdpa rejects Gemma 2's softcap), and the FP16 sliding-window rejection test skips where transformers keeps sliding layers in StaticLayer and windows them through the mask.

Test plan

test_export_hf_llm.py passes with transformers 5.0.0rc1 (the examples pin) and 5.22.2.


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/24946

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

❌ 133 New Failures, 8 Unrelated Failures, 10 Unclassified Failures

As of commit c399e30 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
transformers no longer re-exports accelerate's init_empty_weights, so
export_hf_llm failed to import. Build GGUF-loaded models with a local context
that puts parameters on the meta device and leaves buffers on the CPU, as
init_empty_weights did; a plain meta device would also empty computed buffers
such as RoPE frequencies. Pass dtype rather than the deprecated torch_dtype.

Newer StaticLayer.lazy_initialization also takes the value states, so the FP16
KV cache passes them where the signature asks. The tests cover both versions:
the GGUF mapping test uses eager attention, since newer sdpa rejects Gemma 2's
softcap, and the FP16 sliding-window rejection test skips where transformers
keeps sliding layers in StaticLayer and windows them through the mask.

Tested with transformers 5.0.0rc1 and 5.22.2.

This branch had an error being deployed

1 failed deployment
cadence — c399e304 Deployed Nov 14, 2026 by metascroy via hifi1s-build / hifi1s #38335
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