diffsynth-engine 0.4.3.dev2__py3-none-any.whl → 0.4.3.dev3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diffsynth_engine/utils/offload.py +10 -7
- {diffsynth_engine-0.4.3.dev2.dist-info → diffsynth_engine-0.4.3.dev3.dist-info}/METADATA +1 -1
- {diffsynth_engine-0.4.3.dev2.dist-info → diffsynth_engine-0.4.3.dev3.dist-info}/RECORD +6 -6
- {diffsynth_engine-0.4.3.dev2.dist-info → diffsynth_engine-0.4.3.dev3.dist-info}/WHEEL +0 -0
- {diffsynth_engine-0.4.3.dev2.dist-info → diffsynth_engine-0.4.3.dev3.dist-info}/licenses/LICENSE +0 -0
- {diffsynth_engine-0.4.3.dev2.dist-info → diffsynth_engine-0.4.3.dev3.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import torch
|
|
2
2
|
import torch.nn as nn
|
|
3
3
|
from typing import Dict
|
|
4
|
-
|
|
4
|
+
import platform
|
|
5
5
|
|
|
6
6
|
def enable_sequential_cpu_offload(module: nn.Module, device: str = "cuda"):
|
|
7
7
|
module = module.to("cpu")
|
|
@@ -26,13 +26,14 @@ def add_cpu_offload_hook(module: nn.Module, device: str = "cuda", recurse: bool
|
|
|
26
26
|
for name, buffer in module.named_buffers(recurse=recurse):
|
|
27
27
|
buffer.data = buffer.data.to(device=device)
|
|
28
28
|
return tuple(x.to(device=device) if isinstance(x, torch.Tensor) else x for x in input_)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
for name, param in module.named_parameters(recurse=recurse):
|
|
30
|
+
if platform.system() == 'Linux':
|
|
31
|
+
param.data = param.data.pin_memory()
|
|
32
32
|
offload_param_dict[name] = param.data
|
|
33
33
|
param.data = param.data.to(device=device)
|
|
34
34
|
for name, buffer in module.named_buffers(recurse=recurse):
|
|
35
|
-
|
|
35
|
+
if platform.system() == 'Linux':
|
|
36
|
+
buffer.data = buffer.data.pin_memory()
|
|
36
37
|
offload_param_dict[name] = buffer.data
|
|
37
38
|
buffer.data = buffer.data.to(device=device)
|
|
38
39
|
setattr(module, "_offload_param_dict", offload_param_dict)
|
|
@@ -58,10 +59,12 @@ def offload_model_to_dict(module: nn.Module) -> Dict[str, torch.Tensor]:
|
|
|
58
59
|
module = module.to("cpu")
|
|
59
60
|
offload_param_dict = {}
|
|
60
61
|
for name, param in module.named_parameters(recurse=True):
|
|
61
|
-
|
|
62
|
+
if platform.system() == 'Linux':
|
|
63
|
+
param.data = param.data.pin_memory()
|
|
62
64
|
offload_param_dict[name] = param.data
|
|
63
65
|
for name, buffer in module.named_buffers(recurse=True):
|
|
64
|
-
|
|
66
|
+
if platform.system() == 'Linux':
|
|
67
|
+
buffer.data = buffer.data.pin_memory()
|
|
65
68
|
offload_param_dict[name] = buffer.data
|
|
66
69
|
return offload_param_dict
|
|
67
70
|
|
|
@@ -162,14 +162,14 @@ diffsynth_engine/utils/image.py,sha256=_46CVs1Qe7GdZNulWWJISnR_Y6FotC2tZGLKtr04g
|
|
|
162
162
|
diffsynth_engine/utils/loader.py,sha256=Z5v1WNDWFY0OrVubB70j5VU3zeaAfEK_j8c1KrGI4yM,1240
|
|
163
163
|
diffsynth_engine/utils/lock.py,sha256=1Ipgst9eEFfFdViAvD5bxdB6HnHHBcqWYOb__fGaPUI,1601
|
|
164
164
|
diffsynth_engine/utils/logging.py,sha256=XB0xTT8PBN6btkOjFtOvjlrOCRVgDGT8PFAp1vmse28,467
|
|
165
|
-
diffsynth_engine/utils/offload.py,sha256=
|
|
165
|
+
diffsynth_engine/utils/offload.py,sha256=8dHMEzAQcE-GNbFYotGQg2YBBB0eywoRTIffVmK4A0k,3746
|
|
166
166
|
diffsynth_engine/utils/onnx.py,sha256=jeWUudJHnESjuiEAHyUZYUZz7dCj34O9aGjHCe8yjWo,1149
|
|
167
167
|
diffsynth_engine/utils/parallel.py,sha256=TtB6FzP2qo4VQqSenVnV-ZaKmp9xHaIWJ8D1ZjHtukE,17064
|
|
168
168
|
diffsynth_engine/utils/platform.py,sha256=2lXdw6YkqcRONCeT98n4cyg1Ii8Ybbyj2Ns72Se9tlk,496
|
|
169
169
|
diffsynth_engine/utils/prompt.py,sha256=YItMchoVzsG6y-LB4vzzDUWrkhKRVlt1HfVhxZjSxMQ,280
|
|
170
170
|
diffsynth_engine/utils/video.py,sha256=Ne0rd2lb59UT1q5EotpjlY7OT8F9oTCFDyo1ST77uoQ,1004
|
|
171
|
-
diffsynth_engine-0.4.3.
|
|
172
|
-
diffsynth_engine-0.4.3.
|
|
173
|
-
diffsynth_engine-0.4.3.
|
|
174
|
-
diffsynth_engine-0.4.3.
|
|
175
|
-
diffsynth_engine-0.4.3.
|
|
171
|
+
diffsynth_engine-0.4.3.dev3.dist-info/licenses/LICENSE,sha256=x7aBqQuVI0IYnftgoTPI_A0I_rjdjPPQkjnU6N2nikM,11346
|
|
172
|
+
diffsynth_engine-0.4.3.dev3.dist-info/METADATA,sha256=387bRGAkcA7KVuHnisJYZK8Sa2xlQMqJj6m-fG9vC8o,1110
|
|
173
|
+
diffsynth_engine-0.4.3.dev3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
174
|
+
diffsynth_engine-0.4.3.dev3.dist-info/top_level.txt,sha256=6zgbiIzEHLbhgDKRyX0uBJOV3F6VnGGBRIQvSiYYn6w,17
|
|
175
|
+
diffsynth_engine-0.4.3.dev3.dist-info/RECORD,,
|
|
File without changes
|
{diffsynth_engine-0.4.3.dev2.dist-info → diffsynth_engine-0.4.3.dev3.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{diffsynth_engine-0.4.3.dev2.dist-info → diffsynth_engine-0.4.3.dev3.dist-info}/top_level.txt
RENAMED
|
File without changes
|