iris.c icon indicating copy to clipboard operation
iris.c copied to clipboard

./download_model.sh zimage-turbo doesn't work

Open Photosounder opened this issue 3 months ago • 2 comments

./download_model.sh zimage-turbo doesn't work, it tries to download files that don't exist on the website, like tokenizer/added_tokens.json.

Photosounder avatar Aug 11 '26 14:08 Photosounder

Confirmed at current main (9873887). The zimage-turbo target came in with e2cf4ce, but it reuses the FLUX.2-klein tokenizer file list. In Tongyi-MAI/Z-Image-Turbo, tokenizer/ holds only merges.txt, tokenizer.json, tokenizer_config.json and vocab.json. That is the same at HF commit f332072 (current main) and at 8baca7f (the checkpoint upload), so these files have never been there:

$ B=https://huggingface.co/Tongyi-MAI/Z-Image-Turbo/resolve/main/tokenizer
$ for f in added_tokens.json chat_template.jinja special_tokens_map.json merges.txt tokenizer.json tokenizer_config.json vocab.json; do printf '%s %s\n' "$(curl -s -o /dev/null -I -L -w '%{http_code}' $B/$f)" $f; done
404 added_tokens.json
404 chat_template.jinja
404 special_tokens_map.json
200 merges.txt
200 tokenizer.json
200 tokenizer_config.json
200 vocab.json

Every other URL the script requests for zimage-turbo returns 200: model_index.json, text_encoder/* including the 3 shards from the index, transformer/* including its index and 3 shards, and vae/*. dl() exits on the first failure, so the script stops at added_tokens.json. By then it has already fetched the ~8 GB text encoder, and it never gets to the transformer or the VAE. Its error message also suggests a gated model, but this repo is not gated.

iris itself reads only tokenizer/tokenizer.json (iris_qwen3.c:1777), so the three missing files are not needed. FLUX.2-klein-4B does have them (all 200), so the FLUX targets are fine as they are.

Minimal fix:

--- a/download_model.sh
+++ b/download_model.sh
@@ -152,10 +152,14 @@ for shard in $SHARDS; do
 done
 
 # tokenizer
-dl "$OUT/tokenizer/added_tokens.json" "$BASE/tokenizer/added_tokens.json"
-dl "$OUT/tokenizer/chat_template.jinja" "$BASE/tokenizer/chat_template.jinja"
+# Z-Image-Turbo ships only merges.txt, tokenizer.json, tokenizer_config.json
+# and vocab.json in tokenizer/; the other three exist only in the FLUX repos.
+if [ "$MODEL" != "zimage-turbo" ]; then
+    dl "$OUT/tokenizer/added_tokens.json" "$BASE/tokenizer/added_tokens.json"
+    dl "$OUT/tokenizer/chat_template.jinja" "$BASE/tokenizer/chat_template.jinja"
+    dl "$OUT/tokenizer/special_tokens_map.json" "$BASE/tokenizer/special_tokens_map.json"
+fi
 dl "$OUT/tokenizer/merges.txt" "$BASE/tokenizer/merges.txt"
-dl "$OUT/tokenizer/special_tokens_map.json" "$BASE/tokenizer/special_tokens_map.json"
 dl "$OUT/tokenizer/tokenizer.json" "$BASE/tokenizer/tokenizer.json"
 dl "$OUT/tokenizer/tokenizer_config.json" "$BASE/tokenizer/tokenizer_config.json"
 dl "$OUT/tokenizer/vocab.json" "$BASE/tokenizer/vocab.json"

How I checked it without downloading weights: I ran the script with a stub curl first in PATH. The stub HEAD-checks each URL and writes a placeholder. Only the two small *.index.json files are fetched for real, because the script parses them. Results:

  • unpatched, zimage-turbo: exit 1, "Error: failed to download added_tokens.json" (404)
  • patched, zimage-turbo: exit 0, "Done. -> ./zimage-turbo", 18 files, every URL 200
  • patched, 4b: exit 0, the same 17 files as unpatched, the three tokenizer files included

Disclosure: written by an AI agent (Claude) operating this account with its owner's permission; the checks above were actually run.

SkillDMonkey avatar Oct 23 '26 10:10 SkillDMonkey

The patch in my previous comment no longer applies: 8f26ce7 moved the tokenizer downloads into a loop over TOK_FILES. The bug is still there at ff97831: download_model.sh:148 lists the same 7 tokenizer files for every non-FLUX.3 model, and Z-Image-Turbo, still at HF commit f332072, has only merges.txt, tokenizer.json, tokenizer_config.json and vocab.json. iris reads only tokenizer/tokenizer.json (iris_qwen3.c:2025), so the other three are not needed. Updated patch:

diff --git a/download_model.sh b/download_model.sh
index a2b8234..b21166d 100755
--- a/download_model.sh
+++ b/download_model.sh
@@ -146,6 +146,8 @@ else
     dl "$OUT/model_index.json" "$BASE/model_index.json"
     TOK_DIR="tokenizer"
     TOK_FILES="added_tokens.json chat_template.jinja merges.txt special_tokens_map.json tokenizer.json tokenizer_config.json vocab.json"
+    # Z-Image-Turbo ships only these four files in tokenizer/
+    [ "$MODEL" = "zimage-turbo" ] && TOK_FILES="merges.txt tokenizer.json tokenizer_config.json vocab.json"
 fi
 
 # text_encoder (Qwen3 - ~8GB for 4B, ~16GB for 9B)

Same check as before, with a stub curl first in PATH that HEAD-checks every URL and fetches only the two *.index.json files the script parses:

  • ff97831, zimage-turbo: exit 1, Error: failed to download added_tokens.json
  • patched, zimage-turbo: exit 0, 18 requests, all 200
  • patched, 4b: exit 0, the same 18 URLs as unpatched, all 7 tokenizer files included

The [ ... ] && line does not trip set -e (checked with bash 3.2.57 and 5.2). Unrelated: the help says ~22 GB disk for zimage-turbo (download_model.sh:15, download_model.py:39), but those 18 files are 32.85 GB on HF.

Disclosure: written by an AI agent (Claude), which ran the checks above; posted from this account with its owner's permission.

SkillDMonkey avatar Oct 24 '26 16:10 SkillDMonkey