From 14f4e7ef7ccfec44121dac7a19afda9a3cd3be99 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sun, 5 Jul 2026 05:32:24 +0000 Subject: [PATCH] Keep standalone chat templates in the scoped video download tokenizer/chat_template.jinja ships as its own file in the LTX-2 and HunyuanVideo-1.5 repos and apply_chat_template reads it at generation time, so a scoped snapshot without it loads fine and then crashes the first generation. --- studio/backend/core/inference/video.py | 6 +++++- studio/backend/tests/test_video_backend.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/studio/backend/core/inference/video.py b/studio/backend/core/inference/video.py index 3b64e37dca..dcdbb863bb 100644 --- a/studio/backend/core/inference/video.py +++ b/studio/backend/core/inference/video.py @@ -406,7 +406,11 @@ class VideoBackend: files: list[tuple[str, int]] = [] for sibling in info.siblings or []: name, size = sibling.rfilename, sibling.size or 0 - if not name.endswith((".safetensors", ".json", ".model", ".txt")): + # .jinja: tokenizer/chat_template.jinja ships as a standalone file in the + # LTX-2 and HunyuanVideo-1.5 repos (not embedded in tokenizer_config.json) + # and apply_chat_template needs it at generation time, so a snapshot + # without it loads fine and then crashes the first generation. + if not name.endswith((".safetensors", ".json", ".model", ".txt", ".jinja")): continue if "/" not in name and name.endswith(".safetensors"): continue diff --git a/studio/backend/tests/test_video_backend.py b/studio/backend/tests/test_video_backend.py index 30cbacdee0..edb0a41bbb 100644 --- a/studio/backend/tests/test_video_backend.py +++ b/studio/backend/tests/test_video_backend.py @@ -459,6 +459,7 @@ _LTX2_SIBLINGS = [ _sibling("text_encoder/diffusion_pytorch_model-00002-of-00002.safetensors", 25), _sibling("vae/diffusion_pytorch_model.safetensors", 3), _sibling("tokenizer/tokenizer.model", 1), + _sibling("tokenizer/chat_template.jinja", 1), _sibling("assets/example.mp4", 500), ] @@ -473,7 +474,10 @@ def test_base_download_files_scopes_pipeline_pull(): assert "assets/example.mp4" not in files assert files["text_encoder/model-00001-of-00002.safetensors"] == 25 assert files["transformer/diffusion_pytorch_model-00001-of-00002.safetensors"] == 20 - assert sum(files.values()) == 10 + 1 + 20 + 18 + 25 + 25 + 3 + 1 + # The standalone chat template must survive the whitelist: apply_chat_template + # reads it at generation time and it is not embedded in tokenizer_config.json. + assert "tokenizer/chat_template.jinja" in files + assert sum(files.values()) == 10 + 1 + 20 + 18 + 25 + 25 + 3 + 1 + 1 def test_base_download_files_gguf_drops_transformer():