Repository navigation
Conversation
Member
|
If we use #450 as the PR to pick up new mlx/mlx-c, this will likely sit on top of that. That requires that mlx-c expose the correct API |
Contributor
Author
|
Looks like MLX team does not want to support anything like this. They closed the PR downstream, no sense to keep this open. |
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.
Proposed changes
Related issue: ml-explore/mlx-swift-lm#542
Problem
Autoregressive decoding evaluates one token at a time, while speculative decoding verifies a short block of tokens in one target-model call. These different shapes can select different Metal matmul and attention kernels with different floating-point reduction orders.
Although mathematically equivalent, the resulting BF16 values may differ slightly. Over many transformer layers and decoding rounds, these differences can eventually change a close
argmax, causing temperature-zero speculative decoding to diverge from ordinary autoregressive decoding.The underlying numerical fix belongs in MLX. Swift applications also need a supported way to enable and configure that behavior without relying exclusively on process environment variables.
Changes
This PR:
For MTP speculative decoding, the limit should cover
blockSize. For conventional speculative decoding, it should cover the complete verification width, normallynumDraftTokens + 1.Dependencies
The MLX and mlx-c dependency changes must land first. After they are merged, this PR’s submodule pointers should be updated to the final upstream commit SHAs if either dependency is squash-merged.
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes