mirror of
https://github.com/QwenLM/Qwen.git
synced 2026-05-21 00:45:48 +08:00
@@ -242,7 +242,7 @@ With this method, it is available to load Qwen-7B in `NF4` and `Int8`, which sav
|
|||||||
| Int8 | 52.8 | 10.44G |
|
| Int8 | 52.8 | 10.44G |
|
||||||
| NF4 | 48.9 | 7.79G |
|
| NF4 | 48.9 | 7.79G |
|
||||||
|
|
||||||
Note: The GPU memory usage profiling in the above table is performed on single A100-SXM4-80G GPU, PyTorch 2.0.1 and cuda 11.8, with flash attention used.
|
Note: The GPU memory usage profiling in the above table is performed on single A100-SXM4-80G GPU, PyTorch 2.0.1 and CUDA 11.8, with flash attention used.
|
||||||
|
|
||||||
## Inference Efficiency
|
## Inference Efficiency
|
||||||
|
|
||||||
@@ -256,11 +256,11 @@ We measured the average inference speed of generating 2K tokens under BF16 preci
|
|||||||
| Int8 (bnb) | 7.94 | 7.86 |
|
| Int8 (bnb) | 7.94 | 7.86 |
|
||||||
| NF4 (bnb) | 21.43 | 20.37 |
|
| NF4 (bnb) | 21.43 | 20.37 |
|
||||||
|
|
||||||
In detail, the setting of profiling is generating 2048 new tokens with 1 context token. The profiling runs on single A100-SXM4-80G GPU with PyTorch 2.0.1 and cuda 11.8. The inference speed is averaged over the generated 2048 tokens.
|
In detail, the setting of profiling is generating 2048 new tokens with 1 context token. The profiling runs on single A100-SXM4-80G GPU with PyTorch 2.0.1 and CUDA 11.8. The inference speed is averaged over the generated 2048 tokens.
|
||||||
|
|
||||||
### GPU Memory Usage
|
### GPU Memory Usage
|
||||||
|
|
||||||
We also profile the peak GPU memory usage for encoding 2048 tokens as context (and generating single token) and generating 8192 tokens (with single token as context) under BF16 or Int8/NF4 quantization levels, respectively. The results are shown below
|
We also profile the peak GPU memory usage for encoding 2048 tokens as context (and generating single token) and generating 8192 tokens (with single token as context) under BF16 or Int8/NF4 quantization levels, respectively. The results are shown below.
|
||||||
|
|
||||||
When using flash attention, the memory usage is:
|
When using flash attention, the memory usage is:
|
||||||
|
|
||||||
|
|||||||
48
README_JA.md
48
README_JA.md
@@ -239,15 +239,49 @@ model = AutoModelForCausalLM.from_pretrained(
|
|||||||
|
|
||||||
この方法では、Qwen-7B を `NF4` と `Int8` でロードすることができ、メモリ使用量を節約できる。以下にモデル性能の関連統計量を示します。量子化により、有効性は若干低下するが、推論効率は大幅に向上し、メモリコストが削減されることがわかります。
|
この方法では、Qwen-7B を `NF4` と `Int8` でロードすることができ、メモリ使用量を節約できる。以下にモデル性能の関連統計量を示します。量子化により、有効性は若干低下するが、推論効率は大幅に向上し、メモリコストが削減されることがわかります。
|
||||||
|
|
||||||
| Precision | MMLU | Memory |
|
| Precision | MMLU | GPU Memory for Loading Model |
|
||||||
| :---------: | :------: | :------: |
|
| ----------- | :------: | :---------------------------: |
|
||||||
| BF16 | 56.7 | 16.2G |
|
| BF16 | 56.7 | 16.38G |
|
||||||
| Int8 | 52.8 | 10.1G |
|
| Int8 | 52.8 | 10.44G |
|
||||||
| NF4 | 48.9 | 7.4G |
|
| NF4 | 48.9 | 7.79G |
|
||||||
|
|
||||||
##
|
注:上表のGPUメモリ使用量プロファイリングは、シングルA100-SXM4-80G GPU、PyTorch 2.0.1、CUDA 11.8、フラッシュアテンション使用で実行されています。
|
||||||
|
|
||||||
`cli_demo.py` に CLI のデモ例を用意しています。ユーザはプロンプトを入力することで Qwen-7B-Chat と対話することができ、モデルはストリーミングモードでモデルの出力を返します。
|
## 推論効率
|
||||||
|
|
||||||
|
### 推論スピード
|
||||||
|
|
||||||
|
BF16精度、量子化レベルInt8またはNF4で、それぞれ2Kトークンを生成する平均推論速度を測定した。
|
||||||
|
|
||||||
|
| Quantization Level | Inference Speed with flash_attn (tokens/s) | Inference Speed w/o flash_attn (tokens/s) |
|
||||||
|
| ------ | :---------------------------: | :---------------------------: |
|
||||||
|
| BF16 (no quantization) | 30.06 | 27.55 |
|
||||||
|
| Int8 (bnb) | 7.94 | 7.86 |
|
||||||
|
| NF4 (bnb) | 21.43 | 20.37 |
|
||||||
|
|
||||||
|
詳細には、プロファイリングの設定は、1コンテクスト・トークンで2048の新しいトークンを生成している。プロファイリングは、PyTorch 2.0.1とCUDA 11.8を搭載したシングルA100-SXM4-80G GPUで実行される。推論速度は生成された2048個のトークンの平均です。
|
||||||
|
|
||||||
|
### GPUメモリ使用量
|
||||||
|
|
||||||
|
また、BF16またはInt8/NF4量子化レベルの下で、2048個のトークンをコンテキストとしてエンコードした場合(および単一のトークンを生成した場合)と、8192個のトークンを生成した場合(単一のトークンをコンテキストとして生成した場合)のGPUメモリ使用量のピーク値をそれぞれプロファイリングしました。結果を以下に示す。
|
||||||
|
|
||||||
|
Flash attentionを使用した場合のメモリ使用量は以下の通りである:
|
||||||
|
|
||||||
|
| Quantization Level | Peak Usage for Encoding 2048 Tokens | Peak Usage for Generating 8192 Tokens |
|
||||||
|
| --- | :---: | :---: |
|
||||||
|
| BF16 | 18.11GB | 23.52GB |
|
||||||
|
| Int8 | 12.17GB | 17.60GB |
|
||||||
|
| NF4 | 9.52GB | 14.93GB |
|
||||||
|
|
||||||
|
Flash attentionを使用しない場合、メモリ使用量は次のようになる:
|
||||||
|
|
||||||
|
| Quantization Level | Peak Usage for Encoding 2048 Tokens | Peak Usage for Generating 8192 Tokens |
|
||||||
|
| --- | :---: | :---: |
|
||||||
|
| BF16 | 18.11GB | 24.40GB |
|
||||||
|
| Int8 | 12.18GB | 18.47GB |
|
||||||
|
| NF4 | 9.52GB | 15.81GB |
|
||||||
|
|
||||||
|
上記のスピードとメモリーのプロファイリングは、[このスクリプト](https://qianwen-res.oss-cn-beijing.aliyuncs.com/profile.py)を使って行われた。
|
||||||
|
|
||||||
## デモ
|
## デモ
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user