Giter Club home page Giter Club logo

optimum-graphcore's Introduction

Optimum Graphcore

πŸ€— Optimum Graphcore is the interface between the πŸ€— Transformers library and Graphcore IPUs. It provides a set of tools enabling model parallelization and loading on IPUs, training and fine-tuning on all the tasks already supported by Transformers while being compatible with the Hugging Face Hub and every model available on it out of the box.

What is an Intelligence Processing Unit (IPU)?

Quote from the Hugging Face blog post:

IPUs are the processors that power Graphcore’s IPU-POD datacenter compute systems. This new type of processor is designed to support the very specific computational requirements of AI and machine learning. Characteristics such as fine-grained parallelism, low precision arithmetic, and the ability to handle sparsity have been built into our silicon.

Instead of adopting a SIMD/SIMT architecture like GPUs, Graphcore’s IPU uses a massively parallel, MIMD architecture, with ultra-high bandwidth memory placed adjacent to the processor cores, right on the silicon die.

This design delivers high performance and new levels of efficiency, whether running today’s most popular models, such as BERT and EfficientNet, or exploring next-generation AI applications.

Poplar SDK setup

A Poplar SDK environment needs to be enabled to use this library. Please refer to Graphcore's Getting Started guide.

Install

To install the latest release of this package:

pip install optimum[graphcore]

Optimum Graphcore is a fast-moving project, and you may want to install from source.

pip install git+https://github.com/huggingface/optimum-graphcore.git

Installing in developer mode

If you are working on the optimum-graphcore code then you should use an editable install. First clone and install optimum:

git clone https://github.com/huggingface/optimum
cd optimum
pip install -e .
cd ..

The clone and install optimum-graphcore:

git clone https://github.com/huggingface/optimum-graphcore
cd optimum-graphcore
pip install -e .

Now whenever you change the code, you'll be able to run with those changes instantly.

Running the examples

There are a number of examples provided in the examples directory. Each of these contains a README with command lines for running them on IPUs with Optimum Graphcore.

Please install the requirements for every example:

cd <example-folder>
pip install -r requirements.txt

How to use it?

πŸ€— Optimum Graphcore was designed with one goal in mind: make training and evaluation straightforward for any πŸ€— Transformers user while leveraging the complete power of IPUs. It requires minimal compared to using πŸ€— Transformers.

To immediately use a model on a given input (text, image, audio, ...), we support the pipeline API:

->>> from transformers import pipeline
+>>> from optimum.graphcore import pipeline

# Allocate a pipeline for sentiment-analysis
->>> classifier = pipeline('sentiment-analysis', model="distilbert-base-uncased-finetuned-sst-2-english")
+>>> classifier = pipeline('sentiment-analysis', model="distilbert-base-uncased-finetuned-sst-2-english", ipu_config = "Graphcore/distilbert-base-ipu")
>>> classifier('We are very happy to introduce pipeline to the transformers repository.')
[{'label': 'POSITIVE', 'score': 0.9996947050094604}]

It is also super easy to use the Trainer API:

-from transformers import Trainer, TrainingArguments
+from optimum.graphcore import IPUConfig, IPUTrainer, IPUTrainingArguments

-training_args = TrainingArguments(
+training_args = IPUTrainingArguments(
     per_device_train_batch_size=4,
     learning_rate=1e-4,
+    # Any IPUConfig on the Hub or stored locally
+    ipu_config_name="Graphcore/bert-base-ipu",
+)
+
+# Loading the IPUConfig needed by the IPUTrainer to compile and train the model on IPUs
+ipu_config = IPUConfig.from_pretrained(
+    training_args.ipu_config_name,
 )

 # Initialize our Trainer
-trainer = Trainer(
+trainer = IPUTrainer(
     model=model,
+    ipu_config=ipu_config,
     args=training_args,
     train_dataset=train_dataset if training_args.do_train else None,
     ...  # Other arguments

For more information, check our documentation

Supported Models

The following model architectures and tasks are currently supported by πŸ€— Optimum Graphcore:

Pre-Training Masked LM Causal LM Seq2Seq LM (Summarization, Translation, etc) Sequence Classification Token Classification Question Answering Multiple Choice Image Classification
BART βœ… ❌ βœ… βœ… ❌
BERT βœ… βœ… ❌ βœ… βœ… βœ… βœ…
ConvNeXt βœ… βœ…
DeBERTa βœ… βœ… βœ… βœ… βœ…
DistilBERT ❌ βœ… βœ… βœ… βœ… βœ…
GPT-2 βœ… βœ… βœ… βœ…
HuBERT ❌ βœ…
LXMERT ❌ βœ…
RoBERTa βœ… βœ… ❌ βœ… βœ… βœ… βœ…
T5 βœ… βœ…
ViT ❌ βœ…
Wav2Vec2 βœ…

If you find any issue while using those, please open an issue or a pull request.

optimum-graphcore's People

Contributors

jimypbr avatar michaelbenayoun avatar gejinchen avatar lewtun avatar regisss avatar juliensimon avatar katalinic-gc avatar payoto avatar hja03 avatar rahult-graphcore avatar thorinf avatar sergiopperez avatar mishig25 avatar blazejba avatar jeffboudier avatar lesteve avatar manuelesigona avatar internetoftim avatar anjleeg-gcai avatar curly-engineer avatar fxmarty avatar joao-alex-cunha avatar

Watchers

Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.