[CPU][INT4] Add AWQ frontend support for CPU #8225
[CPU][INT4] Add AWQ frontend support for CPU #8225jianan-gu wants to merge 34 commits intosgl-project:mainfrom
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @jianan-gu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces comprehensive support for running AWQ (Activation-aware Weight Quantization) Linear layers on CPU, specifically targeting INT4 precision. The primary goal is to enable efficient inference of quantized models on CPU architectures, leveraging specialized CPU kernels for optimized performance.
Highlights
- CPU INT4 AWQ Integration: Implemented the necessary logic within
AWQLinearMethodto enable AWQ quantized linear layers to run on CPU, leveraging Intel AMX capabilities for accelerated INT4 operations. - Weight Pre-processing for CPU: Added new utility functions (
_autoawq_to_int4pack,_amx_process_int4_packed_qweight_after_loading) inamx_utils.pyto convert and pack AWQ weights into a CPU-optimized INT4 format, including support for a W4A8 (Weight 4-bit, Activation 8-bit) scheme via an environment variable. - Dynamic Kernel Dispatch: Modified the
AWQLinearMethod.applymethod to dynamically select and utilize appropriate CPU INT4 matrix multiplication kernels (int4_scaled_mm_cpu,int4_scaled_mm_cpu_with_quant) when the model is running on a CPU with AMX support. - bfloat16 Activation Support: Extended the
AWQConfigto declaretorch.bfloat16as a supported activation data type, which is crucial for efficient CPU inference with quantized models. - Flexible Quantization Configuration: Updated
update_config.pyto allowgroup_sizeto be used in quantization configurations, providing more flexibility for block-wise quantization schemes.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces AWQ Linear frontend support for CPU, including updates to configs and amx utils. The changes involve conditional logic based on the SGLANG_USE_CPU_INT4_W4A8 environment variable and the availability of Intel AMX. The review focuses on adding comments to improve code clarity.
Co-authored-by: Ma Mingfei <mingfei.ma@intel.com>
|
@jianan-gu rebase. |
Co-authored-by: Ma Mingfei <mingfei.ma@intel.com>
|
/rerun-failed-ci |
2 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
This PR implements AWQ int4 frontends support for CPU, and is calling the CPU sgl-kernels in #8226