From 8b7e4d3da4481fd896b05464749c84eae4a3ae77 Mon Sep 17 00:00:00 2001 From: "Mark D. Adams" Date: Sat, 5 Sep 2026 12:02:28 -0700 Subject: [PATCH] Fix KeyError: 'default_num_special_tokens' when recreating Tekken tokenizer ### Problem When loading Mistral-based GGUF text encoders via `CLIPLoaderGGUF` (specifically tested with `Mistral-Small-3.2-24B-Instruct-2506-UD-Q8_K_XL.gguf` for FLUX.2 workflows), ComfyUI core crashes during tokenizer initialization: ```text File "ComfyUI/comfy/text_encoders/bpe_tokenizer.py", line 271, in from_tekken_json special_token_offset = config["default_num_special_tokens"] KeyError: 'default_num_special_tokens' --- loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loader.py b/loader.py index 7cefb11..ca617c8 100644 --- a/loader.py +++ b/loader.py @@ -395,7 +395,7 @@ def gguf_tekken_tokenizer_loader(path, temb_shape): if model_str == "gpt2": if temb_shape == (131072, 5120): # probably Mistral data = { - "config": {"num_vocab_tokens": 150000, "default_vocab_size": 131072}, + "config": {"num_vocab_tokens": 150000, "default_vocab_size": 131072, "default_num_special_tokens": 1000}, "vocab": [], "special_tokens": [], }