fix(quant): load W8A8 int8 checkpoints with per-shard static input scales#29530
Open
Sunt-ing wants to merge 1 commit into
Open
fix(quant): load W8A8 int8 checkpoints with per-shard static input scales#29530Sunt-ing wants to merge 1 commit into
Sunt-ing wants to merge 1 commit into
Conversation
…ales CompressedTensorsW8A8Int8 allocated the static input_scale and input_zero_point as one-slot PerTensorScaleParameters. A fused layer (e.g. gate_up_proj) has one activation scale per logical shard, so loading the second shard raised "IndexError: index 1 is out of bounds for dimension 0 with size 1" and the model failed to load. Allocate one slot per logical shard like weight_scale, and convert the per-tensor weight scale to channelwise so the int8 GEMM kernel gets one scale per output channel. Signed-off-by: Ting Sun <suntcrick@gmail.com>
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
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
Loading a compressed-tensors W8A8 int8 checkpoint with static activation scales (e.g.
nm-testing/tinyllama-w8a8-compressed) crashes during model load:CompressedTensorsW8A8Int8.create_weightsallocates the staticinput_scale/input_zero_pointas one-slotPerTensorScaleParameters. A fused layer such as Llamagate_up_projhas separategate_proj.input_scaleandup_proj.input_scaleshards; the first loads into shard 0, the second into shard 1, but the parameter has length 1, so the load fails.Modifications
input_scaleandinput_zero_pointwithlen(output_partition_sizes)slots, likeweight_scale, so every logical shard of a fused layer loads.convert_to_channelwise) so the int8 GEMM kernel receives onescales_bper output channel; otherwise forward fails withRuntimeError: size of scales_b is not matched. The activationinput_scalestays scalar.Testing
Real-engine E2E on a single GPU, loading the public
nm-testing/tinyllama-w8a8-compressedcheckpoint.Reproduction (env, script, before/after)
A
TestW8A8Int8StaticInputScalecase added totest/registered/quant/test_quant_config_parsing.py(CPU):create_weightswithoutput_partition_sizes=[4, 4]must allocateinput_scale/input_zero_pointof shape(2,). The test fails on main (torch.Size([1]) != torch.Size([2])) and passes with the fix.ruff/black/isortclean.Checklist
CI States
Latest PR Test (Base): ❌ Run #28302208073
Latest PR Test (Extra): ❌ Run #28302208028