In this repo, is there any token length limit when using gemma in CLIPTextEncode node?
- User
In this repo, is there any token length limit when using gemma in
CLIPTextEncodenode? Assistant
I will investigate the repository to determine if there is a token length limit when using 'gemma' with the
CLIPTextEncodenode. I will search for relevant files in thecomfyandcomfy_api_nodesdirectories.Assistant
"Gemma" search results suggest
lumina2.pyandllama.pyhandle 'gemma' as text encoders, specificallyGemma2BTokenizerandGemma3_4BTokenizerinlumina2.pyhavemax_length=99999999, implying no tokenizer-level limit. I will now examinenodes.pyto see howCLIPTextEncodeuses these tokenizers and if any other component imposes a token limit.Assistant
CLIPTextEncodeis innodes.py. I'll read its class definition there to see how it handles token limits, especially for 'gemma'.Assistant
I've analyzed
CLIPTextEncodeinnodes.pyand observed itsencodemethod delegates tokenization and encoding to theclipobject'stokenizeandencode_from_tokens_scheduledmethods. Prior investigation of 'gemma' tokenizers (Gemma2BTokenizer,Gemma3_4BTokenizer) inlumina2.pyshowedmax_length=99999999, suggesting no explicit token limit there. Thus, theCLIPTextEncodenode and 'gemma' tokenizers don't impose an explicit token length limit, but hardware and memory constraints may cause an effective limit. I'll verify this by examiningclip.tokenizeto ensure no hidden limits.Assistant
Oops,
search_file_contentfailed due to a regex error. I need to fix the escape sequence:\.tokenize(should work for a literal search. Retrying.Assistant
I keep getting a regex error with
\.tokenize\. The problem is the trailing backslash. I'll usefixed_strings=Trueto search for the literal ".tokenize(" to avoid regex interpretation issues.Assistant
Okay,
tokenizeis called incomfy/sd.py, but I need its definition.CLIPTextEncodeusesclip.tokenize(), andGemma2BTokenizer/Gemma3_4BTokenizerinherit fromsd1_clip.SDTokenizer. Therefore, I'll search fortokenize's definition incomfy/sd1_clip.py.Assistant
I've analyzed
comfy/sd1_clip.pyand confirmedSDTokenizer.tokenize_with_weightshandles token batching.Gemma2BTokenizerandGemma3_4BTokenizer, used for "gemma" models, setmax_lengthto 99999999. This meansCLIPTextEncodewon't truncate "gemma" inputs; instead, it will process the entire text by splitting it into batches according to this very largemax_length. Therefore, there's no explicit token length truncation for "gemma" models; practical limits will stem from memory and processing capabilities.