[Transforms] Initial Implementation #277
Open
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.
Summary
Add initial support for transforms in compressed-tensors. The following PRs will enable the initial functionality:
Through this functionality, users can define a recipe targeting layers and their specific parameters and activations with transforms. Transforms are loaded from a registry, attached to the layer being targeted, and then applied to a layer's weights (for now) as well as during QDQ during forward passes (such as during generation). Once quantized, the transforms along with a transform_config are saved to disk. They can then be deserialized and loaded for evals.
Examples:
# U(W)V.T
where U and V are hadamard rotation matrices and W is the linear weight. The transforms are not fused into the weights.For a Llama-3.1-1b-Instruct, the following recipe was applied and tested to apply QuIP style rotations to all the linear weights as part of Int4 and Int8 quantization.
Transform Args:
Transform Schemes, defining the different hadamard rotations
Transform Config, passed into the QuantizationModifier
Next Steps:
Required PRs:
[WIP] Add support to load models with transforms huggingface/transformers#36621