-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
Quantized KV cache: update quanto #31052
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks !
My only question being if these changes are Backward compatible, would this work with the previous quanto version? If not we could raise an error when initializing the QuantoCache educating users to install quanto>=0.2.0 , what do you think?
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
@younesbelkada right, it's not compatible with older versions. I can add a warning or raise an error asking to update quanto to the latest version, if that's usual workflow in these situations? :) |
Since the quanto cache is not part of a release yet, I think we should just force users to use quanto >= 0.2.0 - for that I would just check the quanto version using something like this: https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L1576C53-L1576C79 and raise an error at the cache init if the quanto minimum version is not met |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ! I think it will be interesting to rerun the benchmark with quanto for int4 kv-cache quantization. @dacorvo said that the latency of models quantized with qint4 weights is drastically reduced (almost divided by two).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean work, thanks !
The new kernels only work when doing a matmul between fp16 inputs and int4 weights. In this case the KV are just dequantized, and I haven't bound the kernel for that (the CUDA dequantize method is included in quanto though so maybe you can give it a try). |
More specifically: https://github.com/huggingface/quanto/blob/f545e01443767b8920609bfcde5417fe064eedfd/quanto/library/ext/cuda/awq/dequantize.cuh#L14 |
@dacorvo i see, thanks! I'll check it out! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating and adding the version guard!
Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
What does this PR do?
The latest version of
quanto
was apparently refactored affecting quant-cache. This PR updates QuantoQuantizedCache to work with the latest version of quanto