Repository navigation
tools: requantization script and perplexity harness - #685
Merged
Merged
Conversation
scripts/requantize_mlp.py rewrites a checkpoint's 8-bit affine module overrides to 4-bit (optional group_size 32 and module-name regex filter) with pure-numpy raw safetensors I/O, enabling quantization variants for the #683 quality/throughput frontier; the uniform 4-bit gemma-4-12b variant it produced measured 1.59 to 1.62x decode on GB10. examples/perplexity.rs computes exact teacher-forced next-token NLL over a fixed text so those variants can be quality-gated beyond greedy smoke prompts.
This was referenced Jul 7, 2026
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
…lup#685) scripts/requantize_mlp.py rewrites a checkpoint's 8-bit affine module overrides to 4-bit (optional group_size 32 and module-name regex filter) with pure-numpy raw safetensors I/O, enabling quantization variants for the lablup#683 quality/throughput frontier; the uniform 4-bit gemma-4-12b variant it produced measured 1.59 to 1.62x decode on GB10. examples/perplexity.rs computes exact teacher-forced next-token NLL over a fixed text so those variants can be quality-gated beyond greedy smoke prompts.
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.
Lands the two tools behind issue #683 steps 2 and 3 (refs #683, does not close it).
scripts/requantize_mlp.py: rewrites a checkpoint's 8-bit affine module overrides down to 4-bit with pure-numpy raw safetensors I/O (bf16 as uint16, u32 low-first packing, q computed against bf16-rounded scales/biases so the stored triples are self-consistent). Supports--target-group-size 32and a--matchregex to requantize only selected modules (e.g. keep down_proj at 8-bit), updating config quantization overrides accordingly. The uniform 4-bit gemma-4-12b variant it produced measured 1.59 to 1.62x decode with 3.6 GB lower peak on GB10 (numbers on the issue).examples/perplexity.rs: exact teacher-forced next-token NLL over a fixed text file, chunked with fresh KV caches, for comparing quantization variants of the same model (the quality gate the greedy smoke prompts cannot provide).Tool-only change: no library or runtime code is touched.
Refs #683