tabensemb.model.AbstractNN.from_compiled#

method

classmethod AbstractNN.from_compiled(model: torch._dynamo.OptimizedModule) pl.LightningModule#

Returns an instance LightningModule from the output of torch.compile.

The torch.compile function returns a torch._dynamo.OptimizedModule, which wraps the LightningModule passed in as an argument, but doesn’t inherit from it. This means that the output of torch.compile behaves like a LightningModule but it doesn’t inherit from it (i.e. isinstance will fail).

Use this method to obtain a LightningModule that still runs with all the optimizations from torch.compile.