(model: Union[torch.nn.Module, List[torch.nn.Module]], dtype=torch.float32)
| 137 | |
| 138 | |
| 139 | def cast_training_params(model: Union[torch.nn.Module, List[torch.nn.Module]], dtype=torch.float32): |
| 140 | if not isinstance(model, list): |
| 141 | model = [model] |
| 142 | for m in model: |
| 143 | for param in m.parameters(): |
| 144 | # only upcast trainable parameters into fp32 |
| 145 | if param.requires_grad: |
| 146 | param.data = param.to(dtype) |
| 147 | |
| 148 | |
| 149 | def _set_state_dict_into_text_encoder( |
no test coverage detected