Skip to content

fix: Qwen3.8 Flash Next and 27B on EXL3 checkpoints stop at the end of the chat turn - #69

Closed
vcruz305 wants to merge 2 commits into
ashhart:mainfrom
vcruz305:fix/exl3-stop-ids
Closed

vcruz305 wants to merge 2 commits into
ashhart:mainfrom
vcruz305:fix/exl3-stop-ids

Conversation

@vcruz305

Copy link
Copy Markdown
Contributor

On EXL3 checkpoints of Qwen3.8 Flash Next and Qwen3.8-27B, the CUDA engine does not stop a reply at the end of the chat turn. It reads its stop ids from config.json only: the top-level eos_token_id, else text_config's. These packs have no top-level id, and text_config names only <|endoftext|> (248044). The turn's end, <|im_end|> (248046), is listed in generation_config.json alone.

So on 0.3.6.1, Config.read returns (248044,) for turboderp's Flash Next pack (3.05bpw_h5_ng5), for the SAGE Flash Next packs I serve (4.15 bpw, and CYBER-FROST-3.8 at 3.5 bpw), and for turboderp's 27B packs at 3.00 and 4.00 bpw. The MLX checkpoints are fine because they list both ids at the top level.

On one DGX Spark (GB10), CYBER-FROST-3.8-EXL3-SAGE-3.5bpw served on 0.3.6 with a ~16k-token prompt, thinking on and a get_weather tool request streamed <|im_end|>\n<|im_start|>user... as content, called the tool three times and leaked <think> into the answer.

The change

Both families' Config.read now add generation_config.json's eos_token_id after config.json's, in order and without duplicates. A checkpoint that names no stop id anywhere raises a ValueError instead of failing later.

  • families/qwen4_exp/cuda/weights.py: a small stop_ids() helper, used by Config.read.
  • families/qwen3_5/cuda/weights.py: the same logic inline in Config.read.
  • tests/test_flashnext_eos.py and tests/test_qwen27b_eos.py: CPU tests with synthetic configs for the EXL3 layout, the MLX layout, no generation_config.json, scalar values, and no id at all.

ple_eos (the n-gram tables' end id) still comes from text_config, so the Flash Next n-gram path reads the same id as before.

Checked

Against the real configs on disk, with this branch at 0.3.6.1, Config.read returns:

Checkpoint Before After
turboderp Qwen3.8-Flash-Next-exl3, 3.05bpw_h5_ng5 (248044,) (248044, 248046)
Flash Next SAGE 4.15 bpw EXL3 (248044,) (248044, 248046)
CYBER-FROST-3.8-EXL3-SAGE-3.5bpw (248044,) (248044, 248046)
turboderp Qwen3.8-27B-exl3, 3.00bpw (248044,) (248044, 248046)
turboderp Qwen3.8-27B-exl3, 4.00bpw (248044,) (248044, 248046)
Flash Next MLX 4-bit (248046, 248044) (248046, 248044)
Vontra Qwen3.8-27B-MLX-4bit (248046, 248044) (248046, 248044)

The new tests pass along with tests/test_cuda_cli.py and tests/test_cuda_build.py (26 tests, CPU).

End to end on the Spark with the Flash Next change: CYBER-FROST served on 0.3.6 with the same ~16k-token thinking-on prompt and tool request now returns one get_weather call with finish_reason: tool_calls, and no leaked tags. Its token hash matches 0.3.6 serving a copy of the pack whose config.json lists both ids.

Not claimed

  • I did not serve a 27B EXL3 request end to end. The 27B change is checked by the config reads above and the CPU tests, and it is the same logic as the Flash Next change.
  • GLM-5.3-Flash is not changed and not affected: its loader reads text_config first, and Mia-AiLab's EXL3 checkpoint lists its three stop ids there.
  • Stop ids are the only change. Drafting and exactness are untouched. Drafted and serial replies were not re-checked on this exact branch, but the Flash Next change gave drafted equal to serial 3/3 on 0.3.6.

Overlap

The CUDA engine took its stop ids from config.json: the top-level eos_token_id, else
text_config's. EXL3 packs of Flash Next (turboderp 3.05bpw_h5_ng5, CYBER-FROST SAGE 3.5 bpw)
have no top-level id, and text_config names <|endoftext|> (248044) only; the turn's end,
<|im_end|> (248046), is listed in generation_config.json alone. Served chat replies ran
past their turn: a thinking-on tool request streamed "<|im_end|>\n<|im_start|>user..." as
content, repeated the call three times and leaked <think> into the answer.

Config.read now adds generation_config.json's eos_token_id to config.json's, in order and
without duplicates. The MLX checkpoint, whose top level already lists both, is unchanged.
The 27B's CUDA Config took its stop ids from config.json only, as Flash Next's did.
turboderp's 27B EXL3 packs (3.00 and 4.00 bpw) have no top-level eos_token_id and
text_config names <|endoftext|> (248044) only, so Config.read returned (248044,) and
<|im_end|> (248046), which these packs list in generation_config.json alone, did not end a
reply. The MLX 4-bit checkpoint lists both at the top level and reads (248046, 248044), as
before.

Config.read now adds generation_config.json's eos_token_id after config.json's, in order and
without duplicates, and a checkpoint that names no stop id anywhere fails with a clear error.
GLM-5.3-Flash is not affected: its EXL3 checkpoint lists its three stop ids in text_config,
which its loader reads first.
@ashhart

ashhart commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Thank you, @vcruz305. This shipped in 0.3.6.2 under your name (e5d3a2ae, 57028f34). Flash Next and 27B EXL3 packs now stop at
<|im_end|>, read from generation_config.json, and the MLX checkpoints read the same ids as before. We made one change:
the Flash Next test now skips on machines without Triton, which Flash Next's CUDA weights import. A great catch from a
long overnight run, and a clean fix. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

landed Landed on main by the maintainers; the commits keep the contributor's authorship

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants