convert_olmoe.py: wire --ebits through to quantization (fixes #323)#328
Merged
Merged
Conversation
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.
convert_olmoe.py: wire --ebits through to quantization (fixes #323)
--ebitswas parsed (default 4) but never used:quantize_row()hardcoded qmax=127, so every conversion silently emitted int8 while the script's docstring, name, and default all promised int4 β blocking the int4-on-OLMoE measurement #323 wanted.Fix
quantize_row(w, bits)now mirrors the engine'squantize_rows()(olmoe.c) exactly:qmax = 2**(bits-1) - 1(8 β 127, 4 β 7, 2 β 1)scale = amax(|w|, row) / qmaxq = clamp(round(w/scale), -qmax-1, qmax), stored one value per int8 byte (the engine dequantizes asq*scaleand never assumes the full int8 range, so no container format change and the I8+.qsfast path inload_expert_w()works unchanged)Plus:
--ebitsvalidated to 2..8 (same range the engine enforces), and the completion message now states the actual bit width.Behavior note for review
The default invocation now genuinely produces int4, as the docs always claimed β anyone who relied on the de-facto int8 output gets a real change. If you'd rather preserve de-facto behavior, flipping the default to
--ebits 8is a one-line tweak; I kept 4 because it's what the script has documented since day one and it's the measurement #323 is after.Verification
--ebits 8reproduces the previous (hardcoded int8) output exactly β byte-identical q and scales.Ref #323.