[GH-ISSUE #273] EXL3 quant: long thinking loops run to max_tokens #102

Closed
opened 2026-10-29 21:20:50 +07:00 by bsakaguchi · 4 comments
Owner

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

Setup

  • Project Maya v1.1.15, upstream release, engine compiled from the v1.1.15 checkout
  • Model: GLM-5.3-Flash, turboderp's EXL3 quant at 3.05 bits per weight, MTP draft block
  • Context 262144
  • Client talks to the OpenAI-compatible API, streaming

What happens

I run multi-turn coding-agent sessions through the API. The system prompt tells the model to put executable Python in a fenced block. The harness runs that code and returns the program output as the next user message. Requests are greedy (temperature 0) with thinking enabled.

All of this was seen with the EXL3 3.05bpw quant. I did not test other quants on the same workload, so I cannot say whether this is specific to the quant.

On many prompts the first turn never ends. The model stays in thinking, decodes to the request's max_tokens (81,920 tokens, about 35 minutes at ~40 tok/s) and returns finish_reason: "length". No fenced code block appears in the content. At temperature 0 the same prompt shape fails the same way again.

This is the failure mode the loop guard of #33 was built for, but the guard does not fire. It closes thinking only when the last window repeats one pattern of at most 32 tokens. The loops I see vary their wording, so the pattern check does not match and the turn runs to the ceiling.

Why the sampling knobs do not help

#33 states the GLM path has no repetition penalties. #146 made the server accept llama.cpp's repeat_penalty / repeat_last_n fields in requests, but I found nothing on the GLM decode path that applies them. A client that sends repeat_penalty to stop a loop gets no effect.

Originally created by @eliaskg on GitHub (Oct 19, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/273 ## Setup - Project Maya **v1.1.15**, upstream release, engine compiled from the v1.1.15 checkout - Model: GLM-5.3-Flash, turboderp's EXL3 quant at 3.05 bits per weight, MTP draft block - Context 262144 - Client talks to the OpenAI-compatible API, streaming ## What happens I run multi-turn coding-agent sessions through the API. The system prompt tells the model to put executable Python in a fenced block. The harness runs that code and returns the program output as the next user message. Requests are greedy (temperature 0) with thinking enabled. All of this was seen with the EXL3 3.05bpw quant. I did not test other quants on the same workload, so I cannot say whether this is specific to the quant. On many prompts the first turn never ends. The model stays in thinking, decodes to the request's `max_tokens` (81,920 tokens, about 35 minutes at ~40 tok/s) and returns `finish_reason: "length"`. No fenced code block appears in the content. At temperature 0 the same prompt shape fails the same way again. This is the failure mode the loop guard of #33 was built for, but the guard does not fire. It closes thinking only when the last window repeats one pattern of at most 32 tokens. The loops I see vary their wording, so the pattern check does not match and the turn runs to the ceiling. ## Why the sampling knobs do not help #33 states the GLM path has no repetition penalties. #146 made the server accept llama.cpp's `repeat_penalty` / `repeat_last_n` fields in requests, but I found nothing on the GLM decode path that applies them. A client that sends `repeat_penalty` to stop a loop gets no effect.
Author
Owner

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

Thanks for the detailed report - you're right on the penalties: the server accepts repeat_penalty / presence_penalty / frequency_penalty, but the GLM engine drops them, so they have no effect on GLM today. That's a bug, and the fix (applying them in GLM's sampler, drafting included) is planned for the next release.

Two things that should help right now:

  • Greedy decoding with thinking on tends to loop on reasoning models. With the model's recommended sampling (the dashboard Chat's defaults) instead of temperature 0, these runs usually end.
  • The thinking budget: the server closes a reasoning block after thinking_budget tokens (run config, default 32768), and the answer follows. A lower value, e.g. 16384, caps the time a stuck turn can take.

So the budget may not have fired for you, or the answer itself kept going after it. Could you share the server's log of one failing turn and your run config? Please include the request's max_tokens and whether a glm loop guard line appears.

<!-- gh-comment-id:6276063044 --> @mw00 commented on GitHub (Oct 19, 2026): Thanks for the detailed report - you're right on the penalties: the server accepts `repeat_penalty` / `presence_penalty` / `frequency_penalty`, but the GLM engine drops them, so they have no effect on GLM today. That's a bug, and the fix (applying them in GLM's sampler, drafting included) is planned for the next release. Two things that should help right now: - **Greedy decoding with thinking on tends to loop** on reasoning models. With the model's recommended sampling (the dashboard Chat's defaults) instead of temperature 0, these runs usually end. - **The thinking budget:** the server closes a reasoning block after `thinking_budget` tokens (run config, default 32768), and the answer follows. A lower value, e.g. 16384, caps the time a stuck turn can take. So the budget may not have fired for you, or the answer itself kept going after it. Could you share the server's log of one failing turn and your run config? Please include the request's `max_tokens` and whether a `glm loop guard` line appears.
Author
Owner

@eliaskg commented on GitHub (Oct 19, 2026):

Thanks, that explains it. Here is what I can answer from my side.

The thinking budget never fired. My run config has "thinking_budget": 0, which the server reads as none (int(cfg.get("thinking_budget", 32768) or 0)), so no budget reached the engine and a reasoning block was never closed. A stuck turn thinks to the request's max_tokens (81,920) and ends with finish_reason: "length" and empty content. The setup pass wrote that config, and the key holds 0, not the 32768 default. Nothing on my side asked for a budget of zero, so that default may deserve a look.

The loop guard fired once, in an answer, not in thinking. The entire log holds one guard line:

  glm loop guard: the answer was repeating a 32-token pattern (54196 tokens in): the turn was ended there

The runaway turns stay inside thinking with varied wording, and no guard line appears for them.

Sampling: greedy is deliberate, the client pins temperature 0 for reproducible runs. I can rerun the same prompts with the dashboard's recommended sampling and report back.

Happy to retest once the penalty fix lands.

<!-- gh-comment-id:6277005122 --> @eliaskg commented on GitHub (Oct 19, 2026): Thanks, that explains it. Here is what I can answer from my side. The thinking budget never fired. My run config has "thinking_budget": 0, which the server reads as none (int(cfg.get("thinking_budget", 32768) or 0)), so no budget reached the engine and a reasoning block was never closed. A stuck turn thinks to the request's max_tokens (81,920) and ends with finish_reason: "length" and empty content. The setup pass wrote that config, and the key holds 0, not the 32768 default. Nothing on my side asked for a budget of zero, so that default may deserve a look. The loop guard fired once, in an answer, not in thinking. The entire log holds one guard line: ``` glm loop guard: the answer was repeating a 32-token pattern (54196 tokens in): the turn was ended there ``` The runaway turns stay inside thinking with varied wording, and no guard line appears for them. Sampling: greedy is deliberate, the client pins temperature 0 for reproducible runs. I can rerun the same prompts with the dashboard's recommended sampling and report back. Happy to retest once the penalty fix lands.
Author
Owner

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

Thanks, that settles it: with "thinking_budget": 0 the cap is off, so a stuck reasoning block runs to max_tokens. Our setup doesn't write that key; when it's absent, the server uses 32768. Could you check where it came from, e.g. an older config or another tool that edits it? Removing the key, or setting e.g. 16384, brings the cap back.

The penalties fix is coming in the next release. A rerun with the recommended sampling would be very helpful too, thanks!

<!-- gh-comment-id:6277644938 --> @mw00 commented on GitHub (Oct 19, 2026): Thanks, that settles it: with `"thinking_budget": 0` the cap is off, so a stuck reasoning block runs to `max_tokens`. Our setup doesn't write that key; when it's absent, the server uses 32768. Could you check where it came from, e.g. an older config or another tool that edits it? Removing the key, or setting e.g. 16384, brings the cap back. The penalties fix is coming in the next release. A rerun with the recommended sampling would be very helpful too, thanks!
Author
Owner

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

Fixed in v1.1.17. Thanks for the report! Please reopen if it shows up again.

<!-- gh-comment-id:6284956692 --> @mw00 commented on GitHub (Oct 20, 2026): Fixed in [v1.1.17](https://github.com/mw00/project-maya/releases/tag/v1.1.17). Thanks for the report! Please reopen if it shows up again.
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#102
No description provided.