The parameter's shape as a layer, rather than as a ZeRO-3 partition. Under ``deepspeed.zero.Init`` a partitioned parameter's data is a flat placeholder - ``torch.Size([0])`` on the ranks that do not hold it - and the shape it has as a layer is recorded as ``ds_shape``. Reading ``param.s
(param: torch.Tensor)
| 343 | |
| 344 | |
| 345 | def _layer_shape(param: torch.Tensor): |
| 346 | """The parameter's shape as a layer, rather than as a ZeRO-3 partition. |
| 347 | |
| 348 | Under ``deepspeed.zero.Init`` a partitioned parameter's data is a flat placeholder - |
| 349 | ``torch.Size([0])`` on the ranks that do not hold it - and the shape it has as a layer is |
| 350 | recorded as ``ds_shape``. Reading ``param.shape`` there sees a 1-D tensor for every |
| 351 | parameter in the model. |
| 352 | """ |
| 353 | ds_shape = getattr(param, "ds_shape", None) |
| 354 | return tuple(param.shape) if ds_shape is None else tuple(ds_shape) |
| 355 | |
| 356 | |
| 357 | def set_optimizer_flags(config_class: DeepSpeedConfig, model: torch.nn.Module) -> None: |
no outgoing calls
no test coverage detected