Skip to content

Commit 7253531

Browse files
Fix ltxav te mem estimation. (Comfy-Org#12643)
1 parent e14b044 commit 7253531

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

comfy/text_encoders/lt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import torch
77
import comfy.utils
88
import math
9+
import itertools
910

1011
class T5XXLTokenizer(sd1_clip.SDTokenizer):
1112
def __init__(self, embedding_directory=None, tokenizer_data={}):
@@ -199,8 +200,10 @@ def memory_estimation_function(self, token_weight_pairs, device=None):
199200
constant /= 2.0
200201

201202
token_weight_pairs = token_weight_pairs.get("gemma3_12b", [])
202-
num_tokens = sum(map(lambda a: len(a), token_weight_pairs))
203-
num_tokens = max(num_tokens, 64)
203+
m = min([sum(1 for _ in itertools.takewhile(lambda x: x[0] == 0, sub)) for sub in token_weight_pairs])
204+
205+
num_tokens = sum(map(lambda a: len(a), token_weight_pairs)) - m
206+
num_tokens = max(num_tokens, 642)
204207
return num_tokens * constant * 1024 * 1024
205208

206209
def ltxav_te(dtype_llama=None, llama_quantization_metadata=None):

0 commit comments

Comments
 (0)