Repository navigation
docs(batching): explain server vs generate divergence on snapshot families - #2942
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#2920 reported that a classic
mlxcel-serverrequest onQwen3.8-Flash-Next-4bit-mtpat temperature 0 diverges frommlxcel generate. The cause is the history-boundary prompt-cache snapshot (#1143). The batch scheduler prefills the 70-token chat prompt asprefill[0..65)+prefill[65..70)so it can snapshot the state at the boundary, whilemlxcel generate -phas no history boundary and prefillsprefill[0..70)in one forward. The two partitions reduce in different orders and flip a near-tie token.CONTINUOUS_BATCHING.mdalready states this partition rule, but it never said that it separates the server frommlxcel 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)mlxcel generate--parallel 1[0..65)+[65..70)--no-cache-prompt --prefill-chunk-size 65[0..65)+[65..70)--no-cache-prompt[0..70)MLXCEL_DISABLE_BOUNDARY_SNAPSHOT=1(prompt cache on)[0..70)--no-batch[0..70)MLXCEL_PREFILL_CHUNK=65 mlxcel generatetakes the server's partition and produces the server's answer, so the split alone explains the difference, and the snapshot restore plays no part.--no-cache-promptmatches. feat(speculative): wire the native MTP head and rollback for qwen4_exp #2908 compared it on a different setup and saw no difference.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 generateat a boundary it does not have would move the CLI away from upstreammlx-lm's one-pass prefill.Changes
docs/CONTINUOUS_BATCHING.md: a paragraph and table under "One prefill plan" covering server vsmlxcel generateon snapshot families, with the measurement and the two ways to compare byte for byte.docs/environment-variables.md: theMLXCEL_DISABLE_BOUNDARY_SNAPSHOTentry names this use and links to that section.Closes #2920