[PyTorch FE] Add 2-bit (u2) weight decompression subgraph support#34542
Draft
ljaljushkin wants to merge 2 commits intoopenvinotoolkit:masterfrom
Draft
[PyTorch FE] Add 2-bit (u2) weight decompression subgraph support#34542ljaljushkin wants to merge 2 commits intoopenvinotoolkit:masterfrom
ljaljushkin wants to merge 2 commits intoopenvinotoolkit:masterfrom
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.
Details:
u2_compression_stackpattern matcher inutils_quantize.cppthat detects the NNCFunpack_uint2subgraph:aten::stack([bitwise_and(packed, 3), bitwise_and(bitwise_right_shift(packed, 2), 3), bitwise_and(bitwise_right_shift(packed, 4), 3), bitwise_and(bitwise_right_shift(packed, 6), 3)], dim=-1)and replaces it with a single
element::u2constant.U2ConvertReshapetransformation pass that foldsReshapeon u2 constantsinto the constant itself (analogous to
U4ConvertReshapefor u4).MarkCompressedWeightConstantstransformation pass that marksConvertnodesconsuming u2/u4/i4 constants with
disable_constant_foldingandmark_as_decompressionto prevent MOC from expanding compressed weight constants.
translate_stack(TorchScript) andtranslate_stack_fx(torch.compile) code paths.u2 → u8type promotion in CPU plugin'stransformation_pipeline.cpp.aten::bitwise_right_shiftop converter — the pattern matcherconsumes the entire unpack subgraph at the
aten::stacklevel.This enables export of NNCF models with
INT2SymmetricWeightsDecompressorto OpenVINO IR,following the same approach used for INT4 decompression patterns (PR #27048).
Tickets:
AI Assistance:
lm_eval
--model openvino
--model_args pretrained=$IR_DIR
--device cpu
--tasks lambada_openai