fix: emit real I2_S tensors for offline-quantized LlamaModel checkpoints - #623
Open
Pujitha Paladugu (pujitha24) wants to merge 1 commit into
Open
fix: emit real I2_S tensors for offline-quantized LlamaModel checkpoints#623Pujitha Paladugu (pujitha24) wants to merge 1 commit into
Pujitha Paladugu (pujitha24) wants to merge 1 commit into
Conversation
Motivation: `convert-hf-to-gguf-bitnet.py --outtype i2_s` mishandled offline-quantized LlamaForCausalLM BitNet checkpoints (ternary weights packed as uint8 plus a separate `<name>.weight_scale` tensor): the scale division was applied unconditionally, and the I2_S quantization dispatch only had TL1/TL2 branches, so these tensors fell through to the F16 default instead of producing real I2_S data. Approach: In `LlamaModel`, skip the unconditional `scale_map` division when the requested ftype is I2_S, so the ternary values stay undivided. Add an I2_S branch to the quantization dispatch, gated on the tensor name being present in `scale_map`, which calls `quantize_to_i2_s` with the corresponding scale as `override_scale`. Tensors not present in `scale_map` (ordinary, non-offline-quantized checkpoints) still fall through to the existing F16 path, so the division and dispatch changes only affect genuinely offline-quantized tensors. Report: microsoft#621 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Assisted-by: claude-sonnet-5 (via Claude Code)
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.
Motivation:
convert-hf-to-gguf-bitnet.py --outtype i2_smishandled offline-quantizedLlamaForCausalLM BitNet checkpoints (ternary weights packed as uint8 plus a
separate
<name>.weight_scaletensor): the scale division was appliedunconditionally, and the I2_S quantization dispatch only had TL1/TL2
branches, so these tensors fell through to the F16 default instead of
producing real I2_S data.
Approach:
In
LlamaModel, skip the unconditionalscale_mapdivision when therequested ftype is I2_S, so the ternary values stay undivided. Add an I2_S
branch to the quantization dispatch, gated on the tensor name being present
in
scale_map, which callsquantize_to_i2_swith the correspondingscale as
override_scale. Tensors not present inscale_map(ordinary,non-offline-quantized checkpoints) still fall through to the existing
F16 path, so the division and dispatch changes only affect genuinely
offline-quantized tensors.
Report: #621
Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com
Assisted-by: claude-sonnet-5 (via Claude Code)