Skip to content

Commit 4f5b7db

Browse files
authored
Fix Aimdo fallback on probe to not use zero-copy sft (Comfy-Org#12634)
* utils: dont use comfy sft loader in aimdo fallback This was going to the raw command line switch and should respect main.py probe of whether aimdo actually loaded successfully. * ops: dont use deferred linear load in Aimdo fallback Avoid changes of behaviour on --fast dynamic_vram when aimdo doesnt work.
1 parent 3ebe1ac commit 4f5b7db

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

comfy/ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import torch
2020
import logging
2121
import comfy.model_management
22-
from comfy.cli_args import args, PerformanceFeature, enables_dynamic_vram
22+
from comfy.cli_args import args, PerformanceFeature
2323
import comfy.float
2424
import json
2525
import comfy.memory_management
@@ -296,7 +296,7 @@ class disable_weight_init:
296296
class Linear(torch.nn.Linear, CastWeightBiasOp):
297297

298298
def __init__(self, in_features, out_features, bias=True, device=None, dtype=None):
299-
if not comfy.model_management.WINDOWS or not enables_dynamic_vram():
299+
if not comfy.model_management.WINDOWS or not comfy.memory_management.aimdo_enabled:
300300
super().__init__(in_features, out_features, bias, device, dtype)
301301
return
302302

@@ -317,7 +317,7 @@ def __init__(self, in_features, out_features, bias=True, device=None, dtype=None
317317
def _load_from_state_dict(self, state_dict, prefix, local_metadata,
318318
strict, missing_keys, unexpected_keys, error_msgs):
319319

320-
if not comfy.model_management.WINDOWS or not enables_dynamic_vram():
320+
if not comfy.model_management.WINDOWS or not comfy.memory_management.aimdo_enabled:
321321
return super()._load_from_state_dict(state_dict, prefix, local_metadata, strict,
322322
missing_keys, unexpected_keys, error_msgs)
323323
assign_to_params_buffers = local_metadata.get("assign_to_params_buffers", False)

comfy/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from torch.nn.functional import interpolate
3030
from tqdm.auto import trange
3131
from einops import rearrange
32-
from comfy.cli_args import args, enables_dynamic_vram
32+
from comfy.cli_args import args
3333
import json
3434
import time
3535
import mmap
@@ -113,7 +113,7 @@ def load_torch_file(ckpt, safe_load=False, device=None, return_metadata=False):
113113
metadata = None
114114
if ckpt.lower().endswith(".safetensors") or ckpt.lower().endswith(".sft"):
115115
try:
116-
if enables_dynamic_vram():
116+
if comfy.memory_management.aimdo_enabled:
117117
sd, metadata = load_safetensors(ckpt)
118118
if not return_metadata:
119119
metadata = None

0 commit comments

Comments
 (0)