(param, ignore_status=False, name=None)
| 112 | |
| 113 | |
| 114 | def maybe_zero_3(param, ignore_status=False, name=None): |
| 115 | from deepspeed import zero |
| 116 | from deepspeed.runtime.zero.partition_parameters import ZeroParamStatus |
| 117 | if hasattr(param, "ds_id"): |
| 118 | if param.ds_status == ZeroParamStatus.NOT_AVAILABLE: |
| 119 | if not ignore_status: |
| 120 | logging.warning(f"{name}: param.ds_status != ZeroParamStatus.NOT_AVAILABLE: {param.ds_status}") |
| 121 | with zero.GatheredParameters([param]): |
| 122 | param = param.data.detach().cpu().clone() |
| 123 | else: |
| 124 | param = param.detach().cpu().clone() |
| 125 | return param |
| 126 | |
| 127 | |
| 128 | # Borrowed from peft.utils.get_peft_model_state_dict |
no outgoing calls
no test coverage detected