Whether an optimizer wrapper should own ``param``: trainable, with at least one element. Frozen parameters have always been left out of the optimizer groups. A zero-element parameter is left out the same way: it has nothing to optimize, and binding it to a flat buffer loses its shape, b
(param)
| 888 | |
| 889 | |
| 890 | def is_optimized_parameter(param): |
| 891 | """Whether an optimizer wrapper should own ``param``: trainable, with at least one element. |
| 892 | |
| 893 | Frozen parameters have always been left out of the optimizer groups. A zero-element |
| 894 | parameter is left out the same way: it has nothing to optimize, and binding it to a flat |
| 895 | buffer loses its shape, because torch's ``unflatten_dense_tensors`` hands back a 1-D |
| 896 | ``zeros({0})`` for it. Checkpointing records such parameters with the frozen ones (see |
| 897 | ``DeepSpeedEngine._get_zero_frozen_param_attributes``) so they are rebuilt with their shape. |
| 898 | """ |
| 899 | numel = param.ds_numel if hasattr(param, "ds_numel") else param.numel() |
| 900 | return param.requires_grad and numel > 0 |
| 901 | |
| 902 | |
| 903 | def see_memory_usage(message, force=False): |
no test coverage detected