Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Always lift buffers when importing frozen programs#4658

Open
j2kun wants to merge 3 commits into
llvm:mainllvm/torch-mlir:mainfrom
j2kun:lift-and-freeze-state-dict-buffersj2kun/torch-mlir:lift-and-freeze-state-dict-buffersCopy head branch name to clipboard
Open

Always lift buffers when importing frozen programs#4658
j2kun wants to merge 3 commits into
llvm:mainllvm/torch-mlir:mainfrom
j2kun:lift-and-freeze-state-dict-buffersj2kun/torch-mlir:lift-and-freeze-state-dict-buffersCopy head branch name to clipboard

Conversation

@j2kun

@j2kun j2kun commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Reproduction: https://gist.github.com/j2kun/c2539e1fd9a7de0d10e9513cff0e989c

In fx_importer.py, import_frozen_program only lifts buffers from state_dict to inlined constants in the else block of if hasattr(prog, "constants"):

It should always lift these buffers since the program is frozen. I ran into this because I was exporting a torch model that had batch norms in it, and the batch norm parameters were left as (many many) function arguments when I wanted to freeze them from the values they got during training.

(Followed up from Discord)

@j2kun
j2kun requested a review from sahas3 July 17, 2026 17:19

@sahas3 sahas3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG.

The PyTorch version failure was just fixed in main. Can you rebase and rerun the CIs? Thanks!

Comment thread test/python/fx_importer/basic_test.py Outdated
Comment thread test/python/fx_importer/basic_test.py
j2kun and others added 2 commits July 23, 2026 14:58
@j2kun
j2kun force-pushed the lift-and-freeze-state-dict-buffers branch from 48b3f3d to dff6baa Compare July 23, 2026 21:59
@j2kun
j2kun enabled auto-merge (squash) July 23, 2026 22:01
@j2kun

j2kun commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

The failure is vs torch-nightly, not sure if that's blocking submission, as it doesn't seem related to the changes in this PR.

@sahas3

sahas3 commented Jul 24, 2026

Copy link
Copy Markdown
Member

All CIs need to be passing for merging the change.

It looks like some test in fx_importer config is failing. I think the stable branch only runs onnx (not sure why) -- so the failure is a real issue that needs to be fixed. Does this not reproduce locally?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.