Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

memory: Add more exclusion criteria to pinned read (#13067)

rattusab14541ef796
diff --git a/comfy/memory_management.py b/comfy/memory_management.py
index 563224098..f9078fe7c 100644
--- a/comfy/memory_management.py
+++ b/comfy/memory_management.py
@@ -39,7 +39,10 @@ def read_tensor_file_slice_into(tensor, destination):
if (destination.device.type != "cpu"
or file_obj is None
or threading.get_ident() != info.thread_id
- or destination.numel() * destination.element_size() < info.size):
+ or destination.numel() * destination.element_size() < info.size
+ or tensor.numel() * tensor.element_size() != info.size
+ or tensor.storage_offset() != 0
+ or not tensor.is_contiguous()):
return False
if info.size == 0: