slapo.initialization¶
Functions:
|
A context manager under which models are initialized with all parameters on the meta device, therefore creating an empty model. |
|
A context manager under which models are initialized with all parameters on the specified device. |
- slapo.initialization.init_empty_weights(enable=True, include_buffers=False)[source]¶
A context manager under which models are initialized with all parameters on the meta device, therefore creating an empty model. Useful when just initializing the model would blow the available RAM.
- Parameters
enable (bool) – Whether or not to enable this context manager.
include_buffers (bool) – Whether or not to also put all buffers on the meta device while initializing.
- slapo.initialization.init_on_device(device, include_buffers=False)[source]¶
A context manager under which models are initialized with all parameters on the specified device.
- Parameters
device (torch.device) – Device to initialize all parameters on.
include_buffers (bool) – Whether or not to also put all buffers on the meta device while initializing.