Skip to content

Missing / Unexpected key(s) when loading a checkpoint from a compiled model #17415

Open
@konstantinjdobler

Description

@konstantinjdobler

Bug description

When loading a checkpoint that was compiled using torch.compile on a using

model = LitModel.load_from_checkpoint(...)

...

#later on
model.submodule = torch.compile(model.submodule)

I am getting missing key(s) and unexpected key(s) errors. Specifically, all the model keys are "missing" and instead there are "unexpected" keys where the compiled module is replaced by _orig_mod. Is it just not possible to load a checkpoint from a checkpoint containing a compiled module? Going into the checkpoint and replacing the keys by the correct value is not hard, but inconvenient.

I have not tested whether compiling the entire LightningModule works (perhaps it is just a legitimate limitation that lightning cannot know whether a submodule was compiled or not).

What version are you seeing the problem on?

lightning==2.0.0

cc @Borda @carmocca

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfeatureIs an improvement or enhancementtorch.compile

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions