This PR addresses the problem of loading the full DINGO model just to get access to its metadata.
PyTorch provides the option of loading a model to the "meta" device which allows users to load a representation of the model without loading the actual parameters into memory. As a result, we can access the metadata of the model with lower memory requirements than before.
The model is loaded to map_location="meta"
at the beginning of dingo_pipe where model.metadata is accessed
in ls_cli.py where the model.metadata is extracted.
Loading the model to map_location="meta" requires changes to dingo/core/models/posterior_model.py since operations like model.to(device) and model.load_state_dict(d["model_state_dict"]) cannot be performed for a model on "meta" devices.
This PR was tested on the NPE tutorial example and runs without problems.
This PR addresses the problem of loading the full DINGO model just to get access to its metadata. PyTorch provides the option of loading a model to the "meta" device which allows users to load a representation of the model without loading the actual parameters into memory. As a result, we can access the metadata of the model with lower memory requirements than before.
The model is loaded to
map_location="meta"
dingo_pipe
wheremodel.metadata
is accessedls_cli.py
where themodel.metadata
is extracted.Loading the model to
map_location="meta"
requires changes todingo/core/models/posterior_model.py
since operations likemodel.to(device)
andmodel.load_state_dict(d["model_state_dict"])
cannot be performed for a model on "meta" devices.This PR was tested on the NPE tutorial example and runs without problems.