Skip to content

Commit 7c80628

Browse files
authored
ops: apply the custom placeholder logic to Linux too (#15181)
Windows has proven this logic works for a long time and there are corner cases where this materialization actual consumes real RAM on linux. Its not as bad as the original windows commit charge surge, but its still a detectable transient leak. So simplify and unify.
1 parent de5625a commit 7c80628

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

comfy/ops.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,7 @@ class Linear(torch.nn.Linear, CastWeightBiasOp):
464464

465465
def __init__(self, in_features, out_features, bias=True, device=None, dtype=None):
466466
# don't trust subclasses that BYO state dict loader to call us.
467-
if (not comfy.model_management.WINDOWS
468-
or not comfy.memory_management.aimdo_enabled
467+
if (not comfy.memory_management.aimdo_enabled
469468
or type(self)._load_from_state_dict is not disable_weight_init.Linear._load_from_state_dict):
470469
super().__init__(in_features, out_features, bias, device, dtype)
471470
return
@@ -487,8 +486,7 @@ def __init__(self, in_features, out_features, bias=True, device=None, dtype=None
487486
def _load_from_state_dict(self, state_dict, prefix, local_metadata,
488487
strict, missing_keys, unexpected_keys, error_msgs):
489488

490-
if (not comfy.model_management.WINDOWS
491-
or not comfy.memory_management.aimdo_enabled
489+
if (not comfy.memory_management.aimdo_enabled
492490
or type(self)._load_from_state_dict is not disable_weight_init.Linear._load_from_state_dict):
493491
return super()._load_from_state_dict(state_dict, prefix, local_metadata, strict,
494492
missing_keys, unexpected_keys, error_msgs)
@@ -716,8 +714,7 @@ def __init__(self, num_embeddings, embedding_dim, padding_idx=None, max_norm=Non
716714
norm_type=2.0, scale_grad_by_freq=False, sparse=False, _weight=None,
717715
_freeze=False, device=None, dtype=None):
718716
# don't trust subclasses that BYO state dict loader to call us.
719-
if (not comfy.model_management.WINDOWS
720-
or not comfy.memory_management.aimdo_enabled
717+
if (not comfy.memory_management.aimdo_enabled
721718
or type(self)._load_from_state_dict is not disable_weight_init.Embedding._load_from_state_dict):
722719
super().__init__(num_embeddings, embedding_dim, padding_idx, max_norm,
723720
norm_type, scale_grad_by_freq, sparse, _weight,
@@ -744,8 +741,7 @@ def __init__(self, num_embeddings, embedding_dim, padding_idx=None, max_norm=Non
744741
def _load_from_state_dict(self, state_dict, prefix, local_metadata,
745742
strict, missing_keys, unexpected_keys, error_msgs):
746743

747-
if (not comfy.model_management.WINDOWS
748-
or not comfy.memory_management.aimdo_enabled
744+
if (not comfy.memory_management.aimdo_enabled
749745
or type(self)._load_from_state_dict is not disable_weight_init.Embedding._load_from_state_dict):
750746
return super()._load_from_state_dict(state_dict, prefix, local_metadata, strict,
751747
missing_keys, unexpected_keys, error_msgs)

0 commit comments

Comments
 (0)