Skip to content

docs(batching): explain server vs generate divergence on snapshot families - #2942

Merged
inureyes merged 1 commit into
mainfrom
fix/issue-2920-qwen4-exp-server-classic-parity
Nov 10, 2026
Merged

inureyes merged 1 commit into
mainfrom
fix/issue-2920-qwen4-exp-server-classic-parity

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

#2920 reported that a classic mlxcel-server request on Qwen3.8-Flash-Next-4bit-mtp at temperature 0 diverges from mlxcel generate. The cause is the history-boundary prompt-cache snapshot (#1143). The batch scheduler prefills the 70-token chat prompt as prefill[0..65)+prefill[65..70) so it can snapshot the state at the boundary, while mlxcel generate -p has no history boundary and prefills prefill[0..70) in one forward. The two partitions reduce in different orders and flip a near-tie token. CONTINUOUS_BATCHING.md already states this partition rule, but it never said that it separates the server from mlxcel generate, and its "one prefill plan" sentence reads as if the two always match. This PR documents the case with the measurement and names the switch for byte-for-byte comparisons. There are no code changes.

Evidence (M3 Ultra, main @ 0ba1b50b, MLXCEL_QMV_WIDE=0, 256 tokens, temperature 0)

server run prefill partition vs mlxcel generate
defaults, and --parallel 1 [0..65)+[65..70) diverges at completion token 98
--no-cache-prompt --prefill-chunk-size 65 [0..65)+[65..70) byte-identical to the defaults run
--no-cache-prompt [0..70) identical
MLXCEL_DISABLE_BOUNDARY_SNAPSHOT=1 (prompt cache on) [0..70) identical
--no-batch [0..70) identical
  • At token 98 the one-forward run ties " as" and " when" at logprob -0.875. The split run gives " when" -0.875 over " as" -1.0.
  • MLXCEL_PREFILL_CHUNK=65 mlxcel generate takes the server's partition and produces the server's answer, so the split alone explains the difference, and the snapshot restore plays no part.
  • The OptiQ 2-bit target behaves the same way: the defaults run diverges at answer character 205 (boundary 65), and --no-cache-prompt matches. feat(speculative): wire the native MTP head and rollback for qwen4_exp #2908 compared it on a different setup and saw no difference.
  • The speculative server matched in the original report because its prefill logged no boundary split.

Decision

This is an expected numeric route difference (outcome (a) in the issue). Removing the split would cost snapshot families their multi-turn prompt-cache hit, and splitting mlxcel generate at a boundary it does not have would move the CLI away from upstream mlx-lm's one-pass prefill.

Changes

  • docs/CONTINUOUS_BATCHING.md: a paragraph and table under "One prefill plan" covering server vs mlxcel generate on snapshot families, with the measurement and the two ways to compare byte for byte.
  • docs/environment-variables.md: the MLXCEL_DISABLE_BOUNDARY_SNAPSHOT entry names this use and links to that section.

Closes #2920

…ilies

A cold batch-scheduler request on a snapshot family prefills the chat as two forwards split at the history boundary, while mlxcel generate prefills a short prompt as one forward. On Qwen3.8-Flash-Next-4bit-mtp at temperature 0 that partition change flips a near-tie token (" as" and " when" tie at -0.875 in the one-forward run; the split run gives " when" -0.875 over " as" -1.0), so the server answer parts from generate at completion token 98.

The split alone reproduces it: --no-cache-prompt --prefill-chunk-size 65 gives the defaults run byte for byte, and MLXCEL_PREFILL_CHUNK=65 mlxcel generate gives the server's answer. --no-cache-prompt, --no-batch and MLXCEL_DISABLE_BOUNDARY_SNAPSHOT=1 all match generate. The OptiQ 2-bit target shows the same divergence. This is the documented partition rule, not a bug, so record the measurement in CONTINUOUS_BATCHING.md and point the MLXCEL_DISABLE_BOUNDARY_SNAPSHOT entry at it as the switch for byte-for-byte comparisons.

Closes #2920
@inureyes inureyes added the type:docs Documentation improvements or additions label Nov 10, 2026
@inureyes
inureyes merged commit 2dc8ed4 into main Nov 10, 2026
31 checks passed
@inureyes
inureyes deleted the fix/issue-2920-qwen4-exp-server-classic-parity branch November 10, 2026 13:07
@inureyes inureyes added status:done Completed priority:medium Medium priority area:inference Generation, sampling, decoding (incl. speculative, DRY) platform:macos macOS (Apple Silicon) specific arch:moe Sparse mixture-of-experts decoder labels Nov 30, 2026
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch:moe Sparse mixture-of-experts decoder area:inference Generation, sampling, decoding (incl. speculative, DRY) platform:macos macOS (Apple Silicon) specific priority:medium Medium priority status:done Completed type:docs Documentation improvements or additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(server): qwen4_exp classic server decode differs from offline generate at temp 0

1 participant