(model, exclude_module_name=['embed_tokens'], device=None)
| 17 | replace_parameters_by_name(child_module, name_keywords, device) |
| 18 | |
| 19 | def convert_model_weight_to_float8(model, exclude_module_name=['embed_tokens'], device=None): |
| 20 | for name, module in model.named_modules(): |
| 21 | flag = False |
| 22 | for _exclude_module_name in exclude_module_name: |
| 23 | if _exclude_module_name in name: |
| 24 | flag = True |
| 25 | if flag: |
| 26 | continue |
| 27 | for param_name, param in module.named_parameters(): |
| 28 | flag = False |
| 29 | for _exclude_module_name in exclude_module_name: |
| 30 | if _exclude_module_name in param_name: |
| 31 | flag = True |
| 32 | if flag: |
| 33 | continue |
| 34 | param.data = param.data.to(torch.float8_e4m3fn) |
| 35 | |
| 36 | def autocast_model_forward(cls, origin_dtype, *inputs, **kwargs): |
| 37 | weight_dtype = cls.weight.dtype |
no outgoing calls
no test coverage detected