(self, checkpoint, strict=True, custom_load_fn=None)
| 2467 | moe_layer_id += 1 |
| 2468 | |
| 2469 | def load_module_state_dict(self, checkpoint, strict=True, custom_load_fn=None): |
| 2470 | module_state_dict = checkpoint['module'] |
| 2471 | if custom_load_fn: |
| 2472 | custom_load_fn(src=module_state_dict, dst=self.module) |
| 2473 | else: |
| 2474 | self.module.load_state_dict( |
| 2475 | module_state_dict, # TODO |
| 2476 | strict=strict) |
| 2477 | |
| 2478 | if checkpoint.get(FROZEN_PARAM_FRAGMENTS, None) is not None: |
| 2479 | saved_frozen_params = checkpoint[FROZEN_PARAM_FRAGMENTS] |
| 2480 | for param in self.module.parameters(): |
| 2481 | if param.requires_grad: |
| 2482 | continue |
| 2483 | if param not in self.param_names: |
| 2484 | raise ValueError(f"failed to find frozen {param} in named params") |
| 2485 | name = self.param_names[param] |
| 2486 | if hasattr(param, 'ds_id'): |
| 2487 | param.ds_tensor.data.copy_(saved_frozen_params[name].data) |
| 2488 | else: |
| 2489 | param.data.copy_(saved_frozen_params[name].data) |
| 2490 | |
| 2491 | def _get_zero_ckpt_prefix(self, dp_rank, bf16_mode): |
| 2492 | return f'{"bf16_" if bf16_mode else ""}zero_pp_rank_{dp_rank}' |
no test coverage detected