Precision¶
- class lightning_fabric.plugins.precision.Precision[source]¶
Bases:
object
Base class for all plugins handling the precision-specific parts of the training.
The class attribute precision must be overwritten in child classes. The default value reflects fp32 training.
- convert_input(data)[source]¶
Convert model inputs (forward) to the floating point precision type of this plugin.
This is a no-op for tensors that are not of floating-point type or already have the desired type.
- Return type
- convert_module(module)[source]¶
Convert the module parameters to the precision type this plugin handles.
This is optional and depends on the precision limitations during optimization.
- Return type
- forward_context()[source]¶
A contextmanager for managing model forward/training_step/evaluation_step/predict_step.
- load_state_dict(state_dict)[source]¶
Called when loading a checkpoint, implement to reload precision plugin state given precision plugin state_dict.
- main_params(optimizer)[source]¶
The main params of the model.
Returns the plain model params here. Maybe different in other precision plugins.