[GH-ISSUE #27] server.py uses the Qwen pre-tokenizer for GLM, so numbers get split into single digits #12

Closed
opened 2026-10-29 21:19:06 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @mab776 on GitHub (Oct 8, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/27

In my needle-in-a-haystack test with long prompts, Maya-S and Maya-M were giving me garbled numbers back (504 → 5504, 696 → 6969). It's fine at 8k and broken from ~12–20k, on every quant and config I tried.

Cause: serve/server.py builds ST.Tokenizer(tokens, merges, types) without pre=, so it defaults to qwen35 and splits every number into single digits. GLM uses 1–3 digit groups, and the pack's tokenizer.json already says "pre": "glm4". Against the official tokenizer, 504 = 50|4 vs Maya's 5|0|4, and a 32k prompt is 29,241 vs 30,646 tokens.

Fix:

meta = json.loads((tpath / "tokenizer.json").read_text()) if (tpath / "tokenizer.json").exists() else {}
tok = ST.Tokenizer(tokens, merges, types, pre=meta.get("pre", "qwen35"),
                   special_ids=meta.get("special_ids") or None)

With it the encoding matches the official tokenizer, and the needles went to 6/6 exact at 32k and 128k (Maya-S, v1.0.12).

Originally created by @mab776 on GitHub (Oct 8, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/27 In my needle-in-a-haystack test with long prompts, Maya-S and Maya-M were giving me garbled numbers back (`504` → `5504`, `696` → `6969`). It's fine at 8k and broken from ~12–20k, on every quant and config I tried. Cause: `serve/server.py` builds `ST.Tokenizer(tokens, merges, types)` without `pre=`, so it defaults to `qwen35` and splits every number into single digits. GLM uses 1–3 digit groups, and the pack's `tokenizer.json` already says `"pre": "glm4"`. Against the official tokenizer, `504` = `50|4` vs Maya's `5|0|4`, and a 32k prompt is 29,241 vs 30,646 tokens. Fix: ```python meta = json.loads((tpath / "tokenizer.json").read_text()) if (tpath / "tokenizer.json").exists() else {} tok = ST.Tokenizer(tokens, merges, types, pre=meta.get("pre", "qwen35"), special_ids=meta.get("special_ids") or None) ``` With it the encoding matches the official tokenizer, and the needles went to 6/6 exact at 32k and 128k (Maya-S, v1.0.12).
Author
Owner

@mw00 commented on GitHub (Oct 8, 2026):

Thank you! A real bug, found and diagnosed exactly. Fixed in v1.0.15 and credited to you.

  • strata_tokenizer.Tokenizer.from_dir() now reads the pack's tokenizer/ with the pre and special ids from its tokenizer.json, as in your fix. The server, --bench and the detokenizer test all build their tokenizer through it, so the qwen35 default can't sneak back in at one of them.
  • On the Maya-S pack, 504 is now 50|4 and 696 is 6|96; 12345 is 123|45. The old path gave one digit a token.
  • New tests: a GLM pack's directory gets glm4 and its digit grouping, and a directory without tokenizer.json keeps qwen35.
  • Nothing to redo after updating: the setup has always written "pre": "glm4" into the pack.
<!-- gh-comment-id:6069345855 --> @mw00 commented on GitHub (Oct 8, 2026): Thank you! A real bug, found and diagnosed exactly. Fixed in [v1.0.15](https://github.com/mw00/project-maya/releases/tag/v1.0.15) and credited to you. - `strata_tokenizer.Tokenizer.from_dir()` now reads the pack's `tokenizer/` with the `pre` and special ids from its `tokenizer.json`, as in your fix. The server, `--bench` and the detokenizer test all build their tokenizer through it, so the qwen35 default can't sneak back in at one of them. - On the Maya-S pack, `504` is now `50|4` and `696` is `6|96`; `12345` is `123|45`. The old path gave one digit a token. - New tests: a GLM pack's directory gets `glm4` and its digit grouping, and a directory without `tokenizer.json` keeps `qwen35`. - Nothing to redo after updating: the setup has always written `"pre": "glm4"` into the pack.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#12
No description provided.