Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lightx2v/models/runners/hunyuan_image3/hunyuan_image3_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,25 @@ def _ensure_pipeline_modules(self):
except OSError:
self.hunyuan_generation_config = GenerationConfig()

tokenizer_kwargs = {}
tokenizer_json_path = Path(model_path) / "tokenizer.json"
if tokenizer_json_path.is_file():
# Transformers 5.x may rebuild this custom fast tokenizer from
# partial metadata and silently drop its ByteLevel decoder. Load
# the serialized backend explicitly to preserve the checkpoint's
# original BPE encoding and decoding behavior.
from tokenizers import Tokenizer

tokenizer_kwargs["tokenizer_object"] = Tokenizer.from_file(str(tokenizer_json_path))

self.hunyuan_tokenizer = modules["HunyuanImage3TokenizerFast"].from_pretrained(
model_path,
model_version=self.hunyuan_config.model_version,
**tokenizer_kwargs,
)

if tokenizer_json_path.is_file() and self.hunyuan_tokenizer.backend_tokenizer.decoder is None:
raise RuntimeError(f"Failed to preserve the ByteLevel tokenizer backend from {tokenizer_json_path}. Refusing to continue because prompt encoding and COT decoding would be corrupted.")
self.hunyuan_image_processor = modules["HunyuanImage3ImageProcessor"](self.hunyuan_config)
# Newer transformers versions alias Siglip2ImageProcessorFast to the
# slow processor, whose default output is a Python list. The upstream
Expand Down
Loading