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

Michael Carilli's avatar
Michael Carilli committed
3
#### Minimal Working Sample
4
5
6
7
`minimal.py` shows the basic usage of `FP16_Optimizer` with either static or dynamic loss scaling.  Test via
```bash
python minimal.py
```
8

Michael Carilli's avatar
Michael Carilli committed
9
#### Closures
10
11
12
13
14
15
`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.
16

Michael Carilli's avatar
Michael Carilli committed
17
#### Checkpointing
18
19
20
21
22
23
`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.
24

Michael Carilli's avatar
Michael Carilli committed
25
#### Distributed
26
**distributed_pytorch** shows an example using `FP16_Optimizer` with Pytorch DistributedDataParallel.
27
28
29
30
31
32
33
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
```

34
**distributed_pytorch** shows an example using `FP16_Optimizer` with Apex DistributedDataParallel.
35
36
37
38
39
40
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
```