(layer: nn.Module, device: torch.device)
| 112 | |
| 113 | |
| 114 | def weights_to_device(layer: nn.Module, device: torch.device): |
| 115 | for name, module in layer.named_modules(): |
| 116 | if device.type == 'cpu' and 'lora' in name: |
| 117 | continue |
| 118 | if hasattr(module, "weight") and module.weight is not None: |
| 119 | module.weight.data = module.weight.data.to(device, non_blocking=True) |
| 120 | |
| 121 | |
| 122 | class Offloader: |
no test coverage detected