From bc388f8ffa2863eec919a2bd6bbfc78188265504 Mon Sep 17 00:00:00 2001 From: tdrussell <6509934+tdrussell@users.noreply.github.com> Date: Wed, 16 Apr 2025 13:42:36 -0500 Subject: [PATCH] [HiDream] Hard-cap T5 embeddings to 128 length --- comfy/text_encoders/hidream.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/comfy/text_encoders/hidream.py b/comfy/text_encoders/hidream.py index af105f9bb..275fc47c0 100644 --- a/comfy/text_encoders/hidream.py +++ b/comfy/text_encoders/hidream.py @@ -108,6 +108,8 @@ class HiDreamTEModel(torch.nn.Module): if self.t5xxl is not None: t5_output = self.t5xxl.encode_token_weights(token_weight_pairs_t5) t5_out, t5_pooled = t5_output[:2] + # Quality rapidly degrades if T5 embeddings are >128 length. Llama3 is not as bad, so we allow that one to be longer. + t5_out = t5_out[:, :128, :] if self.llama is not None: ll_output = self.llama.encode_token_weights(token_weight_pairs_llama)