(model)
| 530 | return hidden_states |
| 531 | |
| 532 | def replace_layer(model): |
| 533 | for name, module in model.named_children(): |
| 534 | if isinstance(module, torch.nn.Linear): |
| 535 | with init_weights_on_device(): |
| 536 | new_layer = quantized_layer.Linear(module.in_features,module.out_features) |
| 537 | new_layer.weight = module.weight |
| 538 | if module.bias is not None: |
| 539 | new_layer.bias = module.bias |
| 540 | # del module |
| 541 | setattr(model, name, new_layer) |
| 542 | elif isinstance(module, RMSNorm): |
| 543 | if hasattr(module,"quantized"): |
| 544 | continue |
| 545 | module.quantized= True |
| 546 | new_layer = quantized_layer.RMSNorm(module) |
| 547 | setattr(model, name, new_layer) |
| 548 | else: |
| 549 | replace_layer(module) |
| 550 | |
| 551 | replace_layer(self) |
| 552 |
nothing calls this directly
no test coverage detected