-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
[WIP] [doc] performance/scalability revamp #15213
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b5a2586
[doc] performance/scalability revamp
stas00 94b1b18
Merge remote-tracking branch 'origin/master' into doc-perf-revamp
stas00 309bbae
link the new docs
stas00 a6a2832
no :
stas00 5d3df09
mixed precision
stas00 b6f33bf
Merge remote-tracking branch 'origin/master' into doc-perf-revamp
stas00 90c65d2
Merge remote-tracking branch 'origin/master' into doc-perf-revamp
stas00 674bef6
work on the first doc
stas00 0ad5fe6
expand the main doc
stas00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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,22 @@ | ||
<!--Copyright 2020 The HuggingFace Team. All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
--> | ||
|
||
# Efficient Inference | ||
|
||
## Memory Needs During Inference | ||
|
||
4-6x params | ||
|
||
## Choose Your Scale | ||
|
||
- [One GPU](perf_infer_gpu_one) | ||
- [Many GPUs](perf_infer_gpu_many) | ||
- [CPU](perf_infer_cpu) |
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,30 @@ | ||
<!--Copyright 2020 The HuggingFace Team. All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
--> | ||
|
||
# Efficient Inference on CPU | ||
|
||
|
||
## Less Memory | ||
|
||
|
||
|
||
## Faster Speed | ||
|
||
|
||
|
||
|
||
## Scalability Strategy | ||
|
||
* Deepspeed-ZeRO Stage 3 + CPU/NVMe Offload | ||
|
||
* Sagemaker | ||
|
||
* Deepspeed-Inference |
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,47 @@ | ||
<!--Copyright 2020 The HuggingFace Team. All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
--> | ||
|
||
# Efficient Inference on Multiple GPUs | ||
|
||
|
||
## Less Memory | ||
|
||
### fp16 | ||
|
||
### bf16 | ||
|
||
### Quantization | ||
|
||
|
||
|
||
## Faster Speed | ||
|
||
### DP vs DDP | ||
|
||
### ONNX | ||
|
||
### Infinity, Inference API | ||
|
||
|
||
|
||
|
||
|
||
## Scalability Strategy | ||
|
||
* Deepspeed-ZeRO Stage 3 + CPU/NVMe Offload | ||
|
||
* Sagemaker | ||
|
||
* Deepspeed-Inference | ||
|
||
|
||
|
||
## Hardware |
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,44 @@ | ||
<!--Copyright 2020 The HuggingFace Team. All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
--> | ||
|
||
# Efficient Inference on a Single GPU | ||
|
||
|
||
|
||
## Less Memory | ||
|
||
### fp16 | ||
|
||
### bf16 | ||
|
||
### Quantization | ||
|
||
|
||
|
||
|
||
|
||
## Faster Speed | ||
|
||
### Batch sizes | ||
|
||
### ONNX | ||
|
||
### Infinity, Inference API | ||
|
||
|
||
|
||
## Scalability Strategy | ||
|
||
* Deepspeed-ZeRO Stage 3 + CPU/NVMe Offload | ||
|
||
* Sagemaker | ||
|
||
* Deepspeed-Inference |
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,23 @@ | ||
<!--Copyright 2020 The HuggingFace Team. All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
--> | ||
|
||
# Efficient Training | ||
|
||
|
||
|
||
## Memory Needs During Training | ||
|
||
16-18x number of model params | ||
|
||
## Choose Your Scale | ||
|
||
- [One GPU](perf_train_gpu_one) | ||
- [Many GPUs](perf_train_gpu_many) |
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,80 @@ | ||
<!--Copyright 2020 The HuggingFace Team. All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
--> | ||
|
||
# Efficient Training on Multiple GPU | ||
|
||
|
||
|
||
## Less Memory | ||
|
||
|
||
### fp16 | ||
|
||
### bf16 | ||
|
||
### Gradient Accumulation | ||
|
||
### Gradient Checkpointing | ||
|
||
### Optimizer | ||
|
||
|
||
## Faster Speed | ||
|
||
### DP vs DDP | ||
|
||
### Gradient Accumulation | ||
|
||
### Batch sizes | ||
|
||
|
||
|
||
## Scalability Strategy | ||
|
||
**⇨ Single Node / Multi-GPU** | ||
|
||
* Model fits onto a single GPU: | ||
|
||
1. DDP - Distributed DP | ||
2. ZeRO - may or may not be faster depending on the situation and configuration used | ||
|
||
* Model doesn't fit onto a single GPU: | ||
|
||
1. PP | ||
2. ZeRO | ||
3. TP | ||
|
||
With very fast intra-node connectivity of NVLINK or NVSwitch all three should be mostly on par, without these PP will be faster than TP or ZeRO. The degree of TP may also make a difference. Best to experiment to find the winner on your particular setup. | ||
|
||
TP is almost always used within a single node. That is TP size <= gpus per node. | ||
|
||
* Largest Layer not fitting into a single GPU: | ||
|
||
1. If not using ZeRO - must use TP, as PP alone won't be able to fit. | ||
2. With ZeRO see the same entry for "Single GPU" above | ||
|
||
|
||
**⇨ Multi-Node / Multi-GPU** | ||
|
||
* When you have fast inter-node connectivity: | ||
|
||
1. ZeRO - as it requires close to no modifications to the model | ||
2. PP+TP+DP - less communications, but requires massive changes to the model | ||
|
||
* when you have slow inter-node connectivity and still low on GPU memory: | ||
|
||
1. DP+PP+TP+ZeRO-1 | ||
|
||
|
||
|
||
|
||
|
||
## Hardware |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Let's make a subfolder instead of having so many document names prefixed with
perf
.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.
great idea