This example shows how to use replication in TensorFlow to train a very simple CIFAR-10 Conv model.
Replication allows data-parallelism, where multiple copies of the same model concurrently train on partitions of the same dataset, increasing throughput. Each replica trains on a different (set of) IPU(s), building up a buffer of calculated gradients. Periodically, the replicas synchronise and combine their individual gradients in what's called an "all-reduce".
When using replication, ensure that:
- The data pipeline has enough bandwidth to push the required volume of data;
- Adjustments are made to the learning rate, as replication increases the effective batch size;
- Adjustments are made to the calculation of throughput.
Note: Care should be used when finding the optimal number of replicas and size of the max cross replica sum buffer - please see the code for a more detailed explanation of how these parameters affect model memory and performance.
replication.pyThe main TensorFlow file showcasing replication.README.mdThis file.test_replication.pyScript for testing this example.
-
Prepare the TensorFlow environment.
Install the Poplar SDK following the Getting Started guide for your IPU system. Make sure to run the enable.sh script for Poplar and activate a Python virtualenv with the tensorflow-1 wheel from the Poplar SDK installed.
-
Run the script.
python replication.py
Run replication.py with the -h option to list all available command line options