Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add latest AWQ CUDA fp16 int4 kernels #198

Merged
merged 11 commits into from
May 23, 2024
Merged

Add latest AWQ CUDA fp16 int4 kernels #198

merged 11 commits into from
May 23, 2024

Conversation

dacorvo
Copy link
Collaborator

@dacorvo dacorvo commented May 22, 2024

What does this PR do?

This adds the latest AWQ CUDA kernels from https://github.com/mit-han-lab/llm-awq to the library.

@inproceedings{lin2023awq,
title={AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration},
author={Lin, Ji and Tang, Jiaming and Tang, Haotian and Yang, Shang and Chen, Wei-Ming and Wang, Wei-Chen and Xiao, Guangxuan and Dang, Xingyu and Gan, Chuang and Han, Song},
booktitle={MLSys},
year={2024}
}

This also completely refactors the QBitsTensor class to allow it to be subclassed with tensors that store their underlying data, scale and zeropoint as expected by custom kernels.

The latency of models quantized with qint4 weights is drastically reduced (almost divided by two). An upcoming pull-request will update the benchmark section with new numbers.

Implements #111

dacorvo added 10 commits May 17, 2024 12:14
This new packed Tensor applies the formatting expected by the AWQ
GEMM/GEMV kernels of first and second generation.
Before this change the weight Tensor was quantized just to be able to
identify its target class before deserializing its inner tensors and
meta. The target class is now explicitly identified in QModuleMixin.
This adds AWQBitsTensor, a QBitsTensor subclass that stores its inner
Tensors as expected by AWQ CUDA kernels.
A new `create` static method is added to QBitsTensor to select the best
subclass when creating a QBitsTensor.
This new method is now called automatically when quantizing or copying
a QBitsTensor to a device.
Note that it is still possible to create a QBitsTensor base class on any
device by calling explicitly its constructor instead of the `create`
method.
This is in particular useful when reloading a serialized QBitsTensor to
a specific device. In that case, another helper is added to optimize the
QBitsTensor after deserialization.
transformers version 4.41.0 refuses to load the custom MLP MNIST model.
@dacorvo dacorvo marked this pull request as ready for review May 22, 2024 17:07
@dacorvo dacorvo merged commit 7de45a3 into main May 23, 2024
11 checks passed
@dacorvo dacorvo deleted the awq_kernels branch May 23, 2024 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant