chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "ZeRO & DeepSpeed: New system optimizations enable training models with over 100 billion parameters"
|
||||
date: 2020-02-13
|
||||
link: https://www.microsoft.com/en-us/research/blog/ZeRO-deepspeed-new-system-optimizations-enable-training-models-with-over-100-billion-parameters/
|
||||
excerpt: ""
|
||||
tags: training ZeRO English
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "Turing-NLG: A 17-billion-parameter language model by Microsoft"
|
||||
date: 2020-02-13
|
||||
link: https://www.microsoft.com/en-us/research/blog/turing-nlg-a-17-billion-parameter-language-model-by-microsoft/
|
||||
excerpt: "DeepSpeed was used to train the world's largest language model."
|
||||
tags: training English
|
||||
---
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "ZeRO stage 1 with reduced communication"
|
||||
sneak_preview: true
|
||||
tags: training ZeRO English
|
||||
excerpt: "Partition-aware ZeRO with up to 2x reduction in communication time!"
|
||||
---
|
||||
|
||||
* Partition-aware approach instead of initial implementation that used a global collective (all-reduce)
|
||||
* Total communication volume reduction 1.5x -> 1x of data parallelism
|
||||
* Up to 2x reduction in communication time compared to all-reduce
|
||||
|
||||
## Further updates coming soon!
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: "The Fastest and Most Efficient BERT Training through Optimized Transformer Kernels"
|
||||
excerpt: ""
|
||||
date: 2020-05-19 00:00:00
|
||||
toc: false
|
||||
tags: training English
|
||||
---
|
||||
|
||||
We introduce new technology to accelerate single GPU performance via kernel
|
||||
optimizations. These optimizations not only create a strong foundation for
|
||||
scaling out large models, but also improve the single GPU performance of
|
||||
highly tuned and moderately sized models like BERT by more than 30%, reaching
|
||||
a staggering performance of 66 teraflops per V100 GPU, which is 52% of the
|
||||
hardware peak. **Using optimized transformer kernels as the building block,
|
||||
DeepSpeed achieves the fastest BERT training record: 44 minutes on 1,024
|
||||
NVIDIA V100 GPUs**, compared with the best published result of 67 minutes on
|
||||
the same number and generation of GPUs.
|
||||
|
||||
* Brief overview, see our [press release](https://www.microsoft.com/en-us/research/blog/ZeRO-2-deepspeed-shattering-barriers-of-deep-learning-speed-scale/).
|
||||
* Detailed technology deep dive, see our [blog post](https://www.deepspeed.ai/2020/05/27/fastest-bert-training.html).
|
||||
* Tutorial on how to reproduce our results, see our [BERT pre-training tutorial](https://www.deepspeed.ai/tutorials/bert-pretraining/).
|
||||
* The source code for our transformer kernels can be found in the [DeepSpeed repo](https://github.com/deepspeedai/deepspeed) and BERT pre-training code can be found in the [DeepSpeedExamples repo](https://github.com/deepspeedai/deepspeedexamples).
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "ZeRO-2 & DeepSpeed: Shattering Barriers of Deep Learning Speed & Scale"
|
||||
excerpt: ""
|
||||
link: https://www.microsoft.com/en-us/research/blog/ZeRO-2-deepspeed-shattering-barriers-of-deep-learning-speed-scale/
|
||||
tags: training ZeRO English
|
||||
date: 2020-05-19 02:00:00
|
||||
---
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
title: "An Order-of-Magnitude Larger and Faster Training with ZeRO-2"
|
||||
excerpt: ""
|
||||
tags: training ZeRO English
|
||||
date: 2020-05-19 01:00:00
|
||||
toc: false
|
||||
---
|
||||
|
||||
ZeRO-2 expands the scope of memory optimizations in the original ZeRO by
|
||||
tackling the full spectrum of memory consumption during training. More
|
||||
specifically, ZeRO-2 introduces new technology to reduce the memory footprint
|
||||
of gradients, activation memory, and fragmented memory, in addition to
|
||||
optimizer state memory optimization in the original ZeRO. Altogether, the
|
||||
memory savings empower DeepSpeed to improve the scale and speed of deep
|
||||
learning training by an order of magnitude. More concretely, ZeRO-2 allows
|
||||
training models as large as 170 billion parameters up to 10x faster compared
|
||||
to state of the art.
|
||||
|
||||
For more information on ZeRO-2, see our [blog post](https://www.microsoft.com/en-us/research/blog/ZeRO-2-deepspeed-shattering-barriers-of-deep-learning-speed-scale/).
|
||||
|
||||
For more information on how to use ZeRO-2, see an example of training GPT family of models in this [tutorial](/tutorials/megatron/).
|
||||
|
||||
For a technical overview, see our [technical report](https://arxiv.org/abs/1910.02054).
|
||||
@@ -0,0 +1,295 @@
|
||||
---
|
||||
title: "Microsoft DeepSpeed achieves the fastest BERT training time"
|
||||
excerpt: ""
|
||||
tags: training English
|
||||
date: 2020-05-28 00:00:00
|
||||
---
|
||||
|
||||
Good news! **DeepSpeed obtains the fastest BERT training record: 44 minutes on
|
||||
1024 NVIDIA V100 GPU.** This is a 30% improvement over the best published result
|
||||
of 67 mins in end-to-end training time to achieve the same accuracy on the same
|
||||
number and generation of GPUs. This improvement does not come at the cost of
|
||||
excessive hardware resources but comes from improved software efficiency. For
|
||||
example, DeepSpeed can attain a staggering 64 teraflops of single GPU
|
||||
performance on a NVIDIA V100 GPU which is over 50% of the hardware peak.
|
||||
|
||||
In this blog post, we will discuss four technological improvements that enable
|
||||
DeepSpeed to achieve this record-breaking BERT training time.
|
||||
|
||||
1. Highly optimized transformer kernels to improve compute efficiency
|
||||
2. Overlapping I/O with computation through asynchronous prefetching queue
|
||||
3. Sparse output processing to eliminate wasteful computation
|
||||
4. Layer-norm reordering for training stability and faster convergence
|
||||
|
||||
These optimizations not only benefit BERT; they are also applicable to many
|
||||
other transformer-based models such as RoBERTa, XLNet, and UniLM. Furthermore, besides the improvements mentioned for pre-training, DeepSpeed achieves up to 1.5x speedups for the downstream tasks, such as the fine-tuning for Bing-BERT SQuAD.
|
||||
|
||||
## Performance Results for BERT Pretraining
|
||||
|
||||
Compared to SOTA, DeepSpeed significantly improves single GPU performance for
|
||||
transformer-based model like BERT. Figure 1 shows the single GPU throughput of
|
||||
training BERT-Large optimized through DeepSpeed, comparing with the two
|
||||
well-known PyTorch implementations from [NVIDIA
|
||||
BERT](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/LanguageModeling/BERT)
|
||||
and [Hugging Face
|
||||
BERT](https://github.com/huggingface/transformers/blob/master/src/transformers/modeling_bert.py).
|
||||
DeepSpeed reaches as high as 64 and 53 teraflops throughputs (corresponding to
|
||||
272 and 52 samples/second) for sequence lengths 128 and 512, respectively,
|
||||
exhibiting up to 28% throughput improvements over NVIDIA BERT and up to 62%
|
||||
over HuggingFace BERT. We also support up to 1.8x larger batch size without
|
||||
running out of memory.
|
||||
|
||||
To achieve this performance, DeepSpeed implements a stochastic transformer
|
||||
which exhibits some level of non-deterministic noise without affecting overall
|
||||
convergence. In addition, DeepSpeed also implements a deterministic transformer
|
||||
kernel that is completely reproducible at the expense of a small performance
|
||||
regression of approximately 2% on average. Users can easily choose and switch
|
||||
between the two versions depending on their usage scenarios: Stochastic version
|
||||
pursues ultimate training performance goal, and deterministic version may save
|
||||
development time by better facilitating experimentation and debugging. We
|
||||
report performance numbers for both these kernels in Figure 1. The performance
|
||||
numbers were collected with a gradient accumulation step of 10 for all batch
|
||||
sizes and configurations, since on average an overall batch size used in
|
||||
practical scenarios range from a few hundred to a few thousand.
|
||||
|
||||
|
||||
{: .align-center}
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 1: Performance evaluation of BERT-Large on a single V100 GPU, comparing
|
||||
DeepSpeed with NVIDIA and HuggingFace versions of BERT in mixed-sequence length
|
||||
training. The labeled points show the highest throughput of each implementation
|
||||
in teraflops (Tflops). DeepSpeed boosts throughput and allows for higher batch
|
||||
sizes without running out-of-memory.
|
||||
|
||||
Looking at distributed training across GPUs, Table 1 shows our end-to-end
|
||||
BERT-Large pre-training time (F1 score of 90.5 for SQUAD) using 16 to 1024 GPUs.
|
||||
We complete BERT pre-training in 44 minutes using 1024 V100 GPUs (64 NVIDIA
|
||||
DGX-2 nodes). In comparison, the previous SOTA from NVIDIA takes 47 mins using
|
||||
1472 V100 GPUs. DeepSpeed is not only faster but also uses 30% less resources.
|
||||
Using the same 1024 GPUS,NVIDIA BERT takes 67 minutes using the same 1024 GPUs
|
||||
[1] BERT, whereas DeepSpeed takes 44 minutes, reducing training time by 30%.
|
||||
Similarly, on 256 GPUs, NVIDIA BERT takes 236 minutes while DeepSpeed takes 144
|
||||
minutes (39% faster).
|
||||
|
||||
| Number of nodes | Number of V100 GPUs | Time |
|
||||
| --------------- | ------------------- | ------------ |
|
||||
| 1 DGX-2 | 16 | 33 hr 13 min |
|
||||
| 4 DGX-2 | 64 | 8 hr 41 min |
|
||||
| 16 DGX-2 | 256 | 144 min |
|
||||
| 64 DGX-2 | 1024 | 44 min |
|
||||
|
||||
Table 1: BERT-Large training time using 1 to 64 DGX-2's with DeepSpeed.
|
||||
|
||||
At the recent GTC 2020, NVIDIA announced the next generation hardware A100,
|
||||
which now offers 2.5X hardware peak performance over the V100 GPU. Assuming
|
||||
the A100 GPU allows us to obtain the same percentage of hardware peak
|
||||
performance (50%) as we obtained on V100 GPUs, we expect to obtain even higher
|
||||
throughput by combining our software optimizations with the new hardware. We
|
||||
project it would reduce BERT training time further to less than 25 minutes on a
|
||||
cluster of 1024 A100 GPUs.
|
||||
|
||||
## Performance Results for Fine-Tuning Tasks
|
||||
|
||||
In addition to the performance benefits we show for the pre-training,
|
||||
we have evaluated the performance of our customized kernel for fine-tuning the
|
||||
downstream tasks. Tables 2 and 3 show the samples-per-second achieved when running
|
||||
Bing-BERT SQuAD on NVIDIA V100 using 16 and 32 GB of memory, using PyTorch and DeepSpeed transformer kernels.
|
||||
For the 16-GB V100, we can achieve up to 1.5x speedup while supporting 2x larger batch size per GPU.
|
||||
On the other hand, we can support as large as 32 batch size (2.6x more than Pytorch) using 32GB of memory, while providing 1.3x speedup for the end-to-end fine-tune training. Note, that we use the best
|
||||
samples-per-second to compute speedup for the cases that PyTorch runs out-of-memory (OOM).
|
||||
|
||||
| Micro batch size | PyTorch | DeepSpeed | Speedup (x) |
|
||||
| ---------------- | ------- | --------- | ----------- |
|
||||
| 4 | 36.34 | 50.76 | 1.4 |
|
||||
| 6 | OOM | 54.28 | 1.5 |
|
||||
| 8 | OOM | 54.16 | 1.5 |
|
||||
|
||||
Table 2. Samples/second for running SQuAD fine-tuning on NVIDIA V100 (16-GB) using PyTorch and DeepSpeed transformer kernels.
|
||||
|
||||
| Micro batch size | PyTorch | DeepSpeed | Speedup (x) |
|
||||
| ---------------- | ------- | --------- | ----------- |
|
||||
| 4 | 37.78 | 50.82 | 1.3 |
|
||||
| 6 | 43.81 | 55.97 | 1.3 |
|
||||
| 12 | 49.32 | 61.41 | 1.2 |
|
||||
| 24 | OOM | 60.70 | 1.2 |
|
||||
| 32 | OOM | 63.01 | 1.3 |
|
||||
|
||||
Table 3: Samples/second for running SQuAD fine-tuning on NVIDIA V100 (32-GB) using PyTorch and DeepSpeed transformer kernels.
|
||||
|
||||
|
||||
## BERT Highly Optimized Transformer Kernels
|
||||
|
||||
GPUs have very high peak floating-point throughput, but the default Transformer
|
||||
blocks in most framework implementations are far from reaching this peak.
|
||||
Figure 2 shows the structure of a Transformer block with the LayerNorm placed
|
||||
on the input stream of the two sublayers: Attention and Feed-Forward. To
|
||||
approach the GPU peak performance, we employ two lines of optimizations in our
|
||||
own Transformer kernel implementation: advanced fusion, and invertible
|
||||
operators.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 2: Transformer Layer with Pre-LayerNorm Architecture
|
||||
|
||||
### (a) Advanced fused kernels to reduce data movement
|
||||
|
||||
We observe that transformer-based networks trigger many invocations of CUDA
|
||||
kernels operating in a producer-consumer fashion, adding a lot of cost for
|
||||
transferring data to and from global memory and overhead from kernel launching.
|
||||
Existing compiler-based approaches perform fine-grained fusion (e.g., fusion of
|
||||
element-wise operations), leading to missed fusion opportunities. In contrast,
|
||||
we fully exploit both fine-grain and coarse-grained fusion, tailored for
|
||||
Transformer blocks.
|
||||
|
||||
**QKV and various fusions.** We merge the three Query (Q), Key (K), and Value (V)
|
||||
weight matrices to dispatch a larger QKV GEMM to expose more parallelism and
|
||||
improve data locality on GPU’s shared memory and register files, as shown in
|
||||
Figure 3. Next, we combine the data-layout transformation of the QKV’s output
|
||||
matrix with the bias addition. We then partition the large QKV matrix into
|
||||
three transformed ones, used for the following self-attention computation.
|
||||
|
||||
As Figure 3 illustrates, we read the QKV matrix in consecutive rows (shown by
|
||||
red box), and write them in the three transformed Q, K, and V matrices. Since
|
||||
each matrix starts from a different offset, we may have uncoalesced access to
|
||||
the main memory. Thus, we use the shared memory as an intermediate buffer, in
|
||||
order to rearrange the data in a way that we can put the data in consecutive
|
||||
parts of memory. Even though we produce an uncoalesced pattern when accessing
|
||||
shared memory, we reduce the cost of uncoalesced access to main memory to
|
||||
better exploit memory bandwidth, resulting in 3% to 5% performance improvement
|
||||
in the end-to-end training.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 3: QKV’s GEMM and transform Kernel-Fusion
|
||||
|
||||
We perform additional fusions such as merging the addition of bias from the
|
||||
attention-output GEMM with the addition from the residual connection and also
|
||||
dropout, which allows accesses to happen in the register files and shared
|
||||
memory, which are orders of magnitude faster than the expensive write-back to
|
||||
the global memory.
|
||||
|
||||
**Warp-level communication.** To alleviate the synchronization overhead among
|
||||
parallel GPU cores and further increase the resource utilization of the fused
|
||||
kernels, we use the warp-level (data shuffle instructions) instead of the
|
||||
default inter-warp communication. Take the layer-normalization and SoftMax
|
||||
kernel as examples, we perform each reduction operation inside a warp, while
|
||||
distributing different reductions across different warps. This way, we
|
||||
alleviate the synchronization among the parallel threads and further increase
|
||||
the GPU resource utilization.
|
||||
|
||||
**Stochastic vs deterministic kernels.** DL training is generally robust to some
|
||||
level of stochasticity, and in some cases, controlled noises such as dropouts
|
||||
act as regularizer which improve generalization. In designing our transformer
|
||||
kernel, we embrace some level of stochasticity to improve throughput by
|
||||
allowing for limited data race conditions to exist in the kernel: We leverage
|
||||
implicit warp synchronous programming to achieve higher performance for the
|
||||
warp-level cooperative operations [3]. The lack of explicit warp level
|
||||
synchronization act as non-deterministic noise without affecting the overall
|
||||
convergence behavior of the transformer kernels while giving a decent
|
||||
throughput boost.
|
||||
|
||||
In addition, DeepSpeed also implements a non-stochastic transformer kernel with
|
||||
explicit warp synchronization that produces deterministic results at the
|
||||
expense of a small performance regression. Users can easily choose and switch
|
||||
between the two versions depending on their usage scenarios: Stochastic version
|
||||
pursues ultimate training performance goal, and deterministic version may save
|
||||
development time by better facilitating experimentation and debugging.
|
||||
|
||||
In our experiments, we use stochastic kernels for the pre-training BERT, while
|
||||
using non-stochastic kernels for fine-tuning to achieve fully reproducible
|
||||
results. We recommend using stochastic kernels for training tasks involving
|
||||
massive amounts of data such as pre-training, while using non-stochastic
|
||||
version when training with limited data such as in the case of fine-tuning for
|
||||
more consistent results.
|
||||
|
||||
**Cost-effective rematerialization.** When fusing kernels of the different
|
||||
operations, we observe that some operators are inexpressive to compute but
|
||||
incur expensive data movement cost, such as addition of bias and dropout. For
|
||||
these operations, we avoid saving their results in the forward pass, but
|
||||
instead recompute them during the backward pass, which turns out to be much
|
||||
faster than having their results written and reloaded from the main memory.
|
||||
|
||||
### (b) Invertible operators to save memory and run large batches
|
||||
|
||||
We also observe that the intermediate activations from several operators in the
|
||||
Transformer blocks incur a large memory consumption, such as SoftMax and Layer
|
||||
Norm. For these operators, we drop the inputs to these layers to reduce the
|
||||
footprint of activation memory, by leveraging the fact that they are invertible
|
||||
functions, which are functions whose backward pass is independent of the inputs
|
||||
and can be formulated based only on the outputs [2]. Figure 4 and Figure 5 show
|
||||
the examples of the original implementation of SoftMax and Layer-Norm in
|
||||
PyTorch versus the invertible SoftMax implementation in DeepSpeed. Through this
|
||||
optimization, we are able to reduce the activation memory of the operator by
|
||||
half, and the reduced memory allows us to train with larger batch sizes, which
|
||||
once again improves GPU efficiency.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 4: DeepSpeed invertible SoftMax operation versus Default PyTorch SoftMax operation
|
||||
|
||||
{: .align-center}
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 5: DeepSpeed invertible LayerNorm operation versus Default PyTorch LayerNorm operation
|
||||
|
||||
## Overlapping I/O with Computation through Asynchronous Prefetching Queue
|
||||
|
||||
Beyond highly optimized transformer kernels, the BERT training has other
|
||||
performance limiting factors, e.g., data loading. We develop our own
|
||||
asynchronous worker which prefetches batches of data into a queue only at “safe
|
||||
points” -- points when the CPUs are idle (e.g., right after asynchronously
|
||||
launching the forward pass). In this way, we make sure that there is no
|
||||
dequeuing and copying data from CPU to GPU when there is computation on the CPU
|
||||
side. This is different from the default PyTorch data loader, which can
|
||||
prefetch data at any points and cause performance interference. By using this
|
||||
method, we hide almost all I/O overhead, which accounts for 4% of the original
|
||||
training time.
|
||||
|
||||
## Exploiting Sparsity of BERT’s Output Processing
|
||||
|
||||
We improve the end-to-end training time by 5.4% by recognizing and exploiting
|
||||
sparsity in BERT’s output processing. The output processing involves two steps:
|
||||
i) BERT projection from the hidden output dimension of the final transformer
|
||||
layer to the language vocabulary, using a matrix-matrix multiplication, and ii)
|
||||
a cross-entropy of the masked output tokens to the get each sequence’s
|
||||
prediction error. The cost of the first step is proportional to the vocabulary
|
||||
size, hidden output dimension and the sequence length, and can be as expensive
|
||||
as a transformer layer computation or more. However, only about 15% of the
|
||||
tokens are masked, and we only need the cross-entropy for the masked tokens.
|
||||
Therefore, the projection can be done as an efficient sparse computation. To do
|
||||
so, we discard the rows of the final transformer layer that corresponding to
|
||||
the non-masked tokens before doing the projection, reducing the computation
|
||||
cost of output processing by 85%.
|
||||
|
||||
## Pre-LayerNorm vs Post-LayerNorm Architecture
|
||||
|
||||
We observe that with large batch size (e.g., 64K) the default BERT pre-training
|
||||
suffers from training instability, which can result in model divergence or
|
||||
convergence to bad/suspicious local optima. Further investigation shows that
|
||||
the default BERT has vanishing gradients issue. To mitigate the issue, we
|
||||
changed the placement of LayerNorm (Post-LayerNorm) by placing it only on the
|
||||
input stream of the sublayers in the Transformer block (called Pre-LayerNorm),
|
||||
a modification described by several recent works for neural machine
|
||||
translation. The Pre-LayerNorm results in several useful characteristics such
|
||||
as avoiding vanishing gradient, stable optimization, and performance gain. It
|
||||
allows us to train at aggregated batch size of 64K with increased learning rate
|
||||
and faster convergence.
|
||||
|
||||
|
||||
To try out these optimizations and training recipe, please check out our [BERT
|
||||
training tutorial](https://www.deepspeed.ai/tutorials/bert-pretraining/) and
|
||||
source code at the [DeepSpeed GitHub
|
||||
repo](https://github.com/deepspeedai/deepspeed).
|
||||
|
||||
### References
|
||||
|
||||
[1] "NVIDIA Clocks World’s Fastest BERT Training Time and Largest Transformer Based Model, Paving Path For Advanced Conversational AI" [https://devblogs.nvidia.com/training-bert-with-gpus/](https://devblogs.nvidia.com/training-bert-with-gpus/).
|
||||
|
||||
[2] S. R. Bulo, L. Porzi, and P. Kontschieder, "In-place activated batch norm for memory-optimized training of dnns" 2017. [http://arxiv.org/abs/1712.02616](http://arxiv.org/abs/1712.02616).
|
||||
|
||||
[3] Mark Harris and Kyrylo Perelygin, "Cooperative Groups: Flexible CUDA Thread Programming", [https://devblogs.nvidia.com/cooperative-groups/]( https://devblogs.nvidia.com/cooperative-groups/).
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
title: "DeepSpeed Microsoft Research Webinar on August 6th, 2020"
|
||||
excerpt: ""
|
||||
tags: presentations English
|
||||
link: https://note.microsoft.com/MSR-Webinar-DeepSpeed-Registration-On-Demand.html
|
||||
image: /assets/images/webinar-aug2020.png
|
||||
date: 2020-07-24 00:00:00
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed Microsoft Research Webinar is now on-demand"
|
||||
excerpt: ""
|
||||
tags: presentations English
|
||||
link: https://note.microsoft.com/MSR-Webinar-DeepSpeed-Registration-On-Demand.html
|
||||
date: 2020-08-07 00:00:00
|
||||
---
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
title: "Powering 10x longer sequences and 6x faster execution through DeepSpeed Sparse Attention"
|
||||
excerpt: ""
|
||||
tags: training English
|
||||
date: 2020-09-09 00:00:00
|
||||
toc: false
|
||||
---
|
||||
|
||||
DeepSpeed offers sparse attention kernels, an instrumental technology to support long sequences of model inputs, whether for text, image, or sound. Compared with the classic dense Transformers, it powers an order-of-magnitude longer input sequence and obtains up to 6x faster execution with comparable accuracy. It also outperforms state-of-the-art sparse implementations with 1.5-3x faster execution. Furthermore, our sparse kernels support efficient execution of flexible sparse format and empower users to innovate on their custom sparse structures.
|
||||
|
||||
* Brief overview, see our [press release]({{ site.press_release_v3 }}).
|
||||
* Detailed technology deep dive, see our [blog post](https://www.deepspeed.ai/2020/09/08/sparse-attention.html).
|
||||
* Tutorial on how to use sparse attention, see our [Sparse attention tutorial](https://www.deepspeed.ai/tutorials/sparse-attention/).
|
||||
* The source code for our sparse attention kernels can be found in the [DeepSpeed repo](https://github.com/deepspeedai/deepspeed) and BERT pre-training code using sparse attention can be found in the [DeepSpeedExamples repo](https://github.com/deepspeedai/deepspeedexamples).
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
---
|
||||
title: "10x bigger model training on a single GPU with ZeRO-Offload"
|
||||
excerpt: ""
|
||||
date: 2020-09-09 00:00:00
|
||||
tags: training ZeRO English
|
||||
toc: false
|
||||
---
|
||||
|
||||
We introduce a new technology called ZeRO-Offload to enable **10X bigger model training on a single GPU**. ZeRO-Offload extends ZeRO-2 to leverage both CPU and GPU memory for training large models. Using a machine with **a single GPU**, our users now can run **models of up to 13 billion parameters** without running out of memory, 10x bigger than the existing approaches, while obtaining competitive throughput. This feature democratizes multi-billion-parameter model training and opens the window for many deep learning practitioners to explore bigger and better models.
|
||||
|
||||
* For more information on ZeRO-Offload, see our [press release]( {{ site.press_release_v3 }} ).
|
||||
* For more information on how to use ZeRO-Offload, see our [ZeRO-Offload tutorial](https://www.deepspeed.ai/tutorials/ZeRO-offload/).
|
||||
* The source code for ZeRO-Offload can be found in the [DeepSpeed repo](https://github.com/deepspeedai/deepspeed).
|
||||
@@ -0,0 +1,141 @@
|
||||
---
|
||||
title: "DeepSpeed with 1-bit Adam: 5x less communication and 3.4x faster training"
|
||||
excerpt: ""
|
||||
date: 2020-09-09 00:00:00
|
||||
tags: training English
|
||||
---
|
||||
|
||||
## 1. Introduction
|
||||
|
||||
Scalable training of large models (like BERT and GPT-3) requires careful optimization rooted in model design, architecture, and system capabilities. From a system standpoint, communication has become a major bottleneck, especially on commodity systems with standard TCP interconnects that offer limited network bandwidth.
|
||||
Communication compression is an important technique to reduce training time on such systems. One of the most effective ways to compress communication is via error compensation compression, which offers robust convergence speed, even under 1-bit compression. However, state-of-the-art error compensation techniques only work with basic optimizers like Stochastic Gradient Descent (SGD) and momentum SGD, which are linearly dependent on the gradients. They do not work with non-linear gradient-based optimizers like Adam, which offers state-of-the-art convergence efficiency and accuracy for many tasks, including training of BERT-like models.
|
||||
For a powerful optimizer like ADAM, the non-linear dependency on gradient (in the variance term) makes it challenging to develop error compensation-based compression techniques, limiting the practical value of the state-of-the-art communication compression techniques.
|
||||
|
||||
|
||||
### 1.1 Background: Classic compression techniques
|
||||
|
||||
One way of communication compression is 1-bit compression, which can be expressed as:
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=x%5Cto%20%5Cfrac%7B%5C%7Cx%5C%7C%7D%7B%5C%7CSign(x)%5C%7C%7DSign(x)">
|
||||
|
||||
With this compression, we could achieve a 32x reduction of memory size by representing each number using one bit. The problem is that using this straightforward method would significantly degrade the convergence speed, which makes this method inapplicable. To solve this problem, recent studies show that by using error compensation compression, we could expect almost the same convergence rate with communication compression.
|
||||
The idea of error compensation can be summarized as: 1) doing compression, 2) memorizing the compression error, and then 3) adding the compression error back in during the next iteration. For SGD, doing error compression leads to:
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=x_t%3D%20x_%7Bt-1%7D%20-%20%5Cgamma%20C(g_t%20%2B%20e_%7Bt-1%7D)%2C%20%5Cquad%20e_t%20%3D%20g_t%2Be_%7Bt-1%7D-C(g_t%2Be_%7Bt-1%7D%20)">
|
||||
|
||||
Where C(⋅) is the 1-bit compression operator. The good thing about doing this error compensation is that the history compression error (e_t and e_(t-1)) would be canceled by itself eventually, which can be seen by:
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=x_t%3Dx_%7Bt-1%7D-%5Cgamma(g_t%2Be_%7Bt-1%7D-e_t%20)">
|
||||
|
||||
|
||||
This strategy has been proven to work for optimization algorithms that are linearly dependent on the gradient, such as SGD and Momentum SGD.
|
||||
|
||||
### 1.2 Challenges in applying error-compensation to Adam
|
||||
We provide an overview of the Adam algorithm below. The update rules are as follows.
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=m_%7Bt%2B1%7D%3D%5Cbeta_1%20m_t%2B(1-%5Cbeta_1%20)%20g_t">
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=v_%7Bt%2B1%7D%3D%5Cbeta_2%20v_t%2B(1-%5Cbeta_2%20)%20(g_t%20)%5E2">
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=x_%7Bt%2B1%7D%3Dx_t-%5Cgamma%20%5Cfrac%7Bm_%7Bt%2B1%7D%7D%7B%5Csqrt%7Bv_%7Bt%2B1%7D%7D%20%2B%5Ceta%7D">
|
||||
|
||||
As shown in the equations above, the variance term v_t is nonlinearly dependent on the gradient g_t. If we apply basic error compensation compression to Adam, we observe that Adam will not converge as shown in Figure 1.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 1: Inapplicability of Error-compensation Compression for Adam due to non-linear dependence on the gradient
|
||||
|
||||
## 2. Compressing communication with 1-bit Adam
|
||||
To compress communication while using the Adam optimizer, we develop 1-bit Adam, which addresses the non-linearity in gradients via preconditioning. We observe that the magnitude of changes on the non-linear term, variance ( v_t), decrease significantly after a few epochs of training and setting v_t constant afterwards will not change the convergence speed. The proposed 1-bit Adam optimizer, as shown in Figure 2, consists of two parts: the warmup stage, which is essentially the vanilla Adam algorithm; and the compression stage, which keeps the variance term constant and compresses the remaining linear term, that is the momentum, into 1-bit representation.
|
||||
|
||||
The compression stage of the algorithm is controlled by a threshold parameter (as shown in Figure 2). When we detect that the change in “variance” falls below a certain threshold, we switch to the compression stage. Our study shows that only 15-20% of the overall training steps are needed for the warmup stage.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 2: Comparison of distributed training steps in classic Adam and the proposed 1-bit compressed Adam algorithm
|
||||
|
||||
### 2.1 How 1-bit Adam works under the hood
|
||||
|
||||
The weight update rule for 1-bit Adam is governed by the following equations.
|
||||
|
||||
For the i-th worker, in the compression stage:
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=m_%7Bt%2B1%7D%5E%7B(i)%7D%3D%5Cbeta_1%20m_t%2B(1-%5Cbeta_1%20)%20g_t%5E%7B(i)%7D">
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=%5Cwidehat%7Bm%7D_%7Bt%2B1%7D%5E%7B(i)%7D%3DC(m_%7Bt%2B1%7D%5E%7B(i)%7D%2Be_t%5E%7B(i)%7D)%2C%20%5Cquad%20e_%7Bt%2B1%7D%5E%7B(i)%7D%3D(m_%7Bt%2B1%7D%5E%7B(i)%7D%2Be_t%5E%7B(i)%7D%20)-%5Chat%7Bm%7D_%7Bt%2B1%7D%5E%7B(i)%7D">
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=m_%7Bt%2B1%7D%5E%7B(ave)%7D%20%3D%20%5Cfrac%7B1%7D%7Bn%7D%5Csum_%7Bi%3D1%7D%5En%20%5Chat%7Bm%7D_%7Bt%2B1%7D%5E%7B(i)%7D">
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=%5Chat%7Bm%7D_%7Bt%2B1%7D%5E%7B(ave)%7D%3DC(m_%7Bt%2B1%7D%5E%7B(ave)%7D%2Be_t%5E%7B(ave)%7D%20)%2C%5Cquad%20%20%20e_%7Bt%2B1%7D%5E%7B(ave)%7D%3D(%5Chat%7Bm%7D_%7Bt%2B1%7D%5E%7B(ave)%7D%2Be_t%5E%7B(ave)%7D%20)-%5Chat%7Bm%7D_%7Bt%2B1%7D%5E%7B(ave)%7D">
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=m_%7Bt%2B1%7D%3D%5Chat%7Bm%7D_%7Bt%2B1%7D%5E%7B(ave)%7D">
|
||||
|
||||
<img src="https://render.githubusercontent.com/render/math?math=x_%7Bt%2B1%7D%3Dx_t-%5Cgamma%20%5Cfrac%7Bm_%7Bt%2B1%7D%7D%7B%5Csqrt%7Bv_%7Bwarmup%7D%7D%2B%5Ceta%7D">
|
||||
|
||||
Where x_t is the model after iteration (t-1), m_t^(i), e_t^(i) are the momentum and compression error on worker i after iteration (t-1), and v_warmup is the variance term after the warmup stage.
|
||||
|
||||
### 2.2 Addressing system challenges for 1-bit Adam
|
||||
|
||||
Besides the algorithmic challenge, there are two system challenges in applying 1-bit Adam in training systems. First, we need efficient kernels that convert the momentum to 1-bit representations. Second, we need efficient communication schemes to exchange this compressed momentum across different GPUs. The goal of compression is to reduce the overall training time so that commodity systems with bandwidth-limited interconnects can be used to train large models. We address these challenges in DeepSpeed and introduce a fully optimized 1-bit Adam implementation for training on communication-constrained systems.
|
||||
|
||||
## 3. Benefits of 1-bit Adam on communication-constrained systems
|
||||
|
||||
1-bit Adam offers the same convergence as Adam, incurs up to 5x less communication that enables up to 3.5x higher throughput for BERT-Large pretraining and up to 2.7x higher throughput for SQuAD fine-tuning. This end-to-end throughput improvement is enabled by the 6.6x (Figure 3) and 6.2x (Figure 4) speedup observed during the compression stage. It is worth mentioning that our 1-bit Adam optimizer scales so well on a 40 Gigabit Ethernet system that its performance is comparable to Adam’s scalability on a 40 Gigabit InfiniBand QDR system. We note that the effective bandwidth on 40 Gigabit Ethernet is 4.1 Gbps based on iperf benchmarks whereas InfiniBand provides near-peak bandwidth of 32Gbps based on InfiniBand perftest microbenchmarks.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 3: Scalability of 1-bit Adam for BERT-Large Pretraining on V100 GPUs with batch size of 16/GPU.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 4: Scalability of 1-bit Adam for SQuAD Finetuning on V100 GPUs with batch size of 3/GPU.
|
||||
|
||||
## 4. Dive deeper into 1-bit Adam evaluation results
|
||||
|
||||
### Same convergence as Adam
|
||||
|
||||
One major question for using 1-bit Adam is the convergence speed, and we find that 1-bit Adam can achieve the same convergence speed and comparable testing performance using the same number of training samples as shown in Figure 5.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 5: 1-bit Adam converges like Adam using the same number of training samples.
|
||||
|
||||
Detailed BERT-Base and BERT-Large results are shown in Table 1. We see that the scores are on par with or better than the original model for both the uncompressed and compressed cases.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Table 1: Verifying correctness of 1-bit Adam on various testing tasks
|
||||
|
||||
Up to 5x less communication: 1-bit Adam provides the same convergence as Adam and reduces the communication volume by 16x during the compression stage for 16-bit (FP16) training. For BERT pretraining, this leads to an overall communication reduction of 5x as we observed the warmup stage to be just 15% of the end-to-end training time.
|
||||
|
||||
The formula to calculate the communication volume ratio of the original versus 1-bit Adam is as follows:
|
||||
|
||||
1 / (warmup + (1 – warmup)/16)
|
||||
|
||||
In the case of warmup equaling 15%, original Adam incurs 5x of the communication as 1-bit Adam.
|
||||
|
||||
### 1-bit Adam is 3.5x faster for training BERT-Large
|
||||
|
||||
We present two main results for training BERT-Large on systems with two different bandwidth-limited interconnects: 1) 40 gigabit Ethernet (Figure 5) and 2) 40 gbps InfiniBand QDR (Figure 6). During the compression phase, we observe up to 6.6x higher throughput on the system with Ethernet and up to 2x higher throughput on the system with InfiniBand, resulting in end-to-end speed up (including both warmup and compression stages) of 3.5x and 2.7x, respectively. The major benefit of 1-bit Adam comes from the communication volume reduction—enabled by our compressed momentum exchange—and from our custom allreduce operation that implements efficient 1-bit communication using non-blocking gather operations followed by an allgather operation.
|
||||
|
||||
It is important to note that one can also increase total batch size to reduce communication using optimizers like LAMB instead of Adam for BERT pretraining. However, 1-bit Adam avoids the need for rigorous hyperparameter tuning, which is often more difficult for large batches from our experience. Furthermore, 1-bit Adam also works very well for workloads that have small critical batch size (cannot converge well with large batch size) like many fine-tuning tasks.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 5: Performance of 1-bit Adam for BERT-Large training on 40 Gbps Ethernet interconnect during the compression stage.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 6: Performance of 1-bit Adam for BERT-Large training on 40 Gbps InfiniBand interconnect during the compression stage.
|
||||
|
||||
### 1-bit Adam is 2.7x faster for SQuAD fine-tuning
|
||||
|
||||
1-bit Adam offers scalability not only on large-scale training tasks but also on tasks like SQuAD fine-tuning. As shown in Figures 7 and 8, 1-bit Adam scales well on both Ethernet- and InfiniBand-based systems and offers up to 6.2x higher throughput (during the compression stage) on the Ethernet-based system, resulting in 2.7x end-to-end speedup (25% warmup plus 75% compression stage). For SQuAD fine-tuning, we observed that a total batch size of 96 offers the best F1 score. Batch sizes larger than this value lower the convergence rate and require additional hyperparameter tuning. Therefore, in order to scale to 32 GPUs, we can only apply a small batch size of 3-4 per GPU. This makes fine-tuning tasks communication intensive and hard to scale. 1-bit Adam addresses the scaling challenge well, obtaining 3.4x communication reduction without enlarging batch size, and it results in a 2.7x end-to-end speedup.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 7: Performance of 1-bit Adam for SQuAD fine-tuning on 40 gbps Ethernet during the compression stage.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 8: Performance of 1-bit Adam for SQuAD fine-tuning on 40 gbps InfiniBand interconnect during the compression stage.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: "Up to 5x less communication and 3.4x faster training through 1-bit Adam"
|
||||
excerpt: ""
|
||||
date: 2020-09-09 00:00:00
|
||||
tags: training English
|
||||
toc: false
|
||||
---
|
||||
|
||||
|
||||
Adam is an effective and probably the most well-utilized optimizer for
|
||||
training many large-scale deep learning models. However, Adam is generally
|
||||
not compatible with communication-efficient optimization algorithms, and
|
||||
therefore the communication cost could become a bottleneck while scaling
|
||||
across distributed devices. We introduce a new algorithm - 1-bit Adam - and
|
||||
its efficient implementation in DeepSpeed. 1-bit Adam offers the ***same convergence*** as Adam, incurs up to ***5x less communication*** that enables up to ***3.5x higher throughput for BERT-Large pretraining*** and up to ***2.7x higher throughput for SQuAD fine-tuning*** on bandwidth-limited clusters.
|
||||
|
||||
* Brief overview, see our [press release]({{ site.press_release_v3 }}).
|
||||
* Detailed technology deep dive, see our [blog post](https://www.deepspeed.ai/2020/09/08/onebit-adam-blog-post.html).
|
||||
* Tutorial on how to reproduce our results, see our [1-bit Adam tutorial](/tutorials/onebit-adam/).
|
||||
* The source code for 1-bit Adam can be found in the [DeepSpeed repo](https://github.com/deepspeedai/deepspeed). The implementation of 1-bit Adam is in [onebit_adam.py](https://github.com/deepspeedai/DeepSpeed/blob/master/deepspeed/runtime/fp16/onebit_adam.py) and CUDA-Aware communication for 1-bit Adam is in [custom_collectives.py](https://github.com/deepspeedai/DeepSpeed/blob/master/deepspeed/runtime/custom_collectives.py). Example codes to try this feature can be found in the [DeepSpeedExamples repo](https://github.com/deepspeedai/deepspeedexamples) as shown in the [tutorial](/tutorials/onebit-adam/).
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: "Training a Trillion Parameters with Pipeline Parallelism"
|
||||
excerpt: ""
|
||||
date: 2020-09-09 00:00:00
|
||||
tags: training English
|
||||
---
|
||||
|
||||
DeepSpeed includes new support for pipeline parallelism! DeepSpeed's training
|
||||
engine provides hybrid 3D parallelism for training models with over a
|
||||
trillion parameters. In addition to scaling to the extreme, we have
|
||||
demonstrated that hybrid parallelism accelerates training on clusters with
|
||||
low-bandwidth network by up to 7x.
|
||||
|
||||
* For a brief overview and results including trillion-parameter capabilities,
|
||||
see our [press release]({{ site.press_release_v3 }}).
|
||||
* To get started with pipeline parallel training in DeepSpeed, we recommend our [tutorial](/tutorials/pipeline/).
|
||||
* See our AlexNet example in [DeepSpeedExamples](https://github.com/deepspeedai/DeepSpeedExamples).
|
||||
* Read our API documentation on [readthedocs](https://deepspeed.readthedocs.io/en/latest/pipeline.html).
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
title: "DeepSpeed Sparse Attention"
|
||||
excerpt: ""
|
||||
date: 2020-09-09 01:00:00
|
||||
tags: training inference English
|
||||
---
|
||||
|
||||
Attention-based deep learning models such as the transformers are highly effective in capturing the relationship between tokens in an input sequence, even across long distances. As a result, they are used with text, image, and sound-based inputs, where the sequence length can be in thousands of tokens. However, despite the effectiveness of attention modules to capture long term dependencies, in practice, their application to long sequence input is limited by compute and memory requirements of the attention computation that grow quadratically, `O(n^2)`, with the sequence length `n`.
|
||||
|
||||
To address this limitation, DeepSpeed offers a suite of sparse attention kernels --an instrumental technology that can reduce the compute and memory requirement of attention computation by orders-of-magnitude via block-sparse computation. The suite not only alleviates the memory bottleneck of attention calculation, but also performs sparse computation efficiently. Its APIs allow convenient integration with any transformer-based models. Along with providing a wide spectrum of sparsity structures, it has the flexibility of handling any user-defined block-sparse structures. More specifically, sparse attention (SA) can be designed to compute local attention between nearby tokens, or global attention via summary tokens computed with local attention. Moreover, SA can also allow random attention, or any combination of local, global, and random attention as shown in the following figure with blue, orange, and green blocks, respectively. As a result, SA decreases the memory footprint to `O(wn)`, in which `1 < w < n` is a parameter, whose value depends on the attention structure.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
This library is PyTorch based and develops required kernels through [Triton](https://github.com/ptillet/triton) platform; kernels are not written in CUDA, which leaves the door open for CPU/OpenCL/Vulkan support in the future. The library is an extension to DeepSpeed and can be used through DeepSpeed as well as stand alone.
|
||||
Block-sparse computations handled by DeepSpeed Sparse Attention kernels are illustrated in following figures for forward and backward passes respectively. In the figures, `S` stands for a `block-sparse matrix` and `D` a `dense matrix`.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
{: .align-center}
|
||||
|
||||
To learn more about Sparsity Config, and also how to use this library, please check our [tutorial](/tutorials/sparse-attention/) that provides detailed information about it.
|
||||
|
||||
## Performance Results
|
||||
|
||||
* **Power over 10x longer sequences**
|
||||
In a pre-training experiment, we ran BERT model under three settings: dense, dense with activation checkpoint, and sparse (SA) with activation checkpoint. SA empowers 10x and 16x longer sequences comparing with dense for BERT base and large, respectively. Following figure shows the longest sequence length runnable in BERT base and large model; experiment is performed with batch size 1 on a single NVIDIA V100 GPU-32GB memory.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
* **Up to 6.3x faster computation**
|
||||
We continued the pre-training experiment for different batch sizes and sequence lengths, using [BERT base/large](https://github.com/deepspeedai/DeepSpeedExamples/tree/master/bing_bert) and [Megatron GPT2](https://github.com/deepspeedai/DeepSpeedExamples/tree/master/Megatron-LM). In this experiment we let the training to continue for 100 iteration and recorded the average time per last 30 iterations. SA reduces total computation comparing with dense and improves training speed: the boost is higher with increased sequence length and it is up to 6.3x faster for BERT base, 5.3x for BERT large, and 6.1x for GPT2. Following charts show these results.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
{: .align-center}
|
||||
|
||||
{: .align-center}
|
||||
|
||||
* **Higher accuracy**
|
||||
Related works along the line of sparse attention ([Sparse Transformer](https://arxiv.org/pdf/1904.10509.pdf), [Longformer](https://arxiv.org/pdf/2004.05150.pdf), [BigBird](https://arxiv.org/pdf/2007.14062.pdf)) have shown comparable or higher accuracy than full attention. Our experience is well aligned. In addition to lower memory overhead and faster computation, we also observe cases in production where SA reaches higher accuracy and faster convergence. The following chart illustrates accuracy of training a production model based on BERT for long document comprehension (2,048 sequence length). The experiment is performed in three settings: dense starting from scratch, SA starting from scratch, and SA continued training from a checkpoint of using dense with sequence length of 512. We have observed that, for pre-training from scratch, SA converges faster with higher accuracy comparing with dense. Furthermore, SA continuing training from a pre-trained checkpoint performs even better, with respect to both time and accuracy.
|
||||
|
||||
|
||||
{: .align-center}
|
||||
|
||||
|
||||
* **Comparison with state of the art, Longformer**
|
||||
We compared SA with Longformer, a state-of-the-art sparse structure and implementation. In our experiment, SA uses `Fixed` sparsity, and two implementations have comparable accuracy. On system performance, SA outperforms Longformer both in training and inference:
|
||||
* **1.47x** faster execution pre-training MLM on Wikitext103
|
||||
We ran an experiment following the [notebook](https://github.com/allenai/longformer/blob/master/scripts/convert_model_to_long.ipynb) offered by Longformer. In this experiment, we pre-train an MLM model using RoBERTa-base checkpoint. This is done on 8 V100-SXM2 GPU. Following table shows the details of the result in which using DeepSpeed Sparse Attention shows 1.47x speed up.
|
||||
|
||||
|Model |Local Window Size |BPC |Train Step |Time Per Iteration |Time Improvement |Accuracy improvement |
|
||||
|-------------------|------------------|--------|------------|--------------------|------------------|----------------------|
|
||||
|RoBERTa Checkpoint | |2.5326 | |
|
||||
|Longformer |512 |2.6535 |0 | |1.47 |1.01 |
|
||||
|Sparse Attention | |2.6321 | | | | |
|
||||
|Longformer | |1.6708 |3k |1.6280 | |1.01 |
|
||||
|Sparse Attention | |1.6613 | |1.1059 | | |
|
||||
|Longformer |64 |5.7840 |0 | |1.31 |1.46 |
|
||||
|Sparse Attention | |3.9737 | | | | |
|
||||
|Longformer | |2.0466 |3k |1.4855 | |1.09 |
|
||||
|Sparse Attention | |1.8693 | |1.1372 | | |
|
||||
|
||||
|
||||
* **3.13x** faster execution inference on BERT-Base
|
||||
Through our Long Document Comprehension application we described above, we also checked the inference time for different window sizes testing BERT model on a `2,048` Sequence Length and batch size `1`. In this experiment, we noticed up to `3.13X` speed up replacing Bert Attention with DeepSpeed Sparse Attention instead of Longformer Attention. Following table shows the complete result.
|
||||
|
||||
|Local Window Size |Time Improvement|
|
||||
|--------------------|----------------|
|
||||
|512 |3.13 |
|
||||
|256 |2.29 |
|
||||
|128 |2.16 |
|
||||
|64 |1.5 |
|
||||
|32 |1.24 |
|
||||
|16 |1.23 |
|
||||
|
||||
* **Flexibility to handle any block-sparse structure**
|
||||
DeepSpeed Sparse Attention suite does not target at any specific sparse structure but enables model scientists to explore any block sparse structure with efficient system support. Currently, we have added popular sparse structure like:
|
||||
* [Fixed](https://arxiv.org/pdf/1904.10509.pdf) (from OpenAI Sparse Transformer)
|
||||
* [BigBird](https://arxiv.org/pdf/2007.14062.pdf) (from Google)
|
||||
* BSLongformer (Block-Sparse implementation of [Longformer](https://arxiv.org/pdf/2004.05150.pdf) from AI2)
|
||||
|
||||
We also define a template to have `variable` structure (top figure), which can be used to simply customize any block-sparse random/local/global attention pattern. In addition to this list, user can add any other sparsity structure as described in [tutorial](https://www.deepspeed.ai/tutorials/sparse-attention/) section.
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
title: "Progressive Layer Dropping"
|
||||
excerpt: ""
|
||||
date: 2020-10-29 00:00:00
|
||||
tags: training English
|
||||
toc: false
|
||||
---
|
||||
|
||||
We introduce a new technology called progressive layer dropping (PLD) to speedup the pre-training of Transformer-based networks through efficient and robust compressed training. The pre-training step of Transformer networks often suffer from unbearable overall computational expenses. We analyze the training dynamics and stability of Transformer networks and propose PLD to sparsely update Transformer blocks following a progressive dropping schedule, which smoothly increases the layer dropping rate for each mini-batch as training evolves along both the temporal and the model depth dimension. PLD is able to allow the pre-training to be **2.5X faster** to get similar accuracy on downstream tasks and allows the training to be **24% faster** when training the same number of samples, not at the cost of excessive hardware resources.
|
||||
|
||||
* For detailed technology deep dive, see our [technical report](https://arxiv.org/pdf/2010.13369.pdf).
|
||||
* For more information on how to use PLD, see our [Progressive layer dropping tutorial](https://www.deepspeed.ai/tutorials/progressive_layer_dropping/).
|
||||
* The source code for PLD is now available at the [DeepSpeed repo](https://github.com/deepspeedai/deepspeed).
|
||||
@@ -0,0 +1,98 @@
|
||||
---
|
||||
title: "DeepSpeed ZeRO-3 Offload"
|
||||
excerpt: ""
|
||||
date: 2021-03-08 00:00:00
|
||||
tags: training ZeRO English
|
||||
---
|
||||
Today we are announcing the release of ZeRO-3 Offload, a highly efficient and easy to use implementation of ZeRO Stage 3 and ZeRO Offload combined, geared towards our continued goal of democratizing AI by making efficient large-scale DL training available to everyone. The key benefits of ZeRO-3 Offload are:
|
||||
|
||||
* Unprecedented memory efficiency to run very large models on a limited number of GPU resources - e.g., fine-tune models with over 40B parameters on a single GPU and over 2 Trillion parameters on 512 GPUs!
|
||||
* Extremely Easy to use:
|
||||
* Scale to over a trillion parameters without the need to combine multiple parallelism techniques in complicated ways.
|
||||
* For existing DeepSpeed users, turn on ZeRO-3 Offload with just a few flags in DeepSpeed Config file.
|
||||
* High-performance per-GPU throughput and super-linear scalability across GPUs for distributed training.
|
||||
* With 1 Trillion parameters, ZeRO-3 Offload sustains 25 PetaFlops in compute performance on 512 NVIDIA V100 GPUs, achieving 49 TFlops/GPU.
|
||||
* Up to 2x improvement in throughput compared to ZeRO- 2 Offload on single GPU
|
||||
|
||||
|
||||
<h2> Overview of ZeRO family of technology </h2>
|
||||
|
||||
The ZeRO Redundancy Optimizer (abbreviated ZeRO) is a family of memory optimization technologies for large-scale distributed deep learning. Unlike data parallelism (that is efficient but can only support a limited model size) or model parallelism (that can support larger model sizes but requires significant code refactoring while adding communication overhead that limits efficiency), ZeRO allows fitting larger models in memory without requiring code refactoring while remaining very efficient. ZeRO does so by eliminating the memory redundancy that is inherent in data parallelism while limiting the communication overhead to a minimum.
|
||||
ZeRO removes the memory redundancies across data-parallel processes by partitioning the three model states (optimizer states, gradients, and parameters) across data-parallel processes instead of replicating them. By doing this, it boosts memory efficiency compared to classic data-parallelism while retaining its computational granularity and communication efficiency.
|
||||
There are three stages in ZeRO corresponding to three model states, as shown in the Figure 1: the first stage (ZeRO-1) partitions only the optimizer states, the second stage (ZeRO-2) partitions both the optimizer states and the gradients and the final stage (ZeRO-3) partitions all three model states (for more details see the ZeRO [paper](https://arxiv.org/abs/1910.02054v3)).
|
||||
|
||||
<a href="/assets/images/zero3-offload-memory-overview.png">
|
||||
<img src="/assets/images/zero3-offload-memory-overview.png">
|
||||
</a>
|
||||
Figure 1. Overview of ZeRO memory savings
|
||||
|
||||
In addition to these three stages, ZeRO family of technology also consists of ZeRO-2 Offload. ZeRO-2 Offload is a heterogeneous DL training technology that works in conjunction with ZeRO-2 to offload partitioned optimizer states and gradients to CPU memory. ZeRO-2 Offload offers the full memory advantage of ZeRO-2 even on a single GPU, while at the same time offering great scalability of ZeRO-2 on multi-GPU setup. DeepSpeed library has been offering ZeRO-2 Offload since Sept 2020. For details, please see below:
|
||||
|
||||
* ZeRO: [Stage 1 blog](https://www.microsoft.com/en-us/research/blog/ZeRO-2-deepspeed-shattering-barriers-of-deep-learning-speed-scale/), [Stage 2 blog](https://www.microsoft.com/en-us/research/blog/ZeRO-2-deepspeed-shattering-barriers-of-deep-learning-speed-scale/), [Tutorial](/tutorials/ZeRO)
|
||||
* ZeRO-Offload: [Blog](https://www.microsoft.com/en-us/research/blog/deepspeed-extreme-scale-model-training-for-everyone/#toc-heading-3), [Tutorials](/tutorials/ZeRO-offload), [Paper link](https://arxiv.org/abs/2101.06840)
|
||||
|
||||
<h2>ZeRO-3 Offload</h2>
|
||||
With today’s release of ZeRO-3 Offload, we are adding support for partitioning and offloading parameters in addition to optimizer states and gradients partitioning already supported by ZeRO-2 Offload in DeepSpeed. With parameter partitioning ZeRO-3 Offload implements the full set of features in the three stages of ZeRO, that allows for a linear growth in model size with the number of GPUs. In addition, ZeRO-3 Offload can also optionally offload all these model states to CPU to further reduce GPU memory consumption, leveraging both CPU and GPU to maximize memory and compute efficiency of the entire system.
|
||||
|
||||
We believe ZeRO-3 Offload offers a massive leap for large model training, in three regards:
|
||||
|
||||
i) Unprecedented model scale,
|
||||
|
||||
ii) Ease of supporting very-large models, and
|
||||
|
||||
iii) Achieving excellent training efficiency.
|
||||
|
||||
|
||||
<h2>Unprecedented model scale</h2>
|
||||
Unlike ZeRO-2 and ZeRO-Offload where the parameters have to fit in the memory of a single GPU, ZeRO-3 Offload can partition the parameters across GPUs, and offload them to CPU, supporting model sizes that are much larger than the memory on a single GPU. Furthermore, ZeRO-3 Offload goes beyond the state-of-the-art hybrid 3D-parallelism (data, model and pipeline parallelism combined). While 3D Parallelism is limited by the aggregate GPU memory, ZeRO-3 Offload can exploit both GPU and CPU memory, the latter of which is much larger and cheaper compared to GPU memory. This allows ZeRO-3 Offload to train larger model sizes with the given GPU and CPU resources than any other currently available technology.
|
||||
|
||||
<i>Model Scale on Single GPU</i>: ZeRO-3 Offload can train models with over 40B parameters efficiently on a single GPU (e.g., 32GB V100 GPU + 1.5TB CPU memory). This is 3x larger than what is possible with ZeRO-2 Offload, the current state-of-the art.
|
||||
|
||||
<i>Model Scale on Multi-GPUs</i>: With ZeRO-3 Offload you can train a trillion and two trillion parameter models on NVIDIA 32GB V100 DGX-2 cluster with 256 GPUs and 512 GPUs, respectively. In contrast, the state-of-art 3D Parallelism requires 800 GPUs, and 1600 GPUs, respectively, to fit the same sized models. This represents a 3x reduction in GPUs required to fit models with over a trillion parameters.
|
||||
|
||||
<h2>Ease of supporting very large models</h2>
|
||||
From a system perspective, training models with hundreds of billions and trillions of parameters is extremely challenging. Data parallelism cannot scale the model size much further beyond a billion parameters, model parallelism (with tensor slicing) cannot be used to scale model size efficiently beyond a single node boundary due to massive communication overheads, and pipeline parallelism cannot scale beyond the number of layers available in a model, which limits both the model size and the number of GPUs that it can scale to.
|
||||
|
||||
The only existing parallel technology available that can scale to over a trillion parameters on massively parallel GPU clusters is the [3D parallelism](https://www.microsoft.com/en-us/research/blog/deepspeed-extreme-scale-model-training-for-everyone/#toc-heading-0) that combines data, model and pipeline parallelism in complex ways. While such a system can be very efficient, it requires major model code refactoring from data scientists to split the model into load balanced pipeline stages. This also makes 3D parallelism inflexible in the type of models that it can support, since models with complex dependency graphs cannot be easily converted into a load balanced pipeline.
|
||||
|
||||
ZeRO-3 Offload address these challenges in two ways:
|
||||
|
||||
i) With ground-breaking memory efficiency, ZeRO-3 and ZeRO-3 Offload are the only DL parallel technology that can efficiently scale to over a trillion parameters by itself, without requiring a hybrid parallelism strategy, greatly simplifying the system stack for DL training.
|
||||
|
||||
ii) ZeRO-3 Offload requires virtually no model refactoring from model scientists, liberating data scientists to scale up complex models to hundreds of billions to trillions of parameters.
|
||||
|
||||
<h2>Excellent training efficiency</h2>
|
||||
<i>High-performance per-GPU throughput on multiple nodes</i>: ZeRO-3 Offload offers excellent training efficiency for multi-billion and trillion parameter models on multiple nodes. It achieves a sustained throughput of up to 50 Tflops per GPU running on 32 DGX2 nodes comprising 512 NVIDIA V100 GPUs (see Figure 2). In comparison, the standard data parallel training with PyTorch can only achieve 30 TFlops per GPU for a 1.2B parameter model, the largest model that can be trained using data parallelism alone.
|
||||
|
||||
<a href="/assets/images/zero3-offload-512-v100.png">
|
||||
<img src="/assets/images/zero3-offload-512-v100.png">
|
||||
</a>
|
||||
Figure 2. ZeRO-3 Offload: Multi-billion and trillion parameter model throughput on 512 V100 GPUs
|
||||
|
||||
ZeRO-3 Offload obtains high efficiency despite the 50% communication overhead of ZeRO Stage 3 compared to standard data parallel training for a fixed batch size. This is made possible through a communication overlap centric design and implementation, which allows ZeRO-3 Offload to hide nearly all of the communication volume with computation, while taking advantage of a larger batch size for improved efficiency resulting from better GPU memory efficiency.
|
||||
|
||||
|
||||
<i>Efficient multi-billion parameter model training on a single GPU</i>: ZeRO-3 Offload further democratizes AI by enabling efficient training of multi-billion parameter models on a single GPU. For single GPU training, ZeRO-3 Offload provides benefits over ZeRO-2 Offload along two dimensions. First, ZeRO-3 Offload increases the size of models trainable on a single V100 from 13B to 40B. Second, for ZeRO-3 Offload provides speedups (e.g., 2.3X for 13B) compared to ZeRO-2 Offload for model sizes trainable by both solutions. These results are summarized in Figure 3.
|
||||
|
||||
<a href="/assets/images/zero3-offload-1-v100.png">
|
||||
<img src="/assets/images/zero3-offload-1-v100.png">
|
||||
</a>
|
||||
Figure 3. Multi-billion parameter model training on one V100 GPU
|
||||
|
||||
<i>Super-Linear scalability across GPUs</i>: Additionally, ZeRO-3 Offload also preserves the super-linear scalability characteristics that we have demonstrated with all our previous ZeRO technologies (ZeRO Stage 1, ZeRO Stage 2 and ZeRO Offload). ZeRO-3 Offload can exploit the aggregate PCI-E bandwidth between GPU and CPU across all the GPUs in multi-GPU training configuration, and at the same time, it can also exploit the aggregate CPU compute across all the nodes. As a result, the CPU-GPU-CPU communication time as well as the optimizer update time decreases linearly with number of GPUs and nodes, respectively, allowing ZeRO-3 Offload to exhibit super-linear scaling (see Figure 4).
|
||||
|
||||
<a href="/assets/images/zero3-offload-200B-scalability.png">
|
||||
<img src="/assets/images/zero3-offload-200B-scalability.png">
|
||||
</a>
|
||||
Figure 4. ZeRO-3 Offload Superlinear Scalability for a 200B parameter model.
|
||||
|
||||
<h2>How to use ZeRO-3 Offload</h2>
|
||||
As with many other existing DeepSpeed features, once the user model has been converted to use DeepSpeed, enabling ZeRO-3 Offload is as easy as turning on a couple of flags in DeepSpeed Config file. Supporting advanced features like weight sharing, or enabling extremely large models that requires to be partitioned across GPUs/nodes to fit in GPU/CPU memory, can be done with just a couple of additional lines of code change using the ZeRO-3 Offload API.
|
||||
|
||||
If you are already a DeepSpeed user, you can find our detailed tutorial on ZeRO-3 Offload below. If you are new to DeepSpeed, we recommend that you start at the getting started page before trying out our ZeRO-3 Offload Tutorial.
|
||||
|
||||
* DeepSpeed: [Getting Started Page](/getting-started/)
|
||||
|
||||
* ZeRO-3 Offload [Documentation](https://deepspeed.readthedocs.io/en/latest/zero3.html), [Tutorial](/tutorials/ZeRO/#training-trillion-scale-models-with-ZeRO-3-offload)
|
||||
|
||||
The DeepSpeed Team is very excited to share ZeRO-3 Offload with the DL community.
|
||||
@@ -0,0 +1,60 @@
|
||||
---
|
||||
title: "Mixture-of-Quantization: A novel quantization approach for reducing model size with minimal accuracy impact"
|
||||
excerpt: ""
|
||||
date: 2021-05-05 00:00:00
|
||||
tags: inference English
|
||||
---
|
||||
|
||||
## A unified suite for quantization-aware training and inference
|
||||
|
||||
Running large-scale models on multi-GPU might help reduce latency but increases the deployment cost significantly, especially as the model size grows bigger. To mitigate this issue, we resort to model compression techniques and introduce a new methodology that quantizes Transformer networks with a minimal impact on accuracy. Our technique achieves similar or better performance thanFP16 models through customized inference kernels on lower or equal number of GPUs.
|
||||
|
||||
Our scheme is flexible in the sense that it provides users the ability to experiment with any quantization configuration, such as the target number of bits used for quantization precision, and the scheduling by which the model gets quantized during training. Furthermore, we combine both the FP16 and quantized precision as a mixed-precision mechanism to smooth the transition from a high to low precision. Finally, we use the second-order gradient (eigenvalue) of the parameters to adjust the quantization schedule during training.
|
||||
|
||||
## Quantization methodology
|
||||
|
||||
There are two main approaches of applying quantization: offline quantization on the trained model and quantization-aware training (QAT) that reduces the data-precision during training. Unlike the former scheme, QAT gets the model trained by taking the impact of precision loss into account during the training optimization. This will result in significant improvement of the quantized model accuracy. MoQ is designed on top QAT approach, with the difference that we use a mixture of precisions to train the model toward target quantization, as well as defining a scheduling for reducing the precision.
|
||||
|
||||
All existing QAT approaches quantize the model with a certain precision (number of bits) from the beginning of training until completion. However, even by using a relatively high quantization precision (8-bit), there will be some drop in model accuracy, which might not be acceptable for some downstream tasks. For instance, the [Q8BERT](https://arxiv.org/abs/1910.06188v1) work tries QAT for the BERT network, which results in good accuracy for some tasks while others (like SQuAD) lose 0.8% in the F1 score. Other techniques, such as [Q-BERT](https://arxiv.org/abs/1909.05840v1Q-BERT), use grouped quantization with a large grouping size (128) when quantizing a parameter matrix to gain higher accuracy, but they are still inferior to the baseline.
|
||||
|
||||
Here, we present MoQ as a flexible solution for linear quantization that allows users to define a schedule as the model trains. Similar to iterative pruning to inject sparsity, we start quantization from a higher precision (16-bit quantization or FP16) and gradually reduce the quantization bits or the mixed-precision ratio for the FP16 part until reaching a target precision (8-bit). To control the precision transition, we define a hyperparameter, called quantization period, that indicates when the precision reduction should happen. We observe that by using such a schedule, we get the closest accuracy to the baseline. Note that in order to reach a certain precision, we need to define the starting bits and period in a way that within the number of samples to train, the model eventually gets quantized using the target number of bits. Please refer to the quantization tutorial for more information.
|
||||
|
||||
In order to dynamically adjust quantization precision, we employ eigenvalue as a metric that shows the sensitivity of training to the precision change. Eigenvalue has been previously used ([Q-BERT](https://arxiv.org/abs/1909.05840v1Q-BERT)) for quantization to choose the precision bits on different parts of the network. To combine this with MoQ, we cluster the eigenvalues into several regions based on their absolute values and tune the quantization period for each region accordingly, the higher the magnitude of eigenvalue, the larger the factor and the slower the precision decreases.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 1. Quantization scheduling of one of the GLUE tasks (QNLI), using the eigenvalue of different layers. Different colors show the layers from 0 to 11 for Bert-Base.
|
||||
|
||||
Figure 1 shows the result of combining eigenvalue with MoQ for a 12-layer Bert Base model. As we see, the first few layers (0-4) tend to be more sensitive to reduced precision than the last layers, as their quantization period is an order of magnitude larger than the rest. Another observation from this figure is that the neighbor layers reduce the precision in the same way. For instance, layers 9, 10, and 11 on the left chart, and layers 0 and 4 and 1 and 3 on the right chart of Figure 1 get similar schedule. This is due to having similar eigenvalues for these layers throughout the training.
|
||||
|
||||
{: .align-center}
|
||||
Figure 2: Mixed-precision quantization for the QNLI using target quantization period as 4 bits.
|
||||
|
||||
Figure 2 shows another mixed-precision quantization that sets target bits as 4, however the quantization period keeps updated through the eigenvalues of each layer. As we see, the end quantization bits are different for all layers. The first layers still get to 8-bit quantization as the training samples is not enough to decrease the quantization bits. On the other hand, the last layers keep reducing the precision. We finally reduce the average precision to 6 bits for the entire network while maintaining the accuracy of the model (0.3% drop in accuracy).
|
||||
|
||||
{: .align-center}
|
||||
Figure 3: Mixed-precision quantization with MoQ for Bert SQuAD plus.
|
||||
|
||||
As another example, we use eigenvalue-based MoQ to quantize Bert-Large for SQuAD finetuning. Figure 3 shows the number of bits we get to at the end of finetuning on each layer. Here, we see slightly different precision spectrum compared to BertBase on GLUE tasks. As the figure shows, we can reduce the precision on the first few layers more aggressively than the middle ones. Also, the last few layers can tolerate very low precision similar to the beginning layers. This way of quantization finally results in 90.56 F1 Score which is pretty similar to the baseline.
|
||||
|
||||
## Quantized Inference Kernels
|
||||
|
||||
By using other quantization methodologies, after the model is quantized, it can only have performance benefit if there is hardware support for integer-based operations. For this reason, the inputs and output of all GeMM operations need to be quantized. However, since the range of input may vary request by request, finding a range of data for each input at inference time is challenging. On the other hand, using a static range for all inputs can impact the inference accuracy.
|
||||
|
||||
To alleviate this problem, we introduce inference custom kernels that neither require the hardware support nor the input quantization. These kernels read quantized parameters and dequantize them on-the-fly and use the floating-point units of GPU cores for the GeMM operations. The main benefit of using these kernels is that they reduce the memory footprint required to load a model so that we can run inference on fewer number of GPUs, while improving the performance by saving the memory bandwidth required to run the inference on GPU.
|
||||
|
||||
Regarding the quantization implementation, we use different algorithms to quantize a value based on the range of data and the rounding policy. We support both symmetric and asymmetric quantization as the two mostly used schemes. We applied both techniques for QAT and see very similar results, however since symmetric approach is simpler to implement, we implement our inference kernels based on that. Regarding the rounding, we support [stochastic rounding](https://arxiv.org/abs/1502.02551) as another option besides the normal rounding. We have seen that for reducing the precision to as low as 4-bit or lower, stochastic rounding is more helpful as it has an unbiased random behavior during training.
|
||||
|
||||
## Ease of use
|
||||
|
||||
For enabling quantization through Deepspeed, we only need to pass the scheduling through a JSON configuration file. To add the impact of quantization, we quantize and dequantize the parameters just before they are updated in the optimizer. Thus, we do not incur any change on the modeling side to quantize a model. Instead, we simulate the quantization impact by lowering the precision of data saved in FP16 format. By using this kind of implementation, we have the full flexibility of changing the precision using the training characteristics such as number of steps, and eigenvalue of the parameters and the original FP16 data format. As shown in this blog post, we can improve the quality of a quantized model by adaptively changing the scheduling of the quantization throughout training. For more information on how to use MoQ scheme, please look at our [quantization tutorial](https://www.deepspeed.ai/tutorials/MoQ-tutorial/).
|
||||
|
||||
## Improving quantization accuracy.
|
||||
|
||||
To show how our quantization scheme preserves accuracy, we have experimented MoQ on several tasks and networks: GLUE tasks on Bert-Base and SQuAD on Bert-Large. Table 1 shows the accuracy results for the baseline without quantization (w/o Quant), basic quantization without using any scheduling during training (Basic Quant), and our MoQ scheme. Without using any scheduling, the accuracy for 8-bit quantization is often inferior to the baseline, and in this workload, it suffers from a drop of 1.02 point in accuracy (ACC). In contrast, MoQ powers 8-bit quantization to obtain comparable accuracy as the FP16 baseline, even with a slightly higher ACC, demonstrating the effectiveness of our quantization approach.
|
||||
|
||||
|Task |STSB |MRPC |COLA |WNLI |SST2 |RTE |QNLI |QQP |MNLI |SQuAD|ACC+ |
|
||||
|-------------|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|
|
||||
|w/o QAT(FP16)|88.71|88.12|56.78|56.34|91.74|65.3 |90.96|90.67|84.04|90.56|0 |
|
||||
|Basic QAT |88.9 |88.35|52.78|55.3 |91.5 |64.2 |90.92|90.59|84.01|90.39|-0.87|
|
||||
|MoQ |88.93|89|59.33|56.34|92.09 |67.15 |90.63|90.94|84.55|90.71|0.75 |
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: "DeepSpeed Inference: Multi-GPU inference with customized inference kernels and quantization support"
|
||||
excerpt: ""
|
||||
date: 2021-03-16 00:00:00
|
||||
tags: inference English
|
||||
---
|
||||
While DeepSpeed supports training advanced large-scale models, using these trained models in the desired application scenarios is still challenging due to three major limitations in existing inference solutions: 1) lack of support for multi-GPU inference to fit large models and meet latency requirements, 2) limited GPU kernel performance when running inference with small batch sizes, and 3) difficulties in exploiting quantization, which includes both quantizing the model to reduce the model size and latency as well as supporting high-performance inference of quantized models without specialized hardware.
|
||||
|
||||
To handle these challenges, we introduce DeepSpeed Inference, which seamlessly adds high-performance inference support to large models trained in DeepSpeed with three key features: inference-adapted parallelism for multi-GPU inference, inference-optimized kernels tuned for small batch sizes, and flexible support for quantize-aware training and inference kernels for quantized models.
|
||||
|
||||
## Multi-GPU Inference with Adaptive Parallelism
|
||||
|
||||
Parallelism is an effective approach to fit large models and reduce per-device memory consumption for both training and inference. However, simply applying training parallelism choices and degree to inference does not work well. The MP and PP configuration is normally set during the model training, apart from the data parallelism (DP), based on the memory footprint and computation style, and resource budget. On one hand, inference computation intrinsically requires less memory, so it can afford a larger partition per device. It helps reduce the degree of parallelism needed for model deployment. On the other hand, optimizing latency or meeting latency requirements is often a first-class citizen in inference while training optimizes throughput.
|
||||
|
||||
To obtain desired latency, DeepSpeed Inference automatically adapts MP as an effective approach to reduce model latency, and its parallelism degree is often determined first. With MP, we can split the mode and parallelize computational operations across multiple devices (GPUs) to reduce latency, but it reduces computation granularity and increases communication that may hurt throughput. Once the latency target has been met, DeepSpeed can apply pipeline parallelism to maximize the throughput. Overall, DeepSpeed Inference supports flexible adaptation of both parallelism approach and degree choices from training to inference, minimizing latency while saving deployment costs.
|
||||
|
||||
|
||||
## Customized Inference Kernels for Boosted Compute Efficiency of Transformer Blocks
|
||||
|
||||
To achieve high compute efficiency, DeepSpeed-inference offers inference kernels tailored for Transformer blocks through operator fusion, taking model-parallelism for multi-GPU into account. The main difference between our kernel-fusion scheme and similar approaches is that we not only fuse element-wise operations (such as bias-add, residual, and activation function), but also merge the General matrix multiply (GeMM) operations with other operations. To do this, we design an efficient implementation for the vector-matrix or skinny matrix-matrix multiplication that allows us to fuse more operations at the reduction boundary of GeMM operations.
|
||||
|
||||
# Kernel-Fusion
|
||||
|
||||
We take two main policies for fusing operations: 1) keeping the access-pattern of inputs and outputs intact throughout the sequence of operations fused together; 2) fusing operations at each all-reduce boundary. The first policy ensures that different thread-blocks won’t encounter transferring data between Streaming-Multiprocessors (SMs). This is due to no straight-forward communication among SMs other than using the main memory which adds the block-synching overhead because of non-deterministic behavior of memory access. The reason behind the second policy is that we cannot continue the execution unless the partial results are reduced among the model-parallel GPUs.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 1: Transformer Layer with Megatron-style model-parallelism all-reduce components. The figure illustrates the parts of layer fused together with broken lines (width of line shows the fusion depth).
|
||||
|
||||
Figure 1 shows the different components of a Transformer layer, and the groups of operations considered for fusion in our inference optimization. We also consider the NVIDIA Megatron-LM style of parallelism that partitions attention (Attn) and feed-forward (FF) blocks across multiple GPUs. Thus, we include the two all-reduce operations that reduce the results among parallel GPUs after Attn and FF blocks. As Figure 1 shows, we fuse the operations inside a Transformer layer at four main regions:
|
||||
1. Input Layer-Norm plus Query, Key, and Value GeMMs and their bias adds.
|
||||
2. Transform plus Attention.
|
||||
3. Intermediate FF, Layer-Norm, Bias-add, Residual, and Gaussian Error Linear Unit (GELU).
|
||||
4. Bias-add plus Residual.
|
||||
|
||||
To fuse these operations, we exploit shared-memory as an intermediate cache for transferring data between reduction operations used in layer-norm and GeMM, and the element-wise operations. Moreover, we use the warp-level instructions to communicate data between threads when reducing partial computations. In addition, we use a new schedule for GeMM operations, which allows for fusing as many operations as needed for the third kernel-fusion. We also combine the GeMMs for the attention computation in the second kernel-fusion, by using an implicit matrix transformation in order to reduce the memory pressure. Compared to the unfused computation style using cuBLAS GeMM, we improve the performance by 1.5x, 2.9x. 3x, and 1.2x for all these kernel-fusions, respectively.
|
||||
|
||||
## Seamless pipeline from training to inference with automatic kernel-injection
|
||||
|
||||
To run the model in Inference mode, DeepSpeed simply requires the location of the model checkpoints and the desired parallelism configuration, i.e., MP/PP degree. DeepSpeed Inference kernels can also be enabled for many well-known model architectures such as HuggingFace (Bert and GPT-2) or Megatron GPT-based models using a pre-defined policy map that maps the original parameters to the parameters in the inference kernels. For other transformer-based models, user can specify their own policy map. Note that DS-Inference can run independent of the training pipeline as long as it receives all model checkpoints, and the DeepSpeed Transformer kernels for inference can be injected into any Transformer model if the right mapping policy is defined. For more information on how to enable Transformer inference kernel as well as specifying parallelism, please refer to out [inference tutorial](https://www.deepspeed.ai/tutorials/inference-tutorial/).
|
||||
|
||||
|
||||
## Flexible quantization support
|
||||
|
||||
To further reduce the inference cost for large-scale models, we created the DeepSpeed Quantization Toolkit, supporting flexible quantize-aware training and high-performance kernels for quantized inference.
|
||||
|
||||
For training, we introduce a novel approach called Mixture of Quantization (MoQ), which is inspired by mixed-precision training while seamlessly applying quantization. With MoQ, we can control the precision of the model by simulating the impact of quantization when updating the parameters at each step of training. Moreover, it supports flexible quantization policies and schedules—we find that by dynamically adjusting the number of quantization bits during training, the final quantized model provides higher accuracy under the same compression ratio. To adapt to different tasks, MoQ can also leverage the second order information of models to detect their sensitivity to precision and adjust the quantization schedule and target accordingly.
|
||||
|
||||
To maximize the performance gains from the quantization model, we provide inference kernels tailored for quantized models that reduce latency through optimizing data movement but do not require specialized hardware. Finally, our toolkit does not require any code changes on the client side, making it easy to use.
|
||||
|
||||
## Performance results
|
||||
|
||||
Boosting throughput and reducing inference cost. Figure 3 shows the inference throughput per GPU for the three model sizes corresponding to the three Transformer networks, GPT-2, Turing-NLG, and GPT-3. DeepSpeed Inference increases in per-GPU throughput by 2 to 4 times when using the same precision of FP16 as the baseline. By enabling quantization, we boost throughput further. We reach a throughput improvement of 3x for GPT-2, 5x for Turing-NLG, and 3x for a model that is similar in characteristics and size to GPT-3, which directly translates to 3–5x inference cost reduction on serving these large models. In addition, we achieve these throughput and cost improvements without compromising latency as shown in Figure 5.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 3: Inference throughput for different model sizes. DeepSpeed Inference achieves 3x to 5x higher throughput than baseline.
|
||||
|
||||
One source of inference cost reduction is through reducing the number of GPUs for hosting large models as shown in Figure 4. The optimized GPU resources comes from 1) using inference-adapted parallelism, allowing users to adjust the model and pipeline parallelism degree from the trained model checkpoints, and 2) shrinking model memory footprint by half with INT8 quantization. As shown in this figure, we use 2x less GPUs to run inference for the 17B model size by adapting the parallelism. Together with INT8 quantization through DeepSpeed MoQ, we use 4x and 2x fewer GPUs for 17B and 175B sizes respectively.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 4: Number of GPUs used for running inference on the different model sizes shown in Figure 4.
|
||||
|
||||
Reducing inference latency. For the application scenarios where inference latency is critical, we can increase model parallelism degree in DeepSpeed Inference to reduce inference latency further. As Figure 5 depicts, we can reduce the latency by 2.3x compared to PyTorch as we increase the model-parallelism size to 4. Furthermore, we can still have high latency improvement with a fewer number of GPUs by adapting the parallelism at inference and using MoQ to quantize the model. We obtain 1.3x and 1.9x speedups while using 4x and 2x lower resources than baseline, respectively.
|
||||
|
||||
For the application scenarios where inference latency is critical, we can increase model parallelism degree in DeepSpeed Inference to reduce inference latency further. As Figure 5 depicts, we can reduce the latency by 2.3x compared to PyTorch as we increase the model-parallelism size to 4. Furthermore, we can still have high latency improvement with a fewer number of GPUs by adapting the parallelism at inference and using MoQ to quantize the model. We obtain 1.3x and 1.9x speedups while using 4x and 2x lower resources than baseline, respectively.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 5. Inference latency for the 17B model using different parallelism configuration to optimize latency.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed: Accelerating large-scale model inference and training via system optimizations and compression"
|
||||
date: 2021-05-14
|
||||
link: https://www.microsoft.com/en-us/research/blog/deepspeed-accelerating-large-scale-model-inference-and-training-via-system-optimizations-and-compression/
|
||||
excerpt: ""
|
||||
tags: inference English
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed powers 8x larger MoE model training with high performance"
|
||||
excerpt: ""
|
||||
link: https://www.microsoft.com/en-us/research/blog/deepspeed-powers-8x-larger-moe-model-training-with-high-performance/
|
||||
date: 2021-08-18 00:00:00
|
||||
tags: training English
|
||||
---
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "Autotuning: Automatically discover the optimal DeepSpeed configuration that delivers good training speed"
|
||||
excerpt: ""
|
||||
date: 2021-11-16 10:00:00
|
||||
tags: training English
|
||||
toc: false
|
||||
---
|
||||
|
||||
We introduce a new feature called Autotuning to automatically discover the optimal DeepSpeed configuration that delivers good training speed. One pain point in model training is to figure out good performance-relevant configurations such as micro-batch size to fully utilize the hardware and achieve a high throughput number. This configuration exploring process is commonly done manually but is important since model training is repeated many times and benefits from using a good configuration. Not only is the hand-tuning process time-consuming, but the outcome is hardware-dependent. This means that a good configuration on one hardware might not be the best on another different hardware. The user thus has to hand tune the configuration again. With DeepSpeed, there are more configuration parameters that could potentially affect the training speed, thus making it more tedious to manually tune the configuration.
|
||||
|
||||
The DeepSpeed Autotuner mitigates this pain point and automatically discovers the optimal DeepSpeed configuration that delivers good training speed. It not only reduces the time and resources users spend on tuning, but also can discover configurations better than hand-tuned methods. [DeepSpeedExamples](https://github.com/deepspeedai/DeepSpeedExamples/tree/master/autotuning) would demonstrate the effectiveness of autotuning across different models.
|
||||
|
||||
* For a brief overview, see the [Autotuning tutorial](https://www.deepspeed.ai/tutorials/autotuning/).
|
||||
* For more information on how to use Autotuning, see the [Autotuning README](https://github.com/deepspeedai/DeepSpeed/tree/master/deepspeed/autotuning#deepspeed-autotuning).
|
||||
* The source code can be found in the [DeepSpeed repo](https://github.com/deepspeedai/deepspeed).
|
||||
@@ -0,0 +1,184 @@
|
||||
---
|
||||
title: "DeepSpeed-MoE for NLG: Reducing the training cost of language models by 5 times"
|
||||
excerpt: ""
|
||||
date: 2021-12-09 22:00:00
|
||||
tags: training English
|
||||
---
|
||||
|
||||
Autoregressive transformer-based natural language generation (referred to as
|
||||
NLG in the rest of the blog) models can offer convincing solutions to a broad
|
||||
range of language tasks from document summarization, headline generation,
|
||||
question and answering to even generating code in a wide variety of programming
|
||||
languages. Due to the general applicability of these models, improving their
|
||||
quality has been of great interest for both academia and industry alike.
|
||||
|
||||
The quality of NLG improves with the increase in model size. However, today we
|
||||
are getting close to the limit of what the current generation of hardware can
|
||||
do. The Megatron-Turing NLG 530B model took 3 months to train on over 2K A100
|
||||
GPUs on the NVIDIA Selene Supercomputer, consuming over 3 million GPU hours.
|
||||
Another 3 to 5 times of increase in model size would be infeasible within a
|
||||
reasonable timeframe. Given the exorbitant compute resources required to train
|
||||
the state-of-art NLG models, a natural question to ask is: "Is it possible to
|
||||
make non-trivial improvement to model quality without increasing the compute
|
||||
cost?" Or equivalently, "Is it possible to produce model with similar quality
|
||||
using 3 to 5 times less resources?"
|
||||
|
||||
Recent works like [GShard](https://arxiv.org/abs/2006.16668) and [Switch
|
||||
Transformers](https://arxiv.org/abs/2101.03961) have shown that Mixture of
|
||||
Experts (MoE) model structure reduces large model training cost significantly
|
||||
for transformer-based encoder-decoder models. An MoE model contains a set of
|
||||
sparsely gated experts. During training and inference, only a subset of these
|
||||
experts is activated for each input token. Therefore, the model could scale to
|
||||
billions of parameters without a proportional increase in the computation.
|
||||
Despite showing promising results, the effectiveness of MoE for the much more
|
||||
computation intensive NLG family models remains mostly unknown.
|
||||
|
||||
Given the tremendous compute and energy requirements for training NLG family of
|
||||
models, we explore the opportunities that MoE presents to reduce their training
|
||||
cost. **We show that MoE can be applied to NLG family of models to significantly
|
||||
improve their model quality with the same training cost. Alternatively, it can
|
||||
achieve 5x reduction in training cost to achieve the same model quality of a
|
||||
dense NLG model.** For example, by applying MoE we achieved the model quality of
|
||||
a 6.7B parameter dense NLG model at the cost of training a 1.3B parameter dense
|
||||
model, thanks to the sparse structure of MoE.
|
||||
|
||||
Assuming the scaling holds, the results have the potential to completely
|
||||
transform the large model training landscape in terms of cost. For example, a
|
||||
trillion-parameter dense model can be potentially trained at the cost of a 200B
|
||||
parameter (like GPT-3) sized dense model, translating to millions of dollars in
|
||||
training cost reduction and energy savings (Brown et al., 2020, Language models
|
||||
are few-shot learners).
|
||||
|
||||
## MoE based NLG model architecture
|
||||
|
||||
To create an MoE based NLG model we studied the GPT like transformer-based NLG
|
||||
model. To complete training in a reasonable timeframe, the following models are
|
||||
selected: 350M (24 layers, 1024 hidden size, 16 attention heads), 1.3B (24
|
||||
layers, 2048 hidden size, 16 attention heads), and 6.7B (32 layers, 4096 hidden
|
||||
size, 32 attention heads). We use "350M+MoE-128" to denote a MoE model
|
||||
that uses 350M dense model as the base model and adds 128 experts on every
|
||||
other feedforward layer. That is to say, there are in total 12 MoE layers for
|
||||
both 350M+MoE-128 and 1.3B+MoE-128.
|
||||
|
||||
We use a gating function to activate a subset of experts in the MoE layer for
|
||||
each token. Specifically, in our experiments, only the top-1 expert is
|
||||
selected. Therefore, during both training and inference, our MoE model will
|
||||
have the same number of parameters to be activated for each token as their
|
||||
dense part. For example, our 1.3B+MoE-128 will only activate 1.3B parameter per
|
||||
token, and the amount of training computation per token will be similar to a
|
||||
1.3B dense model.
|
||||
|
||||
## MoE training infrastructure and dataset
|
||||
|
||||
We pre-trained both the dense and MoE version of the above models using
|
||||
[DeepSpeed](http://deepspeed.ai) on 128 A100 GPUs. DeepSpeed uses a
|
||||
combination of data parallel and expert parallel training to effectively scale
|
||||
the [MoE model training](https://www.microsoft.com/en-us/research/blog/deepspeed-powers-8x-larger-moe-model-training-with-high-performance/).
|
||||
|
||||
We used the same training data as described in the [MT-NLG blog](https://www.microsoft.com/en-us/research/blog/using-deepspeed-and-megatron-to-train-megatron-turing-nlg-530b-the-worlds-largest-and-most-powerful-generative-language-model/). For a fair
|
||||
comparison, we use 300B tokens to train both the dense model and the MoE model.
|
||||
|
||||
## MoE leads to better quality for NLG models
|
||||
|
||||
Figure 1 shows that the validation loss for the MoE versions of the model is
|
||||
significantly better than their dense counter parts. Furthermore, notice that
|
||||
the validation loss of the MoE model, 350M+MoE-128, is on par with the
|
||||
validation loss of the 1.3B dense model with 4x larger base. This is also true
|
||||
for 1.3B+MoE-128 in comparison with 6.7B dense model with 5x larger base.
|
||||
Furthermore, the model quality is on par not only for the validation loss but
|
||||
also for a wide variety of 6 ZeRO-shot evaluation tasks as shown in Table 1,
|
||||
demonstrating that these models in fact have very similar model quality.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Figure 1: Token-wise validation loss curves for dense and MoE NLG models with different model sizes.
|
||||
|
||||
| Model size | LAMBADA: completion prediction | PIQA: commonsense reasoning | BoolQ: reading comprehension | RACE-h: reading comprehension | TriviaQA: question answering | WebQs: question answering |
|
||||
| ---: | ---: | ---: | ---: | ---: | ---: | ---: |
|
||||
| **Dense NLG:** | | | | | | |
|
||||
| 350M | 0.5203 | 0.6931 | 0.5364 | 0.3177 | 0.0321 | 0.0157 |
|
||||
| 1.3B | 0.6365 | 0.7339 | 0.6339 | 0.3560 | 0.1005 | 0.0325 |
|
||||
| 6.7B | 0.7194 | 0.7671 | 0.6703 | 0.3742 | 0.2347 | 0.0512 |
|
||||
| **MoE NLG:** | | | | | | |
|
||||
| 350M+MoE-128 (13B) | 0.6270 | 0.7459 | 0.6046 | 0.3560 | 0.1658 | 0.0517 |
|
||||
| 1.3B+MoE-128 (52B) | 0.6984 | 0.7671 | 0.6492 | 0.3809 | 0.3129 | 0.0719 |
|
||||
|
||||
Table 1: ZeRO-shot evaluation results (last six columns) for different dense and MoE NLG models. All ZeRO-shot evaluation results use the accuracy metric.
|
||||
|
||||
## Same quality with 5x less training cost
|
||||
|
||||
As we saw from the results above, adding MoE with 128 experts to the NLG model
|
||||
significantly improves the quality of the NLG model. However, these experts do
|
||||
not change the compute requirements of the model as each token is only
|
||||
processed by a single expert. Therefore, the compute requirements for dense
|
||||
model and its corresponding MoE models with the same base are similar.
|
||||
|
||||
More concretely, a 1.3B+MoE-128 model training requires roughly the same
|
||||
amount of compute operations as 1.3B dense, while offering much better model
|
||||
quality. Furthermore, our results show that by applying MoE we can achieve the
|
||||
model quality of a 6.7B parameter dense model at the training cost of 1.3B
|
||||
parameter dense model, resulting in an effective training compute reduction of
|
||||
5x.
|
||||
|
||||
This compute cost reduction can directly be translated into throughput gain,
|
||||
training time and training cost reduction by leveraging the efficient DeepSpeed
|
||||
MoE training system. Table 2 shows the training throughput of the 1.3B+MoE-128
|
||||
model in comparison to the 6.7B dense model on 128 NVIDIA A100 GPUs.
|
||||
|
||||
| | Training samples per sec | Throughput gain / Cost Reduction
|
||||
| --- | ---: | ---:
|
||||
| 6.7B dense | 70 | 1x
|
||||
| 1.3B+MoE-128 | 372 | 5x
|
||||
|
||||
Table 2: Training throughput (on 128 A100 GPUs) comparing MoE based model vs dense model that can both achieve the same model quality.
|
||||
|
||||
## MoE for Inference
|
||||
|
||||
The training cost reduction of MoE is not free and comes at the expense of
|
||||
increasing the total number of parameters required to achieve the same model
|
||||
quality compared to dense models. The 1.3B+MoE-128 have roughly 8x the number
|
||||
of parameters (52B) compared to the 6.7B dense model. So, does this mean
|
||||
inference will be 8x slower than the dense model, since inference is generally
|
||||
limited by the time taken to read all the model parameters, especially for
|
||||
small batch sizes?
|
||||
|
||||
Not quite. Note that in the 1.3B+MoE-128 model, each token is processed by a
|
||||
unique expert per MoE layer, and the total number of parameters used in
|
||||
processing the token is just 1.3B. This can in theory result in even faster
|
||||
inference than the quality-equivalent dense 6.7B model because of 5x less
|
||||
compute and parameter read. In reality though, the number of tokens in a batch
|
||||
during inference is generally larger than 1. Inferencing, a long sequence
|
||||
length or a non-unit batch size may require loading all the experts, increasing
|
||||
the total number of parameters loaded by 8x compared to the quality-equivalent
|
||||
dense model. Therefore, achieving good inference performance with MoE is still
|
||||
challenging even though the parameters used and the computation incurred per
|
||||
token is small compared to the quality-equivalent dense model.
|
||||
|
||||
Nonetheless, we believe that it is possible to use different forms of
|
||||
parallelism to leverage massive memory bandwidth by scaling across a large
|
||||
number of devices to speed up MoE inference, making it comparable or faster
|
||||
than quality-equivalent dense models for extended inference scenarios and
|
||||
creating opportunities to make MoE based models cost efficient for inference in
|
||||
addition to training.
|
||||
|
||||
## Conclusion and Release
|
||||
|
||||
We demonstrate that MoE based models can be applied to NLG task, reducing the
|
||||
training cost by 5x compared to dense, autoregressive transformer-based models
|
||||
like GPT-3 and MT-NLG 530B. Through MoE based low-cost training we hope to make
|
||||
high quality language models accessible to a broad audience, even with limited
|
||||
compute resources.
|
||||
|
||||
To this end we are releasing our [end-to-end pipeline for training MoE based
|
||||
NLG models](https://github.com/deepspeedai/Megatron-DeepSpeed/tree/moe-training),
|
||||
along with [specific example
|
||||
scripts](https://github.com/deepspeedai/Megatron-DeepSpeed/tree/moe-training/examples_deepspeed/MoE)
|
||||
and [tutorial](/tutorials/mixture-of-experts-nlg) to help get started with our pipeline. We look forward to the application and
|
||||
the innovations that this may bring to the deep learning community.
|
||||
|
||||
## Acknowledgement
|
||||
|
||||
This work was done in collaboration with Brandon Norick, Zhun Liu, Xia Song from the
|
||||
Turing Team, and Young Jin Kim, Alex Muzio, Hany Hassan Awadalla from Z-Code
|
||||
Team. We also thank Luis Vargas, Umesh Madan, Gopi Kumar, Andrey Proskurin and
|
||||
Mikhail Parakhin for their continuous support and guidance.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed: Advancing MoE inference and training to power next-generation AI scale"
|
||||
excerpt: ""
|
||||
link: https://www.microsoft.com/en-us/research/blog/deepspeed-advancing-moe-inference-and-training-to-power-next-generation-ai-scale/
|
||||
date: 2022-01-19 00:00:00
|
||||
tags: inference English
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "Supporting efficient large model training on AMD Instinct GPUs with DeepSpeed"
|
||||
excerpt: ""
|
||||
link: https://cloudblogs.microsoft.com/opensource/2022/03/21/supporting-efficient-large-model-training-on-amd-instinct-gpus-with-deepspeed/
|
||||
date: 2022-03-21 00:00:00
|
||||
tags: training ZeRO English
|
||||
---
|
||||
@@ -0,0 +1,135 @@
|
||||
---
|
||||
title: "Azure empowers easy-to-use, high-performance, and hyperscale model training using DeepSpeed"
|
||||
excerpt: ""
|
||||
date: 2022-07-26 00:09:00
|
||||
tags: training azure English
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
Large-scale transformer-based deep learning models trained on large amounts of data have shown great results in recent years in several cognitive tasks and are behind new products and features that augment human capabilities. These models have grown several orders of magnitude in size during the last five years. Starting from a few million parameters of the original transformer model all the way to the latest 530 billion-parameter Megatron-Turing model as shown in *Figure 1*. There is a growing need for customers to train and fine tune large models at an unprecedented scale.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
*Figure 1: Landscape of large models and hardware capabilities*
|
||||
|
||||
To train these models, users needed to set up and maintain a complex distributed training infrastructure that usually required several manual and error-prone steps. These lead to a subpar experience both in terms of usability and performance. We recently [announced](https://azure.microsoft.com/en-us/blog/azure-empowers-easytouse-highperformance-and-hyperscale-model-training-using-deepspeed/) how we are making great strides to simplify this and enable easy-to-use and high-performance training at 1K+ GPU scale on Azure.
|
||||
|
||||
In this extended post, we share the details of how DeepSpeed users can train trillion-parameter models with a new easy-to-use, streamlined, scalable, and high-performance distributed training experience on Azure. We also share details of the experimental setup, model configurations, additional performance trends, and guide our users on how to run these experiments in their own environments.
|
||||
|
||||
## Making distributed training faster and easier on Azure using DeepSpeed
|
||||
|
||||
We compare the existing manual and error-prone workflow with our proposed easy-to-use workflow for DeepSpeed on Azure in *Figure 2*. Customers can now use easy-to-use [training pipelines](https://github.com/deepspeedai/Megatron-DeepSpeed/tree/main/examples_deepspeed) to launch training jobs at scale. The new workflow reduces the number of steps from 11 to just 1 if users rely on the recommended [AzureML](https://azure.microsoft.com/en-us/services/machine-learning/) [recipes](https://github.com/deepspeedai/Megatron-DeepSpeed/tree/main/examples_deepspeed/azureml).
|
||||
|
||||
|
||||
{: .align-center}
|
||||
|
||||
*Figure 2: An easy-to-use and streamlined distributed training experience with DeepSpeed on Azure*
|
||||
|
||||
For users who have custom environments built using Azure VMs or [Azure VMSS](https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/overview), only two steps are needed:
|
||||
|
||||
- 1) Run the cluster setup script (to be released in the next few weeks)
|
||||
- 2) Use the Azure VMSS [recipes](https://github.com/deepspeedai/Megatron-DeepSpeed/tree/main/examples_deepspeed/azure) to launch training.
|
||||
|
||||
## Key Performance Benefits
|
||||
We already shared a summary of our key performance results in the Azure [announcement](https://azure.microsoft.com/en-us/blog/azure-empowers-easytouse-highperformance-and-hyperscale-model-training-using-deepspeed/). We enable the capability to train 2x larger model sizes (2 trillion vs. 1 trillion parameters), scale to 2x more GPUs (1024 vs. 512), and offer up to 1.8x higher compute throughput/GPU (150 TFLOPs vs. 81 TFLOPs) compared to other [cloud providers](https://medium.com/pytorch/training-a-1-trillion-parameter-model-with-pytorch-fully-sharded-data-parallel-on-aws-3ac13aa96cff).
|
||||
|
||||
DeepSpeed on Azure offers near-linear scalability both in terms of **increase in model size** as well as **increase in number of GPUs**. As shown in *Figure 3a*, together with the DeepSpeed [ZeRO-3](https://www.microsoft.com/en-us/research/blog/zero-infinity-and-deepspeed-unlocking-unprecedented-model-scale-for-deep-learning-training/), its novel CPU offloading capabilities, and a high-performance Azure stack powered by InfiniBand interconnects and A100 GPUs, we were able to maintain an efficient throughput/GPU (>157 TFLOPs) in a near-linear fashion as the model size increases from 175 billion parameters to 2 trillion parameters. On the other hand, for a given model size, e.g., 175B, we achieve near-linear scaling as we increase the number of GPUs from 128 all the way to 1024 as shown in *Figure 3b*. The key takeaway is that Azure and DeepSpeed together are breaking the GPU memory wall and enabling our customers to easily and efficiently train trillion-parameter models at scale.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
*Figure 3: (a) Near-perfect throughput/GPU as we increase the model size from 175 billion to 2 trillion parameters (BS/GPU=8). (b) Near-perfect performance scaling with the increase in number of GPU devices for the 175B model (BS/GPU=16). The sequence length is 1024 for both cases.*
|
||||
|
||||
## Experimental Setup
|
||||
We share the details of our experimental setup and some of the best practices we followed. The users can either directly use them to reproduce our results or modify them to fit their own setup in terms of model scale as well as the scale of Azure hardware being provisioned.
|
||||
|
||||
### Hardware (Azure instances)
|
||||
|
||||
We used [NDm A100 v4-series](https://docs.microsoft.com/en-us/azure/virtual-machines/ndm-a100-v4-series) instances in our experiments. Each instance includes two socket AMD EPYC 7V12 64-Core CPUs, 1.7TB main memory and eight A100 80GB GPUs. The system has a balanced PCIe topology connecting 4 GPU devices to each CPU socket. Each GPU within the VM is provided with its own dedicated, topology-agnostic 200 Gb/s NVIDIA Mellanox HDR InfiniBand connection providing an accelerated 200 Gbps high speed fabric. The DeepSpeed library exploits offload capabilities where the activation and optimizer states are allocated in the main memory. Hence, 1.7TB memory capacity per node helps us to scale to large model sizes.
|
||||
|
||||
### Training setup using AzureML
|
||||
Users can directly use the AzureML studio and use our published [recipes](https://github.com/deepspeedai/Megatron-DeepSpeed/tree/main/examples_deepspeed/azureml) to run experiments without any additional setup. This is the easiest and recommended way of running experiments on Azure.
|
||||
|
||||
### Training setup using Azure VMSS
|
||||
|
||||
Existing VMSS customers and others who have custom Azure VM based environments can follow the setup as follows. The scripts to make these steps easy will be released in the coming weeks.
|
||||
A cluster is created using Azure Virtual Machine Scale Sets (VMSS) to provision the desired number of compute nodes running the new Azure HPAI VM image specialized for extreme-scale deep learning applications using the software stack listed in *Table 1*.
|
||||
|
||||
| Name | Description (Version) |
|
||||
| ------------------------------: | :----------------: |
|
||||
| PyTorch | 1.10.2 (installed from source) |
|
||||
| DeepSpeed | 0.6.2 (installed from source) |
|
||||
| Megatron-LM | [https://github.com/deepspeedai/Megatron-DeepSpeed](https://github.com/deepspeedai/Megatron-DeepSpeed) |
|
||||
| Apex | 0.1 |
|
||||
| NCCL | 2.12.10 |
|
||||
| CUDNN | 8.2.4.15 |
|
||||
| CUDA | 11.4 |
|
||||
| CUDA Driver | R470.82 |
|
||||
| VM Image | Ubuntu-HPC 20.04 Image |
|
||||
|
||||
*Table 1: Detailed version information of the software packages in the Azure HPC VM image*
|
||||
|
||||
Users can create a VMSS with up to 600 VM instances enabling up to 4,800 A100 GPUs. In addition to the VMSS for the compute nodes, we provision a distinct login node using an inexpensive D4s v4 (or similar) instance with 4-core Intel VCPU, running the same image, for compiling, launching, and monitoring jobs. The login node, compute nodes, and a shared storage filesystem are grouped within an Azure Virtual Network (vnet) allowing VMs to connect to each other over SSH and to shared NFS volume shown in *Figure 4*.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
*Figure 4: Organization of our VMSS-based experimental setup*
|
||||
|
||||
## Performance Evaluation on Various Model Configurations
|
||||
|
||||
We ran our experiments with four different model sizes – 175B, 530B, 1T, and 2T – using the configurations shown in *Table 2*.
|
||||
|
||||
| Model Size | 175B | 530B | 1T | 2T |
|
||||
| :---------: | ---: | ---: | ---: | ---: |
|
||||
| Number of layers | 96 | 105 | 128 | 160 |
|
||||
| Hidden Dimension | 12,288 | 20,480 | 25,600 | 32,768 |
|
||||
| Attention Heads | 96 | 128 | 160 | 128 |
|
||||
|
||||
*Table 2: Model configuration*
|
||||
|
||||
For each of these configurations, we report peak throughput of the system using TFLOPs/GPU as the main performance metric. To calculate TFLOPs, we use the formula used by the Megatron paper as shown below.
|
||||
|
||||
```FLOPs/GPU = 96 * B * s * l * h2 * (1 + s/6h + V/(16*l*h))```
|
||||
|
||||
B is batch size, s is sequence length, l is the number of layers, h is hidden size, and V is vocabulary size.
|
||||
|
||||
### Scaling the 175B and 530B models
|
||||
*Figures 5a* and *5b* show the results of 175B model with sequence length 512 and 1024, respectively. We only scale to 512 GPUs for seq-length 512 as adding more GPUs shows similar performance. On the other hand, with sequence length 1024, we saw linear performance increase to 1024 GPUs. Overall, the peak throughput of **204.49 TFLOPs/GPU** was achieved on 256 GPUs with a micro batch size of 32 and sequence length of 512.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
*Figure 5: Performance characteristics of 175B model on 512 and 1K GPUs respectively. The colored columns signify different micro batch sizes.*
|
||||
|
||||
Next, we report the 530B model scaling. Previous results on the 530B MT-NLG model using DeepSpeed and Megatron-LM on 280 DGX A100 servers on the Selene supercomputer showed the peak throughput of 126 TFLOPS/GPU. However, we were able to surpass that throughput and achieved up to **171.37 TFLOPs/GPU** on 128 NDm A100 v4-series A100 systems (i.e., 1024 GPUs) as shown in *Figure 6*.
|
||||
|
||||
The benefit of this 530B model is its simpler parallelization configuration as there is no tensor/pipeline parallelism. With ZeRO powered data parallelism, there are fewer heuristics required to optimally configure the distributed model. In addition, the consistent steady state performance of more than 140 TFLOPs/GPU for micro batch sizes >1 demonstrates a robust software and hardware platform.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
*Figure 6: Throughput achieved with a 530B parameter model on 512 and 1024 GPUs for micro-batch sizes per GPU of 1, 2, 4, and 8, with sequence length 1,024.*
|
||||
|
||||
### Scaling the 1T and 2T models
|
||||
|
||||
The 1T parameter model contains 128 layers with 160 attention heads. Training such an extreme-scale model is not an easy task. *Figure 7* shows the throughput achieved for each of the model configurations we explored on 512 and 1024 GPUs. Peak throughput achieved was **165.36 TFLOPs/GPU** for micro batch size of 8 across 1024 GPUs and the model reached steady state performance within the first 3-4 iterations.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
*Figure 7: Performance characteristics of 1T parameter model on 512 and 1024 GPUs with 1, 2, 4, and 8 micro batch sizes, with sequence length 1,024.*{: .align-center}
|
||||
|
||||
The 2T parameter model consists of 160 layers, 32k hidden dimension, and 128 attention heads. Given the large size of the model and the significant time required on 1024 GPUs, we limited our benchmark runs for the 2T model to a batch size of 8 per GPU with a sequence length of 1024. We were able to achieve 157 TFLOPs/GPU on 1,024 GPUs.
|
||||
|
||||
## How to run training experiments on Azure?
|
||||
|
||||
We recognize that DeepSpeed users are diverse and have different environments. In this tutorial, our focus is on making things simpler for users who plan to run large model training experiments on Azure.
|
||||
|
||||
> The easiest way to do model training on Azure is via the Azure ML recipes. The job submission and data preparation scripts have been made available [here](https://github.com/deepspeedai/Megatron-DeepSpeed/tree/main/examples_deepspeed/azureml). Users simply need to setup their Azure ML workspace following the [guide](https://github.com/Azure/azureml-examples/tree/main/python-sdk#set-up) and submit experiment using the aml_submit.py file.
|
||||
|
||||
Some users have customized environments built on top of Azure VMs and VMSS based clusters. To simplify training on such setups, we are working on an easy-to-use cluster setup script that will be published in the next few weeks. If you already have a cluster setup running, you can use the [azure recipes](https://github.com/deepspeedai/Megatron-DeepSpeed/tree/main/examples_deepspeed/azure) for the 175B and the 1T model. The recipes can easily be modified to train other model configurations.
|
||||
|
||||
## Acknowledgement
|
||||
|
||||
This blog post was written by the DeepSpeed team in collaboration with the AzureML and the AzureHPC team. We would like to acknowledge several individuals who made this work possible:
|
||||
- AzureHPC team: Russell J. Hewett, Kushal Datta, Prabhat Ram, Jithin Jose, and Nidhi Chappell
|
||||
- AzureML team: Vijay Aski, Razvan Tanase, Miseon Park, Savita Mittal, Ravi Shankar Kolli, Prasanth Pulavarthi, and Daniel Moth
|
||||
- DeepSpeed team: Ammar Ahmad Awan, Jeff Rasley, Samyam Rajbhandari, Martin Cai, and Yuxiong He
|
||||
- CTO office: Gopi Kumar and Luis Vargas
|
||||
@@ -0,0 +1,122 @@
|
||||
---
|
||||
title: "ZeRO-Inference: Democratizing massive model inference"
|
||||
excerpt: ""
|
||||
date: 2022-09-10 00:09:00
|
||||
tags: inference ZeRO English
|
||||
---
|
||||
|
||||
## Introduction
|
||||
The current trends in artificial intelligence (AI) domains such as image, speech, and natural language, demonstrate that model quality can be improved by increasing model size. In natural language processing, for example, the state-of-the-art (SOTA) model has grown from 300 million parameters (Bert-Large) to 500 billion parameters (Megatron-Turing-530B) in less than four years. However, this dramatic growth in model sizes has significantly increased the GPU cost to train, finetune or inference these models, making them unaffordable to most users. To democratize access to AI innovations, large organizations, such as Hugging Face (BigScience), Meta, and Yandex have recently publicly released pre-trained massive models. Unfortunately, even these publicly available models are not broadly usable because many users cannot afford the dozens of GPUs required to fit them for inference computation. For example, half-precision inference computation on Megatron-Turing-530B (SOTA model for natural language) requires at least 40 A100-40GB GPUs, which is unaffordable to many students, model scientists, hobbyists, and small businesses that could benefit from using these powerful models. And so, a real concern is that if the dramatic increase in model sizes continues, then a growing fraction of users could be excluded from the benefits of these AI innovations.
|
||||
|
||||
DeepSpeed, a part of Microsoft’s AI at Scale Initiative, has developed the ZeRO-Inference technology to address these obstacles to AI democratization. ZeRO-Inference comes from the family of ZeRO technologies, which are a collection of powerful memory and parallelism optimizations for efficient large scale model training and inference on modern GPU clusters. DeepSpeed had previously developed ZeRO-Infinity, a technology that leverages heterogeneous memory (GPU, CPU, and NVMe) to efficiently scale model training to extreme levels. ZeRO-Inference adapts and optimizes ZeRO-Infinity techniques for model inference on GPUs by hosting the model weights in CPU or NVMe memory, thus hosting no (**zero**) weights in GPU. This approach is inspired by the observation that the aggregate capacity of CPU and NVMe memories in most commodity computing devices (e.g., laptops, desktops, workstations, etc.) is on the order of terabytes and sufficient to host the largest known models for inference computation. By leveraging this non-GPU memory, ZeRO-Inference enables inference computation of massive models (with hundreds of billions of parameters) on as few as a single GPU, thereby making massive model inference accessible to almost everyone. Moreover, by dramatically reducing GPU memory requirements with CPU or NVMe memory which are significantly cheaper, it significantly reduces the cost of massive model inference, offering an affordable inference path to SOTA models.
|
||||
|
||||
## How ZeRO-Inference works
|
||||
The massive computational requirements of large model inference means that accelerators like GPUs are required for efficient execution. Therefore, an important design decision for large model inference on limited GPU budget is how to apportion GPU memory among model weights, inference inputs, and intermediate results.
|
||||
|
||||
### Offload all model weights
|
||||
ZeRO-Inference pins the entire model weights in CPU or NVMe (whichever is sufficient to accommodate the full model) and streams the weights layer-by-layer into the GPU for inference computation. After computing a layer, the outputs are retained in GPU memory as inputs for the next layer, while memory consumed by the layer weights is released for use by the next layer. Thus, model inference time is composed of the time to compute the layers on GPU, and the time to fetch the layers over PCIe. For large model inference, this approach provides scaling and efficiency benefits, as explained below.
|
||||
|
||||
ZeRO-Inference offers scaling benefits in two ways. First, by keeping just one (or a few) model layers in GPU memory at any time, ZeRO-Inference significantly reduces the amount of GPU memory required to inference massive models. For current SOTA models which have about a hundred layers (e.g., 96 and 105 layers in GPT3-175B and Megatron-Turing-530B respectively), ZeRO-Inference reduces the GPU memory requirements by up to two orders of magnitude. For example, with ZeRO-Inference, GPU memory consumption of Megaton-Turing-530B for half-precision inference drops from 1TB to 10GB. Second, by fitting the model into CPU or NVMe memory which are orders of magnitude cheaper than GPU memory, ZeRO-Inference makes scaling to future SOTA models (e.g., with trillions or tens-of-trillions of parameters) more affordable compared to approaches that fit the entire model into GPU memory.
|
||||
|
||||
ZeRO-Inference delivers efficient computation for throughput-oriented inference applications despite the latency of fetching model weights from CPU or NVMe over PCIe interconnect. The primary reason for this is that by limiting GPU memory usage of the model to one or a few layers of weights, ZeRO-Inference can use the majority of GPU memory to support a large amount of input tokens in the form of long sequences or large batch sizes. A large model layer requires a significant amount of computation, especially when processing inputs with many input tokens. For example, one GPT3-175B layer requires about 7 TFlops to process an input of batch size 1 and sequence length of 2048. Therefore, for inference scenarios with long sequence length and large batch sizes, the computation time dominates the latency of fetching model weights, which ultimately improves efficiency. In summary, ZeRO-Inference's strategy to utilize GPU memory to support large number of input tokens results in high performance inference for large models.
|
||||
|
||||
### Optimizations
|
||||
To further improve system efficiency, ZeRO-Inference leverages two additional optimizations to reduce the latency of fetching layer weights from CPU or NVMe memory into GPU memory.
|
||||
|
||||
The first optimization involves overlapping the fetch of a layer with the computation of an earlier layer, a.k.a., layer prefetching. Layer prefetching allows ZeRO-Inference to hide portions of the transfer latency of the prefetched layers. This is especially useful when computation time is not large enough or cannot be sufficiently increased (e.g., with larger batch size) to dominate the latency of fetching layer weights.
|
||||
|
||||
The second optimization, which is applicable for inference on multiple GPUs, involves parallelizing the fetch of each layer across multiple GPUs by using each GPU to fetch only a portion of the layer. Employing the aggregate PCIe links of the GPUs in this manner essentially increases the transfer bandwidth linearly, thus reducing the latency. With this approach, fetching layers into GPU memory occurs in two phases. First, each GPU independently fetches a partition of the layer over PCIe into its memory. At this point, only a partition of the layer will be resident on each GPU. Next, each GPU assembles the full layer for computation by fetching the missing layer pieces from other GPUs over the high-bandwidth GPU-GPU interconnect (e.g., NVLink, xGMI, etc.). Since GPU-GPU interconnect bandwidth is typically over an order of magnitude higher than PCIe bandwidth, efficient multi-GPU or multi-node communication primitives, such as NCCL or RCCL all-gather, can be used to efficiently assemble the full layer on all GPUs with negligible latency compared to the PCIe latency.
|
||||
|
||||
### Alternative approach: Host some model weights in GPU memory
|
||||
An alternative approach to ZeRO-Inference is to pin as many of the model weights as possible into GPU memory and fetch the remainder (from CPU or NVMe) when needed for computation. A benefit of this approach is avoidance of the latency of fetching weights that are already pinned in GPU memory. However, this approach has two downsides: (i) the latency savings for hundred-billion parameter models are negligible since only a small fraction of the weights can fit in GPU memory, and (ii) even when a decent portion of the model weights can fit (e.g., > 50% for ~10B models), the remaining GPU memory can only fit small batch sizes which hurts inference throughput. We later show evaluation results to demonstrate that this approach is sub-optimal.
|
||||
|
||||
|
||||
## Model Scaling on 1 GPU
|
||||
ZeRO-Inference enables significant model scaling for inference on a single GPU compared to a baseline that hosts the model in GPU memory (i.e., HBM). As an example, we consider half-precision model inference using a single NVIDIA Tesla V100 GPU in a NVIDIA DGX2 system. While the V100 GPU has 32GB of memory, the system is equipped with 1.5TB of CPU DRAM and 30TB of NVMe storage. The maximum model size supported for inference computation on GPU depends on the memory in which the model is hosted. *Figure 1* below shows the achievable model scales in this system for GPU inference with ZeRO-Inference. In comparison, the baseline cannot support models larger than 16 billion parameters for GPU inference[^model_scale]. In contrast, ZeRO-Inference has the flexibility to host the model in a different memory (DRAM or NVMe) than HBM. This flexibility allows ZeRO-Inference to support much larger models than baseline. For example, by hosting a model on NVMe memory, Zero-Inference can support models with up to 15 trillion parameters for GPU inference, which is almost a thousand times larger compared to baseline. A practical takeaway from *Figure 1* is that ZeRO-Inference enables single GPU inference computation of current SOTA models, since they are smaller than 15 trillion parameters.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
[^model_scale]: 16 billion parameters model won’t fit in V100-32GB for half-precision inference since no memory will be left for inputs and intermediate results.
|
||||
|
||||
## Token Generation Performance
|
||||
An important inference workload is token generation based on an input prompt. In this workload the model is provided a text sequence as input prompt, and based on this prompt, the model generates output text of configurable length. We use this workload to demonstrate the performance of ZeRO-Inference. This workload consists of two phases: (1) the prompt processing phase where the model processes the input prompt, and (2) the generation phase where the model generates the output tokens.
|
||||
|
||||
ZeRO-Inference is targeted for throughput-oriented inference applications, and so the performance metric that we use for this workload is the number of tokens generated per second in the generation phase. We use the Hugging Face token generation pipeline in our experiments to measure the performance of using a greedy search algorithm to generate ten output tokens given an input prompt of four tokens. The generation pipeline in our experiments uses KV-caching optimization to improve performance by caching generated tokens to avoid re-computation. We consider the performance impact of three aspects of ZeRO-Inference design choices and optimizations: (1) full offloading model weights as opposed to partial offloading, (2) prefetching layer weights ahead of use, and (3) using multiple GPUs to parallelize layer fetching over PCIe. Additionally, we measure the performance impact of varying the number of output tokens.
|
||||
|
||||
### Models
|
||||
For our experiments, we use the three publicly available massive language models listed in *Table 1*. We configure these models for half-precision inference computations. ZeRO-Inference is required to inference these models on a single V100-32GB since they are bigger than GPU memory.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
### Full Offload vs. Partial Offload of model weights
|
||||
A key design choice in ZeRO-Offload is to offload all the weights of models larger than GPU memory rather than host a subset of the weights in GPU memory. Our intuition for this approach is that for throughput-oriented inference applications, the larger batch sizes enabled by full offload yields better performance than partial offload. In *Table 2*, we present results for OPT-30B token generation on a single V100-32GB that compare fully offloading the model weights versus hosting a portion (i.e., 10 and 12 billion parameters[^partial_offload]) in GPU memory. The results show that full offload delivers the best performance for both CPU memory (43 tokens per second) and NVMe memory (30 tokens per second). With both CPU and NVMe memory, full offload is over 1.3x and 2.4x faster than partial offload of 18 and 20 billion parameters respectively. The performance advantage of full offload comes from the larger batch sizes compared to the partial offload options. **Thus when a model does not fit in GPU, using GPU memory to increase batch size rather than to partially fit the model leads to faster token generation.**
|
||||
|
||||
{: .align-center}
|
||||
|
||||
[^partial_offload]: Pinning more parameters in GPU memory resulted in out of memory errors for small batch sizes.
|
||||
|
||||
### Prefetching layer weights
|
||||
ZeRO-Inference fetches layers ahead of use, overlapping with current layer computation, to hide layer transfer latency. We measure the impact of prefetching on token generation performance on a single V100-32GB and summarize the results in *Table 3*. We observe that prefetching did not improve CPU offload. This is because the relatively short sequences in token generation (i.e., less than 50 tokens) resulted in layer computation time that is insufficient to hide a significant portion of layer fetch time from CPU. In contrast, prefetching improves NVMe offloading performance by 1.13x, 1.14x and 1.21x for OPT-30B, OPT-175B, and BLOOM-176B respectively. This is because transferring weights from NVMe through CPU memory allows prefetching to overlap transfers from CPU to GPU memory with transfers from NVMe to CPU boosting the effective transfer bandwidth.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
### Parallelizing layer fetching on multiple GPUs
|
||||
ZeRO-Inference leverages the four PCIe interconnects between GPUs and CPU memory to parallelize layer fetching for faster inference computations on multiple GPUs. In *Table 4*, we report the throughput improvements for token generation on two and four GPUs compared to a single GPU[^multi_gpu_pcie] . These results were collected with layer prefetching enabled. The reported throughput numbers are per GPU showing that token generation becomes faster on each GPU as the aggregated PCIe links reduce the layer fetch latencies. **The improved per GPU throughput translates to super-linear scaling performance**. Additionally, these results suggest improved bandwidths of future PCIe generations could help to improve ZeRO-Inference performance.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
[^multi_gpu_pcie]: For multiple GPU runs, we select GPUs with independent PCIe interconnects to CPU memory.
|
||||
|
||||
|
||||
### Impact of generation output length
|
||||
We measure the performance impact of the number of output tokens since the memory overhead of KV-caching optimization increases with longer output tokens and could limit batch size. First, we consider the impact of token lengths 10, 20, 50, and 100 on batch size that can fit one V100-32GB GPU. The results in *Table 5* show a 2X reduction in batch size for a 5X increase in token count (compared to baseline count of 10).
|
||||
|
||||
{: .align-center}
|
||||
|
||||
Next, we measure the impact on generation throughput using four V100-32GB GPUs. The results are presented in Table 6 for CPU offload, and Table 7 for NVMe-Offload. We observe an impact that is consistent across models and offload memory, which is that increasing the number of output tokens reduces throughput proportionally to batch size reduction. These results also demonstrate the importance of large batch sizes to the performance of ZeRO-Inference.
|
||||
|
||||
{: .align-center}
|
||||
|
||||
{: .align-center}
|
||||
|
||||
## Using ZeRO-Inference
|
||||
We briefly discuss how users can determine when ZeRO-Inference is suitable for their application and how to enable ZeRO-Inference in DeepSpeed.
|
||||
|
||||
### When to use ZeRO-Inference
|
||||
ZeRO-Inference is designed for inference applications that require GPU acceleration but lack sufficient GPU memory to host the model. Also, ZeRO-Inference is optimized for inference applications that are **throughput-oriented** and allow **large batch sizes**. Alternative techniques, such as [Accelerate](https://github.com/huggingface/accelerate), [DeepSpeed-Inference](https://www.deepspeed.ai/inference/), and [DeepSpeed-MII](https://github.com/deepspeedai/deepspeed-mii) that fit the entire model into GPU memory, possibly using multiple GPUs, are more suitable for inference applications that are latency sensitive or have small batch sizes.
|
||||
|
||||
### How to use ZeRO-Inference
|
||||
ZeRO-Inference is available in the DeepSpeed library versions >= 0.6.6. Integrating ZeRO-Inference into token generation pipelines, such as [Hugging Face generate](https://huggingface.co/docs/transformers/main_classes/text_generation), requires updating the DeepSpeed configuration to set [ZeRO optimization](https://www.deepspeed.ai/docs/config-json/#zero-optimizations-for-fp16-training) to stage 3 and [parameter offloading](https://www.deepspeed.ai/docs/config-json/#parameter-offloading) to CPU or NVMe.
|
||||
|
||||
Below is a configuration snippet for enabling ZeRO-Inference with offloading to CPU memory.
|
||||
```json
|
||||
"zero_optimization": {
|
||||
"stage": 3,
|
||||
"offload_param": {
|
||||
"device": "cpu",
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Below is a configuration snippet for offloading to a NVMe device mounted on "/local_nvme".
|
||||
```json
|
||||
"zero_optimization": {
|
||||
"stage": 3,
|
||||
"offload_param": {
|
||||
"device": "nvme",
|
||||
"nvme_path": "/local_nvme",
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Conclusion
|
||||
Recent advances in AI technology have primarily come from extreme scaling of model sizes. However, extreme model scaling has also made the hardware cost of training and inferencing prohibitive for all but the largest organizations, severely restricting access to AI innovations. To help democratize AI, we developed ZeRO-Inference, a technology that enables inference computations of massive models on as few as a single GPU. ZeRO-Inference reduces the GPU cost of SOTA model inference by hosting the model on CPU or NVMe memory and streaming the model layers into GPU memory for inference computation. ZeRO-Inference complements the democratization efforts of large organizations that publicly release pre-trained SOTA models by ensuring that inference computation of these models is affordable for most users (e.g., students, hobbyists, model scientists, etc.).
|
||||
|
||||
|
||||
## Acknowledgement
|
||||
The DeepSpeed team would like to acknowledge Stas Bekman for previewing this blog and providing valuable feedback.
|
||||
@@ -0,0 +1,216 @@
|
||||
---
|
||||
title: "DeepSpeed-MII: instant speedup on 24,000+ open-source DL models with up to 40x cheaper inference"
|
||||
excerpt: ""
|
||||
date: 2022-10-11 00:09:00
|
||||
tags: inference English
|
||||
---
|
||||
|
||||
[  ](/assets/images/mii/hero.png){: .align-center}
|
||||
|
||||
The Deep Learning (DL) open-source community has seen tremendous growth in the last few months. Incredibly powerful text generation models such as the Bloom 176B, or image generation models such as Stable Diffusion are now available to anyone with access to a handful or even a single GPU through platforms such as Hugging Face. While open-sourcing has democratized access to AI capabilities, their application is still restricted by two critical factors: 1) inference latency and 2) cost.
|
||||
|
||||
There has been significant progress in system optimizations for DL model inference that can drastically reduce both latency and cost, but those are not easily accessible. The main reason for this limited accessibility is that the DL model inference landscape is diverse with models varying in size, architecture, system performance characteristics, hardware requirements, etc. Identifying the appropriate set of system optimizations applicable to a given model and applying them correctly is often beyond the scope of most data scientists, making low latency and low-cost inference mostly inaccessible.
|
||||
|
||||
[DeepSpeed Model Implementations for Inference (MII)](https://github.com/deepspeedai/DeepSpeed-MII) is a new open-source python library from DeepSpeed, aimed towards making low-latency, low-cost inference of powerful models not only feasible but also easily accessible.
|
||||
|
||||
* MII offers access to highly optimized implementations of **thousands of widely used DL models.**
|
||||
* MII supported models achieve significantly lower latency and cost compared to their original implementation.
|
||||
+ MII reduces the **latency of Big-Science Bloom 176B model by 5.7x**, while reducing the **cost by over 40x as shown in *Figures 2 (left) and 8***.
|
||||
+ MII reduces the latency and cost of deploying **Stable Diffusion by 1.9x as shown in *Figure 2 (right)***.
|
||||
* To enable low latency/cost inference, MII leverages an extensive set of optimizations from DeepSpeed-Inference such as *deepfusion* for transformers, automated *tensor-slicing* for multi-GPU inference, on-the-fly quantization with *ZeroQuant*, and several others (see below for more details).
|
||||
* With state-of-the-art performance, MII supports low-cost deployment of these models both on-premises and on Azure via AML with just a **few lines of codes**.
|
||||
|
||||
# How does MII work?
|
||||
|
||||
[  ](/assets/images/mii/mii-arch.png)
|
||||
|
||||
*Figure 1: MII Architecture, showing how MII automatically optimizes OSS models using DS-Inference before deploying them on-premises using GRPC, or on Microsoft Azure using AML Inference.*
|
||||
|
||||
|
||||
Under-the-hood MII is powered by [DeepSpeed-Inference](https://arxiv.org/abs/2207.00032). Based on the model type, model size, batch size, and available hardware resources, MII automatically applies the appropriate set of system optimizations from DeepSpeed-Inference to minimize latency and maximize throughput. It does so by using one of many pre-specified model injection policies, that allows MII and DeepSpeed-Inference to identify the underlying PyTorch model architecture and replace it with an optimized implementation (see *Figure 1*). In doing so, MII makes the expansive set of optimizations in DeepSpeed-Inference automatically available for thousands of popular models that it supports.
|
||||
|
||||
# Supported Models and Tasks
|
||||
|
||||
MII supports a growing list of tasks such as text generation, question-answering, text classification, etc, across thousands of transformer models available through multiple open-sourced model repositories such as Hugging Face, FairSeq, EluetherAI, etc. It supports dense models based on BERT, RoBERTa, GPT, OPT, and BLOOM architectures ranging from a few hundred million parameters in size to hundreds of billions of parameters in size. At the same time, it supports recent image generation models such as Stable Diffusion.
|
||||
|
||||
See the MII GitHub repo for an up-to-date list of [models and tasks supported by MII](https://github.com/deepspeedai/deepspeed-mii#supported-models-and-tasks).
|
||||
|
||||
# Inference Optimizations with MII
|
||||
|
||||
Here we provide a summary of the expansive set of optimizations from DeepSpeed-inference made available via MII. For more details, please refer to \[[1](https://arxiv.org/abs/2207.00032), [2](https://arxiv.org/abs/2206.01861)\]:
|
||||
|
||||
**DeepFusion for Transformers:** For transformer-based models such as Bert, Roberta, GPT-2, and GPT-J, MII leverages the transformer kernels in DeepSpeed-Inference that are optimized to achieve low latency at small batch sizes and high throughput at large batch sizes using DeepFusion.
|
||||
|
||||
**Multi-GPU Inference with Tensor-Slicing:** For massive models such as Bloom 176B, MII automatically enables tensor-parallelism within a node to leverage aggregate memory bandwidth and compute across multiple GPUs to achieve the lowest latency and throughput compared to anything else that is currently available.
|
||||
|
||||
**INT8 Inference with ZeroQuant:** For massive models with tens or hundreds of billions of parameters, MII supports INT8 Inference with ZeroQuant. Using this feature not only reduces the memory footprint and the number of GPUs required for inference but also increases the inference throughput by supporting larger batch sizes and using INT8 compute, thus lowering cost compared to FP16.
|
||||
|
||||
**ZeRO-Inference for Resource Constrained Systems:** Models such as Bloom 176B, require over 176 GB of memory to just fit the model even with INT8 support. In the absence of the aggregate GPU memory across multiple GPUs required to deploy such models, MII enables [ZeRO-Inference](https://www.deepspeed.ai/2022/09/09/zero-inference.html) that can leverage the system CPU memory to deploy these massive models with a single GPU with limited memory.
|
||||
|
||||
**Compiler Optimizations:** When applicable, MII automatically applies compiler-based optimizations via [TorchScript](https://pytorch.org/docs/stable/jit.html), [nvFuser](https://pytorch.org/blog/introducing-nvfuser-a-deep-learning-compiler-for-pytorch/), and [CUDA graph](https://developer.nvidia.com/blog/cuda-graphs/), in addition to the above optimizations, to further lower latency and improve throughput.
|
||||
|
||||
# MII-Public and MII-Azure
|
||||
|
||||
MII can work with two variations of DeepSpeed-Inference. The first, referred to as ds-public, contains most of the optimizations discussed above and is also available via our open-source DeepSpeed library. The second referred to as ds-azure, offers tighter integration with Azure, and is available via MII to all Microsoft Azure customers. We refer to MII running the two DeepSpeed-Inference variants as MII-Public and MII-Azure, respectively.
|
||||
|
||||
Both MII-Public and MII-Azure offer significant latency and cost reduction compared to open-sourced PyTorch implementation (Baseline). However for certain generative workloads, they can have differentiated performance: MII-Azure provides further improvements beyond MII-Public. We quantify the latency and cost reduction for both variations in the next section.
|
||||
|
||||
# Quantifying Latency and Cost Reduction
|
||||
|
||||
Inference workloads can be either latency critical, where the primary objective is to minimize latency, or cost sensitive, where the primary objective is to minimize cost. In this section, we quantify the benefits of using MII for both latency-critical and cost-sensitive scenarios.
|
||||
|
||||
## Latency Critical Scenarios
|
||||
|
||||
For latency-critical scenarios, where a small batch size of 1 is often used, MII can reduce the latency by up to 6x for a wide range of open-source models, across multiple tasks. More specifically, we show model latency reduction of [^overhead_details]:
|
||||
|
||||
1. Up to 5.7x for multi-GPU inference for text generation using massive models such as Big Science Bloom, Facebook OPT, and EluetherAI NeoX (*Figure 2 (left)*)
|
||||
|
||||
2. Up to 1.9x for image generation tasks model using Stable Diffusion (*Figure 2 (right)*)
|
||||
|
||||
3. Up to 3x for relatively smaller text generation models (up to 7B parameters) based on OPT, BLOOM, and GPT architectures, running on a single GPU (*Figures 3 and 4*)
|
||||
|
||||
4. Up to 9x for various text representation tasks like fill-mask, text classification, question answering, and token classification using RoBERTa- and BERT- based models (*Figures 5 and 6*).
|
||||
|
||||
[  ](/assets/images/mii/llm-latency-sd-latency-zoom.png){: .align-center}
|
||||
*Figure 2: (left) Best achievable latency for large models. MII-Azure (int8) offers 5.7X lower latency compared to Baseline for Bloom-176B. (right) Stable Diffusion text to image generation latency comparison.*
|
||||
|
||||
<!--{: .align-center}
|
||||
*Figure B: Best achievable latency for large models. MII-Azure (int8) offers 5.7X lower latency compared to Baseline for Bloom-176B*
|
||||
|
||||
{: .align-center}
|
||||
*Figure C: Stable Diffusion text to image generation latency comparison*-->
|
||||
|
||||
[  ](/assets/images/mii/opt-bloom.png){: .align-center}
|
||||
*Figure 3: Latency comparison for OPT and BLOOM models. MII-Azure is up to 2.8x faster than baseline.*
|
||||
|
||||
[  ](/assets/images/mii/gpt.png){: .align-center}
|
||||
*Figure 4: Latency comparison for GPT models. MII-Azure is up to 3x faster than baseline.*
|
||||
|
||||
[  ](/assets/images/mii/roberta.png){: .align-center}
|
||||
*Figure 5: Latency comparison for RoBERTa models. MII offers up to 9x lower model latency and up to 3x lower end-to-end latency than baseline on several tasks and RoBERTa variants [^overhead_details].*
|
||||
|
||||
[  ](/assets/images/mii/bert.png){: .align-center}
|
||||
*Figure 6: Latency comparison for BERT models. MII offers up to 8.9x lower model latency and up to 4.5x end-to-end latency across several tasks and BERT variants[^overhead_details].*
|
||||
|
||||
[^overhead_details]: The end-to-end latency of an inference workload is comprised of two components: i) actual model execution, and ii) pre-/post-processing before and after the model execution. MII optimizes the actual model execution but leaves the pre-/post-processing pipeline for future optimizations. We notice that text representation tasks have significant pre-/post-processing overhead (*Figures G and H*). We plan to address those in a future update.
|
||||
|
||||
## Cost Sensitive Scenarios
|
||||
|
||||
MII can significantly reduce the inference cost of very expensive language models like Bloom, OPT, etc. To get the lowest cost, we use a large batch size that maximizes throughput for both baseline and MII. Here we look at the cost reduction from MII using two different metrics: i) tokens generated per second per GPU, and ii) dollars per million tokens generated.
|
||||
|
||||
*Figures 7 and 8* show that MII-Public offers over 10x throughput improvement and cost reduction compared to the baseline, respectively. Furthermore, MII-Azure offers over 30x improvement in throughput and cost compared to the baseline.
|
||||
|
||||
[  ](/assets/images/mii/tput-llms.png){: .align-center}
|
||||
*Figure 7: Throughput comparison per A100-80GB GPU for large models. MII-Public offers over 15x throughput improvement while MII-Azure offers over 40x throughput improvement.*
|
||||
|
||||
[  ](/assets/images/mii/azure-cost.png){: .align-center}
|
||||
*Figure 8: Cost of generating 1 million tokens on Azure with different model types. MII-Azure reduces the cost of generation by over 40x.*
|
||||
|
||||
# Deployment Options
|
||||
|
||||
MII supported models can be deployed in two different ways as shown in *Figure 1* with just a few lines of code.
|
||||
|
||||
## MII-Public Deployment
|
||||
|
||||
MII-Public can be deployed on-premises or on any cloud offering. MII creates a lightweight GRPC server to support this form of deployment and provides a GRPC inference endpoint for queries. The code below shows how a supported model can be deployed with MII-Public Deployment.
|
||||
|
||||
```python
|
||||
import mii
|
||||
mii.deploy(task="text-to-image",
|
||||
model="CompVis/stable-diffusion-v1-4",
|
||||
deployment_name="sd-deployment")
|
||||
```
|
||||
|
||||
## MII-Azure Deployment
|
||||
|
||||
MII supports deployment on Azure via AML Inference. To enable this, MII generates AML deployment assets for a given model that can be deployed using the [Azure-CLI](https://learn.microsoft.com/en-us/cli/azure/what-is-azure-cli), as shown in the code below. Furthermore, deploying on Azure, allows MII to leverage DeepSpeed-Azure as its optimization backend, which offers better latency and cost reduction than DeepSpeed-Public.
|
||||
|
||||
```python
|
||||
import mii
|
||||
mii.deploy(task="text-to-image",
|
||||
model="CompVis/stable-diffusion-v1-4",
|
||||
deployment_name="sd-deployment",
|
||||
deployment_type=DeploymentType.AML)
|
||||
```
|
||||
|
||||
To learn more about these deployment options and get started with MII, please the [MII getting started guide](https://github.com/deepspeedai/deepspeed-mii#getting-started-with-mii).
|
||||
|
||||
# Concluding Remarks
|
||||
|
||||
We are very excited to share MII with the community and improve it with your feedback. We will continue to add support for more models in MII as well as enhance both MII-Public and MII-Azure for both on-premise and Azure users. Our hope is that while open sourcing has made powerful AI capabilities accessible to many, MII will allow for a wider infusion of these capabilities into a diverse set of applications and product offerings by instantly reducing the latency and cost of inferencing.
|
||||
|
||||
# Appendix
|
||||
|
||||
The table below shows the mapping between model aliases used in *Figures 3, 4, 5, and 6* and real model names.
|
||||
|
||||
| Alias | Model Name |
|
||||
| --- | --- |
|
||||
| text-gen-m1 | [sberbank-ai/rugpt3large_based_on_gpt2](https://huggingface.co/sberbank-ai/rugpt3large_based_on_gpt2) |
|
||||
| text-gen-m2 | [skt/kogpt2-base-v2](https://huggingface.co/skt/kogpt2-base-v2) |
|
||||
| text-gen-m3 | [geralt/MechDistilGPT2](https://huggingface.co/geralt/MechDistilGPT2) |
|
||||
| text-gen-m4 | [mrm8488/distilgpt2-finetuned-wsb-tweets](https://huggingface.co/mrm8488/distilgpt2-finetuned-wsb-tweets) |
|
||||
| text-gen-m5 | [Norod78/hebrew-bad_wiki-gpt_neo-tiny](https://huggingface.co/Norod78/hebrew-bad_wiki-gpt_neo-tiny) |
|
||||
| text-gen-m6 | [shibing624/code-autocomplete-distilgpt2-python](https://huggingface.co/shibing624/code-autocomplete-distilgpt2-python) |
|
||||
| text-gen-m7 | [mrm8488/diltilgpt2-finetuned-bookcopus-10](https://huggingface.co/mrm8488/diltilgpt2-finetuned-bookcopus-10) |
|
||||
| bert-q&a-m1 | [bert-large-uncased-whole-word-masking-finetuned-squad](https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad) |
|
||||
| bert-q&a-m2 | [deepset/bert-large-uncased-whole-word-masking-squad2](https://huggingface.co/deepset/bert-large-uncased-whole-word-masking-squad2) |
|
||||
| bert-q&a-m3 | [nyust-eb210/braslab-bert-drcd-384](https://huggingface.co/nyust-eb210/braslab-bert-drcd-384) |
|
||||
| bert-q&a-m4 | [deepset/minilm-uncased-squad2](https://huggingface.co/deepset/minilm-uncased-squad2) |
|
||||
| bert-token-class-m1 | [dslim/bert-large-NER](https://huggingface.co/dslim/bert-large-NER) |
|
||||
| bert-token-class-m2 | [dbmdz/bert-large-cased-finetuned-conll03-english](https://huggingface.co/dbmdz/bert-large-cased-finetuned-conll03-english) |
|
||||
| bert-token-class-m3 | [dslim/bert-base-NER](https://huggingface.co/dslim/bert-base-NER) |
|
||||
| bert-token-class-m4 | [CAMeL-Lab/bert-base-arabic-camelbert-mix-ner](https://huggingface.co/CAMeL-Lab/bert-base-arabic-camelbert-mix-ner) |
|
||||
| bert-fill-mask-m1 | [bert-base-multilingual-cased](https://huggingface.co/bert-base-multilingual-cased) |
|
||||
| bert-fill-mask-m2 | [bert-base-multilingual-uncased](https://huggingface.co/bert-base-multilingual-uncased) |
|
||||
| bert-fill-mask-m3 | [wietsedv/bert-base-dutch-cased](https://huggingface.co/wietsedv/bert-base-dutch-cased) |
|
||||
| bert-fill-mask-m4 | [nlpaueb/bert-base-greek-uncased-v1](https://huggingface.co/nlpaueb/bert-base-greek-uncased-v1) |
|
||||
| bert-fill-mask-m5 | [dbmdz/bert-base-italian-xxl-cased](https://huggingface.co/dbmdz/bert-base-italian-xxl-cased) |
|
||||
| bert-fill-mask-m6 | [aubmindlab/bert-base-arabertv02](https://huggingface.co/aubmindlab/bert-base-arabertv02) |
|
||||
| bert-fill-mask-m7 | [dccuchile/bert-base-spanish-wwm-uncased](https://huggingface.co/dccuchile/bert-base-spanish-wwm-uncased) |
|
||||
| bert-fill-mask-m8 | [bert-base-german-cased](https://huggingface.co/bert-base-german-cased) |
|
||||
| bert-fill-mask-m9 | [bert-base-uncased](https://huggingface.co/bert-base-uncased) |
|
||||
| bert-fill-mask-m10 | [dbmdz/bert-base-german-cased](https://huggingface.co/dbmdz/bert-base-german-cased) |
|
||||
| bert-fill-mask-m11 | [nlpaueb/legal-bert-base-uncased](https://huggingface.co/nlpaueb/legal-bert-base-uncased) |
|
||||
| bert-fill-mask-m12 | [KB/bert-base-swedish-cased](https://huggingface.co/KB/bert-base-swedish-cased) |
|
||||
| bert-fill-mask-m13 | [indolem/indobertweet-base-uncased](https://huggingface.co/indolem/indobertweet-base-uncased) |
|
||||
| bert-fill-mask-m14 | [emilyalsentzer/Bio_ClinicalBERT](https://huggingface.co/emilyalsentzer/Bio_ClinicalBERT) |
|
||||
| bert-fill-mask-m15 | [asafaya/bert-mini-arabic](https://huggingface.co/asafaya/bert-mini-arabic) |
|
||||
| bert-text-class-m1 | [DTAI-KULeuven/mbert-corona-tweets-belgium-topics](https://huggingface.co/DTAI-KULeuven/mbert-corona-tweets-belgium-topics) |
|
||||
| bert-text-class-m2 | [avichr/heBERT_sentiment_analysis](https://huggingface.co/avichr/heBERT_sentiment_analysis) |
|
||||
| bert-text-class-m3 | [finiteautomata/beto-sentiment-analysis](https://huggingface.co/finiteautomata/beto-sentiment-analysis) |
|
||||
| bert-text-class-m4 | [ProsusAI/finbert](https://huggingface.co/ProsusAI/finbert) |
|
||||
| bert-text-class-m5 | [cross-encoder/ms-marco-MiniLM-L-12-v2](https://huggingface.co/cross-encoder/ms-marco-MiniLM-L-12-v2) |
|
||||
| bert-text-class-m6 | [nlptown/bert-base-multilingual-uncased-sentiment](https://huggingface.co/nlptown/bert-base-multilingual-uncased-sentiment) |
|
||||
| bert-text-class-m7 | [microsoft/xtremedistil-l6-h256-uncased](https://huggingface.co/microsoft/xtremedistil-l6-h256-uncased) |
|
||||
| bert-text-class-m8 | [cross-encoder/ms-marco-MiniLM-L-6-v2](https://huggingface.co/cross-encoder/ms-marco-MiniLM-L-6-v2) |
|
||||
| fill-mask-m1 | [vinai/bertweet-large](https://huggingface.co/vinai/bertweet-large) |
|
||||
| fill-mask-m2 | [klue/roberta-large](https://huggingface.co/klue/roberta-large) |
|
||||
| fill-mask-m3 | [sberbank-ai/ruRoberta-large](https://huggingface.co/sberbank-ai/ruRoberta-large) |
|
||||
| q&a-m1 | [deepset/roberta-large-squad2](https://huggingface.co/deepset/roberta-large-squad2) |
|
||||
| token-class-m1 | [Jean-Baptiste/roberta-large-ner-english](https://huggingface.co/Jean-Baptiste/roberta-large-ner-english) |
|
||||
| text-class-m1 | [cross-encoder/stsb-roberta-large](https://huggingface.co/cross-encoder/stsb-roberta-large) |
|
||||
| text-class-m2 | [siebert/sentiment-roberta-large-english](https://huggingface.co/siebert/sentiment-roberta-large-english) |
|
||||
| text-class-m3 | [roberta-large-mnli](https://huggingface.co/roberta-large-mnli) |
|
||||
| fill-mask-m4 | [vinai/bertweet-base](https://huggingface.co/vinai/bertweet-base) |
|
||||
| fill-mask-m5 | [vinai/phobert-base](https://huggingface.co/vinai/phobert-base) |
|
||||
| fill-mask-m6 | [microsoft/graphcodebert-base](https://huggingface.co/microsoft/graphcodebert-base) |
|
||||
| fill-mask-m7 | [vinai/bertweet-covid19-base-uncased](https://huggingface.co/vinai/bertweet-covid19-base-uncased) |
|
||||
| fill-mask-m8 | [uklfr/gottbert-base](https://huggingface.co/uklfr/gottbert-base) |
|
||||
| fill-mask-m9 | [cardiffnlp/twitter-roberta-base](https://huggingface.co/cardiffnlp/twitter-roberta-base) |
|
||||
| fill-mask-m10 | [microsoft/codebert-base-mlm](https://huggingface.co/microsoft/codebert-base-mlm) |
|
||||
| fill-mask-m11 | [pdelobelle/robbert-v2-dutch-base](https://huggingface.co/pdelobelle/robbert-v2-dutch-base) |
|
||||
| fill-mask-m12 | [ufal/robeczech-base](https://huggingface.co/ufal/robeczech-base) |
|
||||
| q&a-m2 | [Rakib/roberta-base-on-cuad](https://huggingface.co/Rakib/roberta-base-on-cuad) |
|
||||
| q&a-m3 | [thatdramebaazguy/roberta-base-squad](https://huggingface.co/thatdramebaazguy/roberta-base-squad) |
|
||||
| text-class-m4 | [roberta-base-openai-detector](https://huggingface.co/roberta-base-openai-detector) |
|
||||
| text-class-m5 | [pysentimiento/robertuito-emotion-analysis](https://huggingface.co/pysentimiento/robertuito-emotion-analysis) |
|
||||
| text-class-m6 | [cardiffnlp/twitter-roberta-base-sentiment](https://huggingface.co/cardiffnlp/twitter-roberta-base-sentiment) |
|
||||
| text-class-m7 | [cardiffnlp/twitter-roberta-base-sentiment-latest](https://huggingface.co/cardiffnlp/twitter-roberta-base-sentiment-latest) |
|
||||
| q&a-m4 | [deepset/roberta-base-squad2](https://huggingface.co/deepset/roberta-base-squad2) |
|
||||
| text-class-m8 | [textattack/roberta-base-SST-2](https://huggingface.co/textattack/roberta-base-SST-2) |
|
||||
| text-class-m9 | [cardiffnlp/twitter-roberta-base-emotion](https://huggingface.co/cardiffnlp/twitter-roberta-base-emotion) |
|
||||
| text-class-m10 | [pysentimiento/robertuito-sentiment-analysis](https://huggingface.co/pysentimiento/robertuito-sentiment-analysis) |
|
||||
| text-class-m11 | [finiteautomata/bertweet-base-sentiment-analysis](https://huggingface.co/finiteautomata/bertweet-base-sentiment-analysis) |
|
||||
| fill-mask-m13 | [huggingface/CodeBERTa-small-v1](https://huggingface.co/huggingface/CodeBERTa-small-v1) |
|
||||
| q&a-m5 | [deepset/tinyroberta-squad2](https://huggingface.co/deepset/tinyroberta-squad2) |
|
||||
| text-class-m12 | [j-hartmann/emotion-english-distilroberta-base](https://huggingface.co/j-hartmann/emotion-english-distilroberta-base) |
|
||||
@@ -0,0 +1,144 @@
|
||||
---
|
||||
title: "DeepSpeed Data Efficiency: A composable library that makes better use of data, increases training efficiency, and improves model quality"
|
||||
excerpt: ""
|
||||
date: 2022-12-12 00:09:00
|
||||
tags: training English
|
||||
---
|
||||
|
||||
[  ](/assets/images/data_efficiency/data_efficiecy_fig0.png){: .align-center}
|
||||
|
||||
Recently, large-scale deep learning models are empowering us to achieve more in many ways, such as [improving programming efficiency by code generation](https://github.com/features/copilot) and [providing art inspiration by text-to-image generation](https://www.microsoft.com/en-us/microsoft-365/blog/2022/10/12/new-tools-from-microsoft-365-edge-and-bing-bridge-the-gap-between-productivity-and-creativity/). To enable these services and keep improving the quality, deep learning model architecture evolves rapidly, and the model size is also growing at a tremendous speed. For example, from GPT to GPT-3 the model size increased 1500x in 2 years. The increasing model size leads to unprecedented training cost, making it challenging for many AI practitioners to train their own models. On the other hand, a less-emphasized perspective is that **data scale is actually increasing at a similar speed as model scale, and the training cost is proportional to both of them.** In Figure 1 below we plot the model and data scales of several representative language models in the last 5 years. From the oldest model on the left to the newest models on the right, both the model and data scales increase at similar speed. This demonstrates the importance of improving data efficiency: achieve same model quality with less data and reduced training cost, or achieve better model quality with the same amount of data and similar training cost.
|
||||
|
||||
[  ](/assets/images/data_efficiency/data_efficiecy_fig1.png){: .align-center}
|
||||
|
||||
*Figure 1: Model scale (number of parameters) and data scale (number of tokens consumed during training) of representative language models in the last 5 years.*
|
||||
|
||||
There are two popular research directions among existing data efficiency techniques: Data sampling techniques aim to improve the convergence speed by sampling the most suitable next data batch from the whole data pool; Data routing techniques aim to reduce the computation by routing each data to only a subset of the model components. These techniques improve data and training efficiency, but existing solutions on them have limitations on **extensibility, flexibility, and composability.** They are commonly designed for specific training tasks, making them hard to be extended with customized strategies and making them less flexible to be applied on diverse workloads from different users. Furthermore, different techniques are implemented separately, making it challenging to compose multiple solutions to further improve data and training efficiency.
|
||||
|
||||
To address these challenges, we, the DeepSpeed team as part of Microsoft’s [AI at Scale](https://www.microsoft.com/en-us/research/project/ai-at-scale/) initiative, are proud to announce **DeepSpeed Data Efficiency Library** – a composable framework that makes better use of data, increases training efficiency, and improves model quality. DeepSpeed Data Efficiency takes extensibility, flexibility, and composability into consideration, and it specifically demonstrates the following innovations:
|
||||
|
||||
**Efficient data sampling via curriculum learning.** Curriculum learning (CL) improves data efficiency by sampling from easier data. We present a general curriculum learning library which enables users to employ curriculum learning to their models at **maximum extensibility**: users can easily analyze, index, and sample their training data based on various customizable strategies. Using this library, we were able to explore different CL strategies for GPT-3 and BERT pretraining and identify the best solution that provides up to **1.5x data saving** while still maintaining similar model quality.
|
||||
|
||||
**Efficient data routing via random layerwise token dropping.** We present a novel data routing technique called random layerwise token dropping (random-LTD) to skip the computation of a subset of the input tokens at all middle layers. Random-LTD employs a simple yet effective routing strategy and requires **minimal model architecture change.** It is **flexible** to apply random-LTD to various tasks (GPT-3/BERT pretraining and GPT/ViT finetuning), and we achieve great data efficiency improvement (up to **1.5x data saving** while still maintaining the model quality).
|
||||
|
||||
**Seamlessly composing multiple methods.** The proposed DeepSpeed Data Efficiency framework seamlessly composes the curriculum learning and random-LTD techniques, and only requires minimal changes on the user code side. Furthermore, by composing both methods we can achieve even better data and training efficiency: for GPT-3 1.3B pretraining, we achieve **2x data and 2x time savings** together with better or similar model quality compared to the baseline training. When using the same amount of data, our approach further improves the model quality over the baseline. Users can also extend and contribute to the library by adding additional data efficiency techniques to compose together.
|
||||
|
||||
Each of these advances is explored further in the blog post below. For more about the technical details, please read our papers, “[Random-LTD: Random and Layerwise Token Dropping Brings Efficient Training for Large-scale Transformers](https://arxiv.org/abs/2211.11586)” which describes the random-LTD technique, and “[DeepSpeed Data Efficiency: Improving Deep Learning Model Quality and Training Efficiency via Efficient Data Sampling and Routing](https://arxiv.org/abs/2212.03597)” which describes the curriculum learning technique and overall DeepSpeed Data Efficiency framework.
|
||||
|
||||
# Efficient Data Sampling via Curriculum Learning
|
||||
|
||||
## Motivation
|
||||
|
||||
Curriculum learning aims to improve training convergence speed by presenting relatively easier or simpler examples earlier during training. Building a curriculum learning solution usually requires two components: the difficulty metric (i.e., how to quantify the difficulty of each data sample) and the pacing function (i.e., how to decide the curriculum difficulty range when sampling next training data batch). Curriculum learning has been successfully applied to various training tasks, and last year we also released a specific curriculum learning technique (sequence length warmup) for GPT-style model pretraining (see technical details in our paper “[The Stability-Efficiency Dilemma: Investigating Sequence Length Warmup for Training GPT Models](https://openreview.net/forum?id=JpZ5du_Kdh)” published in NeurIPS 2022). However, one common limitation among existing works is that there does not exist a generalized and extensible curriculum learning library, which allows practitioners to easily apply custom curriculum difficulty metrics, the combination of metrics, and pacing functions.
|
||||
|
||||
## Design
|
||||
|
||||
To solve the limitation of existing solutions, we design and implement a general curriculum learning library emphasizing the extensibility. It consists of three components as shown in Figure 2 below (top part). First, we use a data analyzer to perform the offline CPU-only data analysis which indexes the whole data pool based on any difficulty metric such as the sequence length, the vocabulary rarity, or anything defined by user. Next, during training, the curriculum scheduler determines the difficulty threshold for the current step based on a pacing function such as linear, rooted, or any strategy provided by users. Then the data sampler will sample the data with desired difficulty from the indexed data pool. Overall, this general implementation would enable users to explore curriculum learning on their workloads with maximum customizability (more technical details in [our DeepSpeed Data Efficiency paper](https://arxiv.org/abs/2212.03597)).
|
||||
|
||||
[  ](/assets/images/data_efficiency/data_efficiecy_fig2.png){: .align-center}
|
||||
|
||||
*Figure 2: Design of the DeepSpeed Data Efficiency framework.*
|
||||
|
||||
## Evaluation Results
|
||||
|
||||
Using this general and extensible curriculum learning solution for GPT-3 and BERT-Large model pretraining, we are able to easily analyze and index the huge training data based on up to 7 difficulty metrics and enable better data and training efficiency. For GPT-3 pretraining, our solution with the best difficulty metric (combination of truncation-based sequence length and vocabulary rarity) achieves 1.5x data and training cost saving while still maintaining model quality as baseline (Table 1 Case (8) vs. (1)). For BERT-Large pretraining, our solution with the best difficulty metric (vocabulary rarity) achieves 1.5x saving while still maintaining model quality (Table 2 Case (8) vs. (1)). On the other hand, our solutions can further improve model quality when using the same amount of data as baseline (Table 1 Case (2) to (6), Table 2 Case (2) to (6)).
|
||||
|
||||
| **Case** | **Pretrain data** | **Avg 0-shot accuracy** | **Avg 10-shot accuracy** |
|
||||
| ---------- |---------- |---------- |---------- |
|
||||
| (1) Baseline | 300B | 42.5 | 44.0 |
|
||||
| (2) CL truncation-based sequence length | 300B | 43.4 | 44.8 |
|
||||
| (3) CL reshape-based sequence length | 300B | 43.0 | 44.5 |
|
||||
| (4) CL vocabulary rarity | 300B | 42.3 | 44.5 |
|
||||
| (5) CL combining (2) and (4) | 300B | **43.6** | **44.9** |
|
||||
| (6) CL combining (3) and (4) | 300B | 43.0 | 44.4 |
|
||||
| (7) Baseline | 200B (1.5x) | 41.9 | 44.0 |
|
||||
| (8) CL combining (2) and (4) | **200B (1.5x)** | 42.7 | 44.5 |
|
||||
|
||||
*Table 1: GPT-3 1.3B pretraining data consumption and average evaluation accuracy on 19 tasks.*
|
||||
|
||||
| **Case** | **Pretrain data** | **GLUE finetune score** |
|
||||
| ---------- |---------- |---------- |
|
||||
| (1) Baseline | 1049B | 87.29 |
|
||||
| (2) CL truncation-based sequence length | 1049B | 87.31 |
|
||||
| (3) CL reorder-based sequence length | 1049B | 87.48 |
|
||||
| (4) CL vocabulary rarity | 1049B | 87.36 |
|
||||
| (5) CL combining (2) and (4) | 1049B | **87.60** |
|
||||
| (6) CL combining (3) and (4) | 1049B | 87.06 |
|
||||
| (7) Baseline | 703B (1.5x) | 87.19 |
|
||||
| (8) CL combining (2) and (4) | **703B (1.5x)** | 87.29 |
|
||||
|
||||
*Table 2: BERT-Large pretraining data consumption and average GLUE finetuning score on 8 tasks.*
|
||||
|
||||
# Efficient Data Routing via Random Layerwise Token Dropping
|
||||
|
||||
## Motivation
|
||||
|
||||
Standard data routing usually feeds the full images/sequences into all layers of a model. However, this process may not be optimal for training efficiency since some parts of an image (or words of a sentence) do not require a frequent feature update. As such, the token dropping method has been proposed, which is illustrated in Figure 3 (b) below, to skip the compute of some tokens/words (i.e., G-2 tokens in Figure 3 (b)) of a sentence in order to save the compute cost.
|
||||
|
||||
Although existing methods show promising results, they also exhibit several caveats: (1) most works solely focus on BERT (encoder-only on text data) pretraining and do not include decoder pretraining and/or other modalities (e.g., images); (2) the ability to skip layers is limited, which bounds the total amount of compute saving. By analyzing existing methods, we found out the potential main issue that limits their skipping and coverage abilities is the loss of attention mechanism for G-2 tokens for all skipped layers, since multi-head attention focuses on different tokens at different layer depths and the attention map aligns with the dependency relation most strongly in the middle of transformer architectures.
|
||||
|
||||
## Design
|
||||
|
||||
To resolve this main issue, we propose random-LTD, a **random** and **layerwise** token dropping mechanism, which processes only a subset of tokens among the entire data batch for all middle layers in order to save compute cost (see more details in [our Random-LTD paper](https://arxiv.org/abs/2211.11586)). As such, each token rarely bypasses all middle layers and its dependency with other tokens can be captured by the model. The illustration of random-LTD compared to baseline is shown in Figure 3 below, where random-LTD splits the input tokens into two groups and only the first group involves the compute.
|
||||
|
||||
[  ](/assets/images/data_efficiency/data_efficiecy_fig3.png){: .align-center}
|
||||
|
||||
*Figure 3: Comparison between baseline, existing token dropping methods, and random-LTD. Note that for random-LTD, only part of the inputs (Group 1) is used for Layer i.*
|
||||
|
||||
Random-LTD is simple yet very effective. Particularly, compared to other existing token dropping methods, random-LTD (1) does a purely random selection for each layer for two different groups, as such we do not require any expert design for the selection criterion; (2) is able to apply to all middle layers to achieve better saving ratio; (3) demonstrates great generalizability for both encoder and decoder models; and (4) is easy to use without much modeling change. These advantages enable maximum flexibility when applying random-LTD to various workloads.
|
||||
|
||||
## Evaluation Results
|
||||
|
||||
Thanks to its great flexibility, we were able to apply random-LTD method to broader applications, including BERT and GPT pretraining as well as ViT and GPT finetuning tasks. For all cases, random-LTD achieves similar model quality as baseline while using less data, and/or achieve better model quality while using the same amount of data (Table 3 to 6). For GPT-3 and BERT-Large pretraining, random-LTD achieves 1.5-2x data saving while still maintaining the same model quality. For GPT-3 we also tested random-LTD with full data which further improves the model quality compared to baseline.
|
||||
|
||||
| **Case** | **Pretrain data** | **Avg 0-shot accuracy** |
|
||||
| ---------- |---------- |---------- |
|
||||
| (1) Baseline | 300B | 42.5 |
|
||||
| (2) Random-LTD | 300B | **43.7** |
|
||||
| (3) Random-LTD | **200B (1.5x)** | 42.5 |
|
||||
|
||||
*Table 3: GPT-3 1.3B pretraining data consumption and average evaluation accuracy on 19 tasks.*
|
||||
|
||||
| **Case** | **Pretrain data** | **GLUE finetune score** |
|
||||
| ---------- |---------- |---------- |
|
||||
| (1) Baseline | 1049B | 87.29 |
|
||||
| (2) Random-LTD | **524B (2x)** | **87.32** |
|
||||
|
||||
*Table 4: BERT-Large pretraining data consumption and average GLUE finetuning score on 8 tasks.*
|
||||
|
||||
| **Case** | **Train data** | **ImageNet Top-1 Acc** |
|
||||
| ---------- |---------- |---------- |
|
||||
| (1) Baseline | 100% | 84.65 |
|
||||
| (2) Random-LTD | **77.7% (1.3x)** | **84.70** |
|
||||
|
||||
*Table 5: Finetuning result of ViT on ImageNet.*
|
||||
|
||||
| **Case** | **Train data** | **PTB PPL** |
|
||||
| ---------- |---------- |---------- |
|
||||
| (1) Baseline | 100% | 16.11 |
|
||||
| (2) Random-LTD | 100% | **15.9** |
|
||||
|
||||
*Table 6: GPT-2 350M finetuning result on the PTB task.*
|
||||
|
||||
# Composing Data Efficiency Techniques to Achieve More
|
||||
|
||||
The curriculum learning and random-LTD techniques are complementary. Inside DeepSpeed Data Efficiency framework, we seamlessly compose the two techniques as shown in Figure 2 above, where curriculum learning helps to sample the next data batch and random-LTD helps to decide how to route each sampled data inside the model. DeepSpeed Data Efficiency solves several complexities when composing the two techniques so that users can easily apply each technique or both to their training pipeline. The composability of DeepSpeed Data Efficiency also applies to data sampling and routing techniques in general, so that it provides a platform to implement and compose additional data efficiency techniques.
|
||||
|
||||
The composed DeepSpeed Data Efficiency solution leverages both data efficiency techniques and achieves even better data and training efficiency. Take the GPT-3 pretraining task as an example, composing CL and random-LTD, with 100% data, leads to the best model quality in our experiments (Table 7 Case (1) to (4)). When pretraining with 50% data, the baseline training results in worse zero-shot and 10-shot evaluation accuracy, and using either CL or random-LTD can only recover part of the 10-shot accuracy loss. On the other hand, the composed data efficiency solution achieves the same or better accuracy results as baseline with 100% data, demonstrating a 2x data and 2x time saving (Case (5) to (8)). Similar benefit such as 2x data saving was also observed when applying our solution to BERT pretraining.
|
||||
|
||||
| **Case** | **Pretrain data** | **Pretrain time (on 64 V100)** | **Avg 0-shot accuracy** | **Avg 10-shot accuracy** |
|
||||
| ---------- |---------- |---------- |---------- |---------- |
|
||||
| (1) Baseline | 300B | 260hr | 42.5 | 44.0 |
|
||||
| (2) CL best metric | 300B | 259hr | 43.6 | 44.9 |
|
||||
| (3) random-LTD | 300B | 263hr | 43.7 | 44.9 |
|
||||
| (4) CL + random-LTD | 300B | 260hr | **43.8** | **45.1** |
|
||||
| (5) Baseline | 150B (2x) | 130hr (2x) | 42.0 | 42.7 |
|
||||
| (6) CL best metric | 150B (2x) | 129hr (2x) | 42.6 | 43.7 |
|
||||
| (7) random-LTD | 150B (2x) | 131hr (2x) | 42.7 | 43.5 |
|
||||
| (8) CL + random-LTD | **150B (2x)** | **130hr (2x)** | 42.8 | 44.0 |
|
||||
|
||||
*Table 7: GPT-3 1.3B pretraining data/time consumption and average evaluation accuracy on 19 tasks.*
|
||||
|
||||
# Concluding Remarks
|
||||
|
||||
We are very excited to share DeepSpeed Data Efficiency library with the community and improve it with your feedback. Please find the code, tutorial, and documents at the [DeepSpeed GitHub](https://github.com/deepspeedai/DeepSpeed), and [website](/tutorials/data-efficiency/). And for more technical details please read our [Random-LTD paper](https://arxiv.org/abs/2211.11586) and [DeepSpeed Data Efficiency paper](https://arxiv.org/abs/2212.03597). We believe that our composable library and novel data efficiency techniques will help users reduce training cost while maintaining model quality or achieve better quality under similar cost. And we hope DeepSpeed Data Efficiency could become a platform that motivates and accelerates future research on deep learning data efficiency.
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: "Scaling Large-Scale Generative Mixture-of-Expert Multimodal Model With VL-MoE "
|
||||
excerpt: ""
|
||||
date: 2023-03-31 00:09:00
|
||||
tags: training English
|
||||
---
|
||||
|
||||
The field of Artificial Intelligence-Generated Content (AIGC) is rapidly growing, with the goal of making content creation more efficient and accessible. One of the most exciting areas of AIGC is the development of large-scale multi-modal models like [Flamingo](https://arxiv.org/abs/2204.14198), [BLIP](https://arxiv.org/abs/2301.12597), and [GPT4](https://arxiv.org/abs/2303.08774), which can accept inputs from multiple resources, e.g., image, text, audio, etc., and generate a variety of formats as outputs. For example, image creation can be made through stable diffusion and DALLE using the prompt text, and the new feature in the coming Office can create slides with texts, images, animations, etc., by leveraging the power of the new Microsoft Office Copilot.
|
||||
|
||||
Scaling up the model size is one common approach to boost usability and capability of AIGC tasks. However, simply scaling up dense architectures (e.g., from GPT-1 to GPT-3) is usually extremely resource-intensive and time-consuming for both model training and inference. One effective way to tackle this challenge is to apply mixture of experts (MoE). In particular, recent [text-based MoE](https://arxiv.org/abs/2201.05596) and [vision-based MoE](https://arxiv.org/abs/2106.05974) studies have demonstrated that MoE models can significantly reduce the training and resource cost as compared to a quality-equivalent dense model, or produce a higher quality model under the same training budget. Up to now, the effectiveness of jointly training MoE for multi-modal models remains not well understood. To explore this important capability, [DeepSpeed team](https://www.deepspeed.ai/) is proud to announce our first large-scale generative mixture-of-expert (MoE) multimodal model, named [VL-MoE](https://arxiv.org/abs/2303.07226).
|
||||
|
||||
[  ](/assets/images/vl_moe.png){: .align-center}
|
||||
|
||||
*Figure 1: The new encoding process in our VL-MoE for various modality inputs, for which gray and colored blocks indicate non-activated and activated modules, respectively.*
|
||||
|
||||
Specifically, we incorporate the MoE structure into the classical single-tower multi-modal model by comprising of the following components: (1) a shared self-attention module across modalities, (2) a pool of modality-specific experts in the feed-forward network (FFN), and (3) a sparse gated MoE extended from the dense FFN. Subsequently, under the same amount of training resources as that used in [VLMO](https://arxiv.org/abs/2111.02358) (200k training steps), we demonstrate VL-MoE's advantages over the state-of-the-art dense counterparts in the following two aspects:
|
||||
|
||||
(1) **VL-MoE can achieve significant accuracy improvement in comparison to its dense counterparts.** Table 1 demonstrates that under the same training budget (i.e., have the same number of activated parameters for each token), VL-MoE Base with 32 experts achieves better accuracy than the VLMO-Base dense model on all four vision-language datasets.
|
||||
|
||||
(2) **VL-MoE achieves similar model quality with a much smaller activated number of parameters compared to its dense counterparts.** Our results show that the finetuning performance of our VL-MoE is similar to that of the 3.1X larger VLMO-Large dense model (i.e., 3.1X more activated number of parameters per token). This can directly translate to approximately 3.1X training cost reduction as the training FLOPs for transformers are proportional to the activated model size per token.
|
||||
|
||||
|
||||
|
||||
| | Param per Token (# Total Param) | VQA | NLVR2 | COCO | Flickr30K |
|
||||
| | | test-dev / std | dev / test-P | TR / IR | TR / IR |
|
||||
|-------------------------------|:-------------------------------:|:--------------:|:-------------:|:-----------:|:-----------:|
|
||||
| Dense Counterparts | | | | | |
|
||||
| VLMO-dense Base | 180M (180M) | 76.64 / 76.89 | 82.77 / 83.34 | 74.8 / 57.2 | 92.3 / 79.3 |
|
||||
| VLMO-dense Large | 560M (180M) | 79.94 / 79.98 | 85.64 / 86.86 | 78.2 / 60.6 | 95.3 / 84.5 |
|
||||
| Ours (VL-MoE with 32 Experts) | | | | | |
|
||||
| VL-MoE | 180M (1.9B) | 78.23 / 78.65 | 85.54 / 86.77 | 79.4 / 61.2 | 96.1 / 84.9 |
|
||||
|
||||
*Table 1: Comparison of finetuning accuracy results for different models used in vision-language classification tasks and image-text retrieval tasks.*
|
||||
|
||||
A sophisticated MoE model design requires a highly efficient and scalable training system that can support multi-dimensional parallelism and efficient memory management. [DeepSpeed MoE](https://www.microsoft.com/en-us/research/blog/deepspeed-advancing-moe-inference-and-training-to-power-next-generation-ai-scale/) training system offers such advanced capabilities including easy-to-use APIs enabling flexible combinations of data, tensor, and expert parallelism. Furthermore, DeepSpeed MoE enables larger model scale than state-of-the-art systems by exploiting expert parallelism and [ZeRO optimizations](https://arxiv.org/abs/1910.02054) together. By leveraging the DeepSpeed MoE system, VL-MoE Base with 32 experts achieves similar model quality as VLMO-dense Large with about 2.5x training speedup.
|
||||
|
||||
[DeepSpeed MoE](https://www.microsoft.com/en-us/research/blog/deepspeed-advancing-moe-inference-and-training-to-power-next-generation-ai-scale/) system is already open-sourced and can be easily used as plug-and-play component to achieve high-performance low-cost training for any large-scale MoE models. The tutorial of how to use DeepSpeed MoE is available [here](https://www.deepspeed.ai/tutorials/mixture-of-experts/). VL-MoE is currently in the process of being integrated as a model example of [DeepSpeed Examples](https://github.com/deepspeedai/DeepSpeedExamples). Please stay tuned for our upcoming updates on this thread.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed Chat: 一键式RLHF训练,让你的类ChatGPT千亿大模型提速省钱15倍"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/deepspeed-chat/chinese/README.md
|
||||
date: 2023-04-24 00:00:00
|
||||
tags: training ZeRO RLHF Chinese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed Chat: ChatGPTライクなモデルを簡単・高速・低コストに、あらゆるスケールで学習"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/deepspeed-chat/japanese/README.md
|
||||
date: 2023-04-24 00:00:00
|
||||
tags: training ZeRO RLHF Japanese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed Chat: Easy, Fast and Affordable RLHF Training of ChatGPT-like Models at All Scales"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/deepspeed-chat/README.md
|
||||
date: 2023-04-24 00:00:00
|
||||
tags: training ZeRO RLHF English
|
||||
---
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
title: "DeepSpeed主要技術の概要紹介"
|
||||
excerpt: ""
|
||||
date: 2023-06-07 00:00:00
|
||||
tags: inference training ZeRO RLHF Japanese presentations
|
||||
---
|
||||
|
||||
我々が研究開発しているDeepSpeedについて、主要技術を日本語で説明した資料を公開しました。GPT3やChatGPTのような生成型AIのための大規模言語モデルを含む、様々な深層学習の訓練や推論に容易に適用でき、モデルの大規模化、高速化、コスト削減を可能にします。[こちら](/assets/files/DeepSpeed_Overview_Japanese_2023Jun7th.pdf)よりダウンロードしてください。
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed ZeRO++:降低4倍网络通信,显著提高大模型及类ChatGPT模型训练效率"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/zeropp/chinese/README.md
|
||||
date: 2023-06-22 00:00:00
|
||||
tags: training ZeRO RLHF Chinese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed ZeRO++: LLMやチャットモデルの訓練を劇的に高速化 – 通信オーバヘッドを1/4に大幅削減 -"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/zeropp/japanese/README.md
|
||||
date: 2023-06-22 00:00:00
|
||||
tags: training ZeRO RLHF Japanese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed ZeRO++: A leap in speed for LLM and chat model training with 4X less communication"
|
||||
excerpt: ""
|
||||
link: https://www.microsoft.com/en-us/research/blog/deepspeed-zero-a-leap-in-speed-for-llm-and-chat-model-training-with-4x-less-communication/
|
||||
date: 2023-06-22 00:00:00
|
||||
tags: training ZeRO RLHF English
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed Ulysses: 训练极长序列Transformer模型的系统优化"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/deepspeed-ulysses/chinese/README.md
|
||||
date: 2023-08-24 00:00:00
|
||||
tags: training ZeRO Chinese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed Ulysses: Transformerモデルを非常に長いシーケンスで訓練するための最適化"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/deepspeed-ulysses/japanese/README.md
|
||||
date: 2023-08-24 00:00:00
|
||||
tags: training ZeRO Japanese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed Ulysses: System Optimizations for Enabling Training of Extreme Long Sequence Transformer Models"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/deepspeed-ulysses/README.md
|
||||
date: 2023-08-24 00:00:00
|
||||
tags: training ZeRO English
|
||||
---
|
||||
@@ -0,0 +1,6 @@
|
||||
title: "ZeRO-Inference: 20X faster inference through weight quantization and KV cache offloading"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeedExamples/blob/master/inference/huggingface/zero_inference/README.md
|
||||
date: 2023-09-12 00:09:00
|
||||
tags: inference ZeRO quantization English
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed4Science:利用先进的AI系统优化技术实现科学发现"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/deepspeed4science/chinese/README.md
|
||||
date: 2023-09-19 00:00:00
|
||||
tags: training inference science Chinese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed4Scienceイニシアティブ: 洗練されたAIシステムのテクノロジーにより大規模な科学的発見を可能に"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/deepspeed4science/japanese/README.md
|
||||
date: 2023-09-19 00:00:00
|
||||
tags: training inference science Japanese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "Announcing the DeepSpeed4Science Initiative: Enabling large-scale scientific discovery through sophisticated AI system technologies"
|
||||
excerpt: ""
|
||||
link: https://www.microsoft.com/en-us/research/blog/announcing-the-deepspeed4science-initiative-enabling-large-scale-scientific-discovery-through-sophisticated-ai-system-technologies/
|
||||
date: 2023-09-19 00:00:00
|
||||
tags: training inference science English
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed-VisualChat:多轮图像+文字,为你展现不一样的AI聊天魅力"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/deepspeed-visualchat/10-03-2023/README-Chinese.md
|
||||
date: 2023-10-04 00:00:00
|
||||
tags: training Chinese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed-VisualChat: 複数ラウンド・複数画像の入力が可能なAIチャット体験を実現"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/blob/master/blogs/deepspeed-visualchat/10-03-2023/README-Japanese.md
|
||||
date: 2023-10-04 00:00:00
|
||||
tags: training Japanese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed-VisualChat: Improve Your Chat Experience with Multi-Round Multi-Image Inputs"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/tree/master/blogs/deepspeed-visualchat/10-03-2023/README.md
|
||||
date: 2023-10-04 00:00:00
|
||||
tags: training English
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed-FastGen:通过 MII 和 DeepSpeed-Inference 实现 LLM 高吞吐量文本生成"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/tree/master/blogs/deepspeed-fastgen/chinese/README.md
|
||||
date: 2023-11-06 00:00:00
|
||||
tags: inference Chinese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed-FastGen: MIIとDeepSpeed-InferenceによるLLMのための高速なテキスト生成"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/tree/master/blogs/deepspeed-fastgen/japanese/README.md
|
||||
date: 2023-11-06 00:00:00
|
||||
tags: inference Japanese
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "DeepSpeed-FastGen: High-throughput Text Generation for LLMs via MII and DeepSpeed-Inference"
|
||||
excerpt: ""
|
||||
link: https://github.com/deepspeedai/DeepSpeed/tree/master/blogs/deepspeed-fastgen
|
||||
date: 2023-11-06 00:00:00
|
||||
tags: inference English
|
||||
---
|
||||
Reference in New Issue
Block a user