MCPcopy Create free account
hub / github.com/tdrussell/diffusion-pipe / weights_to_device

Function weights_to_device

utils/offloading.py:114–119  ·  view source on GitHub ↗
(layer: nn.Module, device: torch.device)

Source from the content-addressed store, hash-verified

112
113
114def 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
122class Offloader:

Calls 1

toMethod · 0.45

Tested by

no test coverage detected