Admin-Torch
Transformers Training **Stabilized**
What's New? • Key Idea • How To Use • Docs • Examples • Citation • License
Here, we provide a plug-in-and-play implementation of Admin, which stabilizes previously-diverged Transformer training and achieves better performance, without introducing additional hyper-parameters. The design of Admin is half-precision friendly and can be reparameterized into the original Transformer.
What's New?
Beyond the original admin implementation:
admin-torchremoved the profilling stage and is plug-in-and-play.admin-torch's implementation is more robust (see below).
Comparison w. the DeepNet Init and the Original Admin Init (on WMT'17).
| Regular batch size (8x4096) | Huge batch size (128x4096) | |
|---|---|---|
| Original Admin | ✅ | ❌ |
| DeepNet | ❌ | ✅ |
admin-torch |
✅ | ✅ |
More details can be found in our example.
Key Idea
What complicates Transformer training?
For Transformer f, input x, randomly initialized weight w, we describe its stability (output_change_scale) as
In our study, we show that, an original N-layer Transformer's
output_change_scale is O(n), which unstabilizes its training. Admin stabilize Transformer's
training by regulating this scale to O(logn) or O(1).
More details can be found in our paper.
How to use?
install
pip install admin-torch
import
import admin-torch
enjoy
def __init__(self, ...):
...
+(residual = admin-torch.as_module(self, self.number_of_sub_layers))+
...
def forward(self, ):
...
-!x = x + f(x)!-
+(x = residual(x, f(x)))+
x = self.LN(x)
...
An elaborated example can be found at our doc, and a real working example can be found at LiyuanLucasLiu/fairseq (training recipe is available at our example).
Citation
Please cite the following papers if you found our model useful. Thanks!
Liyuan Liu, Xiaodong Liu, Jianfeng Gao, Weizhu Chen, and Jiawei Han (2020). Understanding the Difficulty of Training Transformers. Proc. 2020 Conf. on Empirical Methods in Natural Language Processing (EMNLP'20).
@inproceedings{liu2020admin,
title={Understanding the Difficulty of Training Transformers},
author = {Liu, Liyuan and Liu, Xiaodong and Gao, Jianfeng and Chen, Weizhu and Han, Jiawei},
booktitle = {Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP 2020)},
year={2020}
}
Xiaodong Liu, Kevin Duh, Liyuan Liu, and Jianfeng Gao (2020). Very Deep Transformers for Neural Machine Translation. arXiv preprint arXiv:2008.07772 (2020).
@inproceedings{liu_deep_2020,
author = {Liu, Xiaodong and Duh, Kevin and Liu, Liyuan and Gao, Jianfeng},
booktitle = {arXiv:2008.07772 [cs]},
title = {Very Deep Transformers for Neural Machine Translation},
year = {2020}
}
Metadata
Release files for admin-torch 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| admin_torch-0.1.0.tar.gz | 1.2 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| admin_torch-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.2 MB
Release files / admin_torch-0.1.0.tar.gz
| Download URL | admin_torch-0.1.0.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc7fce3fafed83d719e0a0594a0201bee54e53807d6f9f0715391bfb89803db4
|
|
BLAKE2b-256 checksum How to use checksums |
e56f9b420533c0f9f09536d88f17fe5b79e046c225b414d6f9b872de17978189
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.5
|
Release files / admin_torch-0.1.0-py3-none-any.whl
| Download URL | admin_torch-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd5696ff43a699b97bee2f58b476653dcf393c0320f43d9a22eee9a6a71ddc70
|
|
BLAKE2b-256 checksum How to use checksums |
8ff8a637a2448682e641efb852821084906ff07e6548d75c2ef322f35c342763
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.5
|
Security for admin-torch 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.