Skip to content

Commit bcf1a1f

Browse files
authored
mm: reset_cast_buffers: sync compute stream before free (#12822)
Sync the compute stream before freeing the cast buffers. This can cause use after free issues when the cast stream frees the buffer while the compute stream is behind enough to still needs a casted weight.
1 parent 6ac8152 commit bcf1a1f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

comfy/model_management.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,7 @@ def reset_cast_buffers():
11481148
LARGEST_CASTED_WEIGHT = (None, 0)
11491149
for offload_stream in STREAM_CAST_BUFFERS:
11501150
offload_stream.synchronize()
1151+
synchronize()
11511152
STREAM_CAST_BUFFERS.clear()
11521153
soft_empty_cache()
11531154

0 commit comments

Comments
 (0)