README.md 1.31 KB
Newer Older
1
2
# Simple examples of FP16_Optimizer functionality

3
4
5
6
`minimal.py` shows the basic usage of `FP16_Optimizer` with either static or dynamic loss scaling.  Test via
```bash
python minimal.py
```
7

8
9
10
11
12
13
`FP16_Optimizer` supports closures with the same control flow as ordinary Pytorch optimizers.  
`closure.py` shows an example.  Test via
```bash
python closure.py
```
See [the API documentation](https://nvidia.github.io/apex/fp16_utils.html#apex.fp16_utils.FP16_Optimizer.step) for more details.
14

15
16
17
18
19
20
`FP16_Optimizer` also supports checkpointing with the same control flow as ordinary Pytorch optimizers.
`save_load.py` shows an example.  Test via
```bash
python save_load.py
```
See [the API documentation](https://nvidia.github.io/apex/fp16_utils.html#apex.fp16_utils.FP16_Optimizer.load_state_dict) for more details.
21

22
**distributed_pytorch** shows an example using `FP16_Optimizer` with Pytorch DistributedDataParallel.
23
24
25
26
27
28
29
The usage of `FP16_Optimizer` with distributed does not need to change from ordinary single-process 
usage. Run via
```bash
cd distributed_pytorch
bash run.sh
```

30
**distributed_pytorch** shows an example using `FP16_Optimizer` with Apex DistributedDataParallel.
31
32
33
34
35
36
Again, the usage of `FP16_Optimizer` with distributed does not need to change from ordinary 
single-process usage.  Run via
```bash
cd distributed_apex
bash run.sh
```