• Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PyTorch interface for the IPU

PopTorch and PopTorch Geometric.

PopTorch - PyTorch integration for the Graphcore IPU

PopTorch is a set of extensions for PyTorch enabling models to be trained, evaluated and used on the Graphcore IPU.

More information can be found in the PopTorch User Guide.

PopTorch Geometric - PyTorch Geometric integration for the Graphcore IPU

PopTorch Geometric is a set of extensions for PyTorch Geometric, enabling Graph Neural Network models to be trained, evaluated and used on the Graphcore IPU. PopTorch Geometric depends on the functionality provided by PopTorch.

More information can be found in the PopTorch Geometric User Guide.

Prerequisites

These instructions assume you are building PopTorch and PopTorch Geometric on Ubuntu 20.04.

To install and run PopTorch and PopTorch Geometric you will need:

  • Python 3.8
  • pip3 >= 18.1
  • The Poplar SDK
sudo apt install -y python3 python3-pip

To build PopTorch and PopTorch Geometric from sources you will need all of the above and:

  • git
  • curl
  • g++
sudo apt install -y git curl g++

To build the documentation you will also need LaTeX:

sudo apt install -y texlive-full

Install the Poplar SDK

The Poplar SDK can be downloaded from: https://www.graphcore.ai/downloads.

Set the following environment variable to point to the installed Poplar SDK:

export SDK_PATH=/path/to/poplar_sdk-ubuntu_20_04*

PopTorch must be built against a compatible version of the SDK. For example, the "sdk-release-3.2" branch of PopTorch must be built against Poplar SDK 3.2.

Installation

Make sure pip3 is up to date (You need pip3 >= 18.1):

pip3 install -U pip --user

Install the PopTorch wheel (Torch will automatically be installed in the process):

pip3 install ${SDK_PATH}/poptorch-*.whl

Once the PopTorch wheel has been installed, PopTorch Geometric wheel can be installed if needed (PyTorch Geometric will automatically be installed in the process):

pip3 install ${SDK_PATH}/poptorch_geometric-*.whl

Usage

The PopTorch wheel doesn't include the PopART and Poplar binaries, so you need to make sure they are in your path before loading PopTorch or PopTorch Geometric. This is done by sourcing their respective enable.sh scripts:

. ${SDK_PATH}/poplar-ubuntu_20_04*/enable.sh
. ${SDK_PATH}/popart-ubuntu_20_04*/enable.sh

You can check everything is in order by running:

python3 -c "import poptorch;print(poptorch.__version__)"

And similarly for PopTorch Geometric:

python3 -c "import poptorch_geometric;print(poptorch_geometric.__version__)"

More information can be found in the PopTorch User Guide

Build instructions

We use Mambaforge as build environment manager.

  1. Clone the PopTorch repository
git clone https://github.com/graphcore/poptorch.git
  1. Create a folder for your build
mkdir build
cd build
  1. Create a build environment and install the dependencies.
../poptorch/scripts/create_buildenv.py
  1. Activate the build environment
. activate_buildenv.sh
  1. Configure the build
cmake ../poptorch -DSDK_DIR=${SDK_PATH} -GNinja

By default, PopTorch will be built in release mode. To build in debug mode add -DCMAKE_BUILD_TYPE=Debug.

To build the documentation, add -DBUILD_DOCS=ON. The HTML and PDF documentation will be generated in docs/.

  1. Compile the PopTorch and PopTorch Geometric libraries
ninja install

If you're only going to use PopTorch or PopTorch Geometric for development purposes then you can stop here. Source the enable script in the PopTorch build folder and you can start using PopTorch:

. enable.sh
python3 -c "import poptorch;print(poptorch.__version__)"

Similarly for PopTorch Geometric:

. enable.sh
python3 -c "import poptorch_geometric;print(poptorch_geometric.__version__)"
  1. (Optional) Build the PopTorch wheel
ninja poptorch_wheel

The wheel will be created in install/dist.

  1. (Optional) Build the PopTorch Geometric wheel
ninja poptorch_geometric_wheel

The wheel will be created in install/dist.

Run the tests

To run the tests:

# Run all the tests, print the output only on failure, run 80 tests in parallel
./test.sh -j80
# PopTorch has 3 test labels: examples, short, long. To run all the tests except the long ones:
./test.sh -j80 -LE long
# To run only the short tests
./test.sh -j80 -L short
# Filter the tests by name using -R
./test.sh -j80 -R half_
# For more information:
./test.sh --help

Note: If you run the tests in parallel, make sure to tell PopTorch to wait for an IPU to become available if they are all in use:

export POPTORCH_WAIT_FOR_IPU=1

Tests can also be run individually using pytest:

. enable.sh
python3 -m pytest ../poptorch/tests/options_test.py
# add -s to get the whole output
# -k to filter the tests by name
python3 -m pytest ../poptorch/tests/options_test.py -s -k popart

Tests specific for Graph Neural Networks are located in tests/gnn/ subdirectory:

. enable.sh
python3 -m pytest ../poptorch/tests/gnn/test_basic_gnn.py
# add -s to get the whole output
# -k to filter the tests by name
python3 -m pytest ../poptorch/tests/gnn/test_basic_gnn.py -s -k GraphSAGE

Feedback / issues

Please create issues here

More Repositories

1

examples

Example code and applications for machine learning on Graphcore IPUs
Python
313
star
2

poplibs

Poplar libraries
C++
115
star
3

tutorials

Training material for IPU users: tutorials, feature examples, simple applications
Python
86
star
4

tensorflow

TensorFlow for the IPU
C++
76
star
5

ogb-lsc-pcqm4mv2

The OGB-LSC is the Large Scale Competition by Open Graph Benchmark to help accelerate research into machine learning on graph structured data
Jupyter Notebook
64
star
6

portfolio-examples

Demonstrators and experimental applications for ML using Graphcore IPUs
Python
35
star
7

poprithms

Graph algorithms for machine learning frameworks
C++
27
star
8

distributed-kge-poplar

The application is a end-user training and evaluation system for standard knowledge graph embedding models. It was developed to optimise the WikiKG90Mv2 dataset
C++
13
star
9

graphcore-research

Implementations and illustrative code to accompany our research publications
12
star
10

gpt-j

Notebook for running GPT-J/GPT-J-6B – the cost-effective alternative to ChatGPT, GPT-3 & GPT-4 for many NLP tasks. Available on IPUs as a Paperspace notebook.
Python
12
star
11

pytorch-lightning-examples

A collection of tutorials and examples showing how to use Graphcore's IPUs with PyTorch Lightning
Python
9
star
12

Gradient-HuggingFace

Tasks and tutorials using Graphore's IPU with Hugging Face. Originally at https://github.com/gradient-ai/Graphcore-HuggingFace
Jupyter Notebook
9
star
13

PopTransformer

PopTransformer provides a fundamental framework(including layers, operators, models, etc) that allow users to develop and run highly optimized transformer-based models(inference-only) with Poplar SDK on Graphcore IPU.
C++
8
star
14

legacy_drivers_and_tools

6
star
15

PopRT

Python
6
star
16

Gradient-Pytorch-Geometric

A repository of tutorials and examples demonstrating use of PyTorch Geometric with IPUs
Jupyter Notebook
6
star
17

popart

Poplar Advanced Runtime for the IPU
C++
5
star
18

popvision_graph_analyser

5
star
19

license-checker

A tool to accumulate license information for pip and aptitude dependencies.
Python
5
star
20

demo-in-a-box

Jupyter Notebook
5
star
21

popvision_system_analyser

4
star
22

dolly-ai

Run Dolly, the world’s first truly open instruction-tuned LLM, with your own prompts on IPUs
Python
4
star
23

api-deployment

Example of deployment of a NLP inference server on Gcore. Using FastAPI, Huggingface's optimum-graphcore and Github workflows.
Python
4
star
24

simple-server-framework

Simple Server Framework provides a wrapper to add serving to an application using a minimal declarative config and utilities to package and deploy the application.
Python
3
star
25

whisper-ai

Speech Recognition (ASR) on Graphcore IPUs using OpenAI's Whisper
Jupyter Notebook
2
star
26

caas-poplar-appliance

caas-poplar-appliance
Jinja
2
star
27

graphcore-cloud-tools

Graphcore cloud utilities to support Paperspace functionality and user monitoring.
Python
2
star
28

helm-charts

2
star
29

ipu_tensorflow_addons

IPU TensorFlow Addons
Python
2
star
30

flan-t5

Notebook for Flan-T5 – an alternative to large language models like GPT-3 & GPT-4 for NLP tasks like named entity recognition and text generation.
Jupyter Notebook
2
star
31

keras

Keras for the IPU
Python
1
star
32

popxl-addons

A collection of addons for PopXL
Python
1
star
33

tgn-ipu

Python
1
star
34

stable-diffusion

Notebook for running Stable Diffusion – the Generative AI alternative to Dall-E and Midjourney – on IPUs
Jupyter Notebook
1
star
35

examples-utils

Utils and common code for Graphcore's example applications
Python
1
star
36

ipu_assembly_support

Visual Studio Code extension to support writing IPU assembly.
Rust
1
star
37

Gradient-Pytorch

Jupyter Notebook
1
star