README.md 1.36 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

Michael Carilli's avatar
Michael Carilli committed
12
#### Checkpointing
13
`FP16_Optimizer` also supports checkpointing with the same control flow as ordinary Pytorch optimizers.
14
15
`save_load.py` shows an example.  Test via `python save_load.py`.

16
See [the API documentation](https://nvidia.github.io/apex/fp16_utils.html#apex.fp16_utils.FP16_Optimizer.load_state_dict) for more details.
17

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

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