(module_obj: Any)
| 27 | |
| 28 | |
| 29 | def fix_upgrade(module_obj: Any): |
| 30 | from transformers import PreTrainedModel |
| 31 | if hasattr(module_obj, '_set_gradient_checkpointing') \ |
| 32 | and 'value' in inspect.signature( |
| 33 | module_obj._set_gradient_checkpointing).parameters.keys() \ |
| 34 | and 'modelscope.' in str(module_obj.__class__): |
| 35 | module_obj._set_gradient_checkpointing = MethodType( |
| 36 | PreTrainedModel._set_gradient_checkpointing, module_obj) |
| 37 | |
| 38 | |
| 39 | def post_init(self, *args, **kwargs): |