-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/intel/neural-compressor i…
…nto jianyu_3.0_onlinedoc
- Loading branch information
Showing
58 changed files
with
450 additions
and
7,022 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Quantization on Client | ||
========================================== | ||
|
||
1. [Introduction](#introduction) | ||
2. [Get Started](#get-started) \ | ||
2.1 [Get Default Algorithm Configuration](#get-default-algorithm-configuration)\ | ||
2.2 [Optimal Performance and Peak Memory Usage](#optimal-performance-and-peak-memory-usage) | ||
|
||
|
||
## Introduction | ||
|
||
For `RTN`, `GPTQ`, and `Auto-Round` algorithms, we provide default algorithm configurations for different processor types (`client` and `sever`). Generally, lightweight configurations are tailored specifically for client devices to enhance performance and efficiency. | ||
|
||
|
||
## Get Started | ||
|
||
### Get Default Algorithm Configuration | ||
|
||
Here, we take the `RTN` algorithm as example to demonstrate the usage on a client machine. | ||
|
||
```python | ||
from neural_compressor.torch.quantization import get_default_rtn_config, convert, prepare | ||
from neural_compressor.torch import load_empty_model | ||
|
||
model_state_dict_path = "/path/to/model/state/dict" | ||
float_model = load_empty_model(model_state_dict_path) | ||
quant_config = get_default_rtn_config() | ||
prepared_model = prepare(float_model, quant_config) | ||
quantized_model = convert(prepared_model) | ||
``` | ||
|
||
> [!TIP] | ||
> By default, the appropriate configuration is determined based on hardware information, but users can explicitly specify `processor_type` as either `client` or `server` when calling `get_default_rtn_config`. | ||
|
||
For Windows machines, run the following command to utilize all available cores automatically: | ||
|
||
```bash | ||
python main.py | ||
``` | ||
|
||
> [!TIP] | ||
> For Linux systems, users need to configure the environment variables appropriately to achieve optimal performance. For example, set the `OMP_NUM_THREADS` explicitly. For processors with hybrid architecture (including both P-cores and E-cores), it is recommended to bind tasks to all P-cores using `taskset`. | ||
### Optimal Performance and Peak Memory Usage | ||
|
||
Below are approximate performance and memory usage figures conducted on a client machine with 24 cores and 32GB of RAM. These figures provide a rough estimate for quick reference and may vary based on specific hardware and configurations. | ||
|
||
- 7B models (e.g., [meta-llama/Llama-2-7b-chat-hf](https://huggingface.co/meta-llama/Llama-2-7b-chat-hf)): the quantization process takes about 65 seconds, with a peak memory usage of around 6GB. | ||
- 1.5B models (e.g., [Qwen/Qwen2-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2-1.5B-Instruct)), the quantization process takes about 20 seconds, with a peak memory usage of around 5GB. |
This file contains 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
This file contains 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
Oops, something went wrong.