Add --q-override for per-layer quantization#922
Open
spicyneuron wants to merge 13 commits intoml-explore:mainfrom
Open
Add --q-override for per-layer quantization#922spicyneuron wants to merge 13 commits intoml-explore:mainfrom
spicyneuron wants to merge 13 commits intoml-explore:mainfrom
Conversation
Contributor
|
This can be interesting to create custom quantizations 🤔 |
Contributor
Author
|
@ivanfioravanti Exactly! Nothing groundbreaking from the example above, but it's a small perplexity improvement with a small cost in speed: https://huggingface.co/spicyneuron/Qwen3-Next-Coder-MLX-mixed-4.5-bit I saw a bigger difference in more aggressive quants, where uniform 3-bit or |
Contributor
Author
|
Discovered some edge cases while inspecting quant results. Moved to draft until I'm confident those are settled. |
Contributor
Author
|
The issue was the |
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.
Adds a repeatable
--q-override PATTERN=VALUEflag to override quantization on a per-layer basis. Patterns are regexes matched against module paths, where the first match wins.Similar to (and inspired by)
llama-quantize. I was applying this via a custom script but felt it might be a helpful option to upstream.Values can be:
8)mxfp4,nvfp4,mxfp8)float16,bfloat16,float32)Example:
Also fixes a subtle issue where
convert()hardcodedq_group_size=64andq_bits=4as signature defaults. The CLI was fine (argparse passesNone), but callingconvert()from Python withq_mode="mxfp4"would silently use the wrong group size. Now both paths go through the same mode-aware default logic.Adds unit tests for the three new helpers (
parse_overrides,build_override_predicate,apply_float_overrides).