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

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

Michael Carilli's avatar
Michael Carilli committed
6
#### Closures
7
`FP16_Optimizer` supports closures with the same control flow as ordinary Pytorch optimizers.  
8
9
`closure.py` shows an example.  Test via `python closure.py`.

10
See [the API documentation](https://nvidia.github.io/apex/fp16_utils.html#apex.fp16_utils.FP16_Optimizer.step) for more details.
11

12
13
<!---
TODO:  add checkpointing example showing deserialization on the correct device
Michael Carilli's avatar
Michael Carilli committed
14
#### Checkpointing
15
`FP16_Optimizer` also supports checkpointing with the same control flow as ordinary Pytorch optimizers.
16
17
`save_load.py` shows an example.  Test via `python save_load.py`.

18
See [the API documentation](https://nvidia.github.io/apex/fp16_utils.html#apex.fp16_utils.FP16_Optimizer.load_state_dict) for more details.
19
-->
20

Michael Carilli's avatar
Michael Carilli committed
21
#### Distributed
22
**distributed_apex** shows an example using `FP16_Optimizer` with Apex DistributedDataParallel.
23
The usage of `FP16_Optimizer` with distributed does not need to change from ordinary single-process 
24
usage. Test via
25
```bash
26
cd distributed_apex
27
28
29
bash run.sh
```

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