# Lightning ⚡ GraphCore
**Audience:** Users looking to save money and run large models faster using single or multiple IPU devices.
[![lightning](https://img.shields.io/badge/-Lightning_2.0+-792ee5?logo=pytorchlightning&logoColor=white)](https://lightning.ai/)
[![Build Status](https://dev.azure.com/Lightning-AI/compatibility/_apis/build/status%2Faccelerators%2FLightning-AI.lightning-Graphcore?branchName=main)](https://dev.azure.com/Lightning-AI/compatibility/_build/latest?definitionId=48&branchName=main)
[![General checks](https://github.com/Lightning-AI/lightning-graphcore/actions/workflows/ci-checks.yml/badge.svg?event=push)](https://github.com/Lightning-AI/lightning-graphcore/actions/workflows/ci-checks.yml)
[![Deploy Docs](https://github.com/Lightning-AI/lightning-Graphcore/actions/workflows/docs-deploy.yml/badge.svg?event=push)](https://lightning-ai.github.io/lightning-Graphcore/)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Lightning-AI/lightning-Graphcore/main.svg)](https://results.pre-commit.ci/latest/github/Lightning-AI/lightning-Graphcore/main)
## What is an IPU?
The Graphcore [Intelligence Processing Unit (IPU)](https://www.graphcore.ai/products/ipu), built for Artificial Intelligence and Machine Learning, consists of many individual cores, called *tiles*, allowing highly parallel computation. Due to the high bandwidth between tiles, IPUs facilitate machine learning loads where parallelization is essential. Because computation is heavily parallelized,
IPUs operate in a different way to conventional accelerators such as CPU/GPUs. IPUs do not require large batch sizes for maximum parallelization, can provide optimizations across the compiled graph and rely on model parallelism to fully utilize tiles for larger models.
IPUs are used to build IPU-PODs, rack-based systems of IPU-Machines for larger workloads. See the [IPU Architecture](https://www.graphcore.ai/products/ipu) for more information.
See the [Graphcore Glossary](https://docs.graphcore.ai/projects/graphcore-glossary/) for the definitions of other IPU-specific terminology.
______________________________________________________________________
## Installation
```bash
pip install -U lightning-graphcore[lightning]
```
## Run on IPU
To enable PyTorch Lightning to utilize the IPU accelerator, simply provide `accelerator="ipu"` parameter to the Trainer class.
To use multiple IPUs set the devices to a number that is a power of 2 (i.e: 2, 4, 8, 16, ...)
```py
from lightning import Trainer
# run on as many IPUs as available by default
trainer = Trainer(accelerator="auto", devices="auto", strategy="auto")
# equivalent to
trainer = Trainer()
# run on one IPU
trainer = Trainer(accelerator="ipu", devices=1)
# run on multiple IPUs
trainer = Trainer(accelerator="ipu", devices=8)
# choose the number of devices automatically
trainer = Trainer(accelerator="ipu", devices="auto")
```
## How to access IPUs
To use IPUs you must have access to a system with IPU devices. To get access see [get started](https://www.graphcore.ai/getstarted).
You must ensure that the IPU system has enabled the PopART and Poplar packages from the SDK. Instructions are in the Get Started guide for your IPU system, on the Graphcore [documents portal](https://docs.graphcore.ai/page/getting-started.html).
## Known limitations
Currently there are some known limitations that are being addressed in the near future to make the experience seamless when moving from different devices.
Please see the [MNIST example](https://github.com/Lightning-AI/lightning/blob/master/examples/pytorch/ipu/mnist_sample.py) which displays most of the limitations and how to overcome them till they are resolved.
- `self.log` is not supported in the `training_step`, `validation_step`, `test_step` or `predict_step`. This is due to the step function being traced and sent to the IPU devices.
- Since the step functions are traced, branching logic or any form of primitive values are traced into constants. Be mindful as this could lead to errors in your custom code.
- Clipping gradients is not supported.
- It is not possible to use `BatchSampler` in your dataloaders if you are using multiple IPUs.
- IPUs handle the data transfer to the device on the host, hence the hooks `ModelHooks.transfer_batch_to_device` and `ModelHooks.on_after_batch_transfer` do not apply here and if you have overridden any of them, an exception will be raised.
Raw data
{
"_id": null,
"home_page": "https://github.com/Lightning-AI/lightning-graphcore",
"name": "lightning-graphcore",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "deep learning,pytorch,AI",
"author": "Lightning-AI et al.",
"author_email": "name@lightning.ai",
"download_url": "https://files.pythonhosted.org/packages/de/ec/2d76d78d53c0a02fc4f1784dcc9d628b6d90b9371d1ffc63ecb533992c48/lightning-graphcore-0.1.0.tar.gz",
"platform": null,
"description": "# Lightning \u26a1 GraphCore\n\n**Audience:** Users looking to save money and run large models faster using single or multiple IPU devices.\n\n[![lightning](https://img.shields.io/badge/-Lightning_2.0+-792ee5?logo=pytorchlightning&logoColor=white)](https://lightning.ai/)\n[![Build Status](https://dev.azure.com/Lightning-AI/compatibility/_apis/build/status%2Faccelerators%2FLightning-AI.lightning-Graphcore?branchName=main)](https://dev.azure.com/Lightning-AI/compatibility/_build/latest?definitionId=48&branchName=main)\n[![General checks](https://github.com/Lightning-AI/lightning-graphcore/actions/workflows/ci-checks.yml/badge.svg?event=push)](https://github.com/Lightning-AI/lightning-graphcore/actions/workflows/ci-checks.yml)\n[![Deploy Docs](https://github.com/Lightning-AI/lightning-Graphcore/actions/workflows/docs-deploy.yml/badge.svg?event=push)](https://lightning-ai.github.io/lightning-Graphcore/)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Lightning-AI/lightning-Graphcore/main.svg)](https://results.pre-commit.ci/latest/github/Lightning-AI/lightning-Graphcore/main)\n\n## What is an IPU?\n\nThe Graphcore [Intelligence Processing Unit (IPU)](https://www.graphcore.ai/products/ipu), built for Artificial Intelligence and Machine Learning, consists of many individual cores, called *tiles*, allowing highly parallel computation. Due to the high bandwidth between tiles, IPUs facilitate machine learning loads where parallelization is essential. Because computation is heavily parallelized,\n\nIPUs operate in a different way to conventional accelerators such as CPU/GPUs. IPUs do not require large batch sizes for maximum parallelization, can provide optimizations across the compiled graph and rely on model parallelism to fully utilize tiles for larger models.\n\nIPUs are used to build IPU-PODs, rack-based systems of IPU-Machines for larger workloads. See the [IPU Architecture](https://www.graphcore.ai/products/ipu) for more information.\n\nSee the [Graphcore Glossary](https://docs.graphcore.ai/projects/graphcore-glossary/) for the definitions of other IPU-specific terminology.\n\n______________________________________________________________________\n\n## Installation\n\n```bash\npip install -U lightning-graphcore[lightning]\n```\n\n## Run on IPU\n\nTo enable PyTorch Lightning to utilize the IPU accelerator, simply provide `accelerator=\"ipu\"` parameter to the Trainer class.\n\nTo use multiple IPUs set the devices to a number that is a power of 2 (i.e: 2, 4, 8, 16, ...)\n\n```py\nfrom lightning import Trainer\n# run on as many IPUs as available by default\ntrainer = Trainer(accelerator=\"auto\", devices=\"auto\", strategy=\"auto\")\n# equivalent to\ntrainer = Trainer()\n\n# run on one IPU\ntrainer = Trainer(accelerator=\"ipu\", devices=1)\n# run on multiple IPUs\ntrainer = Trainer(accelerator=\"ipu\", devices=8)\n# choose the number of devices automatically\ntrainer = Trainer(accelerator=\"ipu\", devices=\"auto\")\n```\n\n## How to access IPUs\n\nTo use IPUs you must have access to a system with IPU devices. To get access see [get started](https://www.graphcore.ai/getstarted).\n\nYou must ensure that the IPU system has enabled the PopART and Poplar packages from the SDK. Instructions are in the Get Started guide for your IPU system, on the Graphcore [documents portal](https://docs.graphcore.ai/page/getting-started.html).\n\n## Known limitations\n\nCurrently there are some known limitations that are being addressed in the near future to make the experience seamless when moving from different devices.\n\nPlease see the [MNIST example](https://github.com/Lightning-AI/lightning/blob/master/examples/pytorch/ipu/mnist_sample.py) which displays most of the limitations and how to overcome them till they are resolved.\n\n- `self.log` is not supported in the `training_step`, `validation_step`, `test_step` or `predict_step`. This is due to the step function being traced and sent to the IPU devices.\n- Since the step functions are traced, branching logic or any form of primitive values are traced into constants. Be mindful as this could lead to errors in your custom code.\n- Clipping gradients is not supported.\n- It is not possible to use `BatchSampler` in your dataloaders if you are using multiple IPUs.\n- IPUs handle the data transfer to the device on the host, hence the hooks `ModelHooks.transfer_batch_to_device` and `ModelHooks.on_after_batch_transfer` do not apply here and if you have overridden any of them, an exception will be raised.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Lightning support for GraphCore accelerators",
"version": "0.1.0",
"project_urls": {
"Bug Tracker": "https://github.com/Lightning-AI/lightning-graphcore/issues",
"Documentation": "https://lightning-graphcore.rtfd.io/en/latest/",
"Download": "https://github.com/Lightning-AI/lightning-graphcore",
"Homepage": "https://github.com/Lightning-AI/lightning-graphcore",
"Source Code": "https://github.com/Lightning-AI/lightning-graphcore"
},
"split_keywords": [
"deep learning",
"pytorch",
"ai"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ab8eee4ad1f1c9e809625a07c98670df1f5b0f645c26ed9cd460b75d5eb5ec7b",
"md5": "a5e633498d3422c7c5c194b973ef642c",
"sha256": "a70a6434ae60931b887b64f85a768b69879f4df563f1e4d87b1a9f4244d44f86"
},
"downloads": -1,
"filename": "lightning_graphcore-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a5e633498d3422c7c5c194b973ef642c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 18079,
"upload_time": "2023-10-03T12:47:12",
"upload_time_iso_8601": "2023-10-03T12:47:12.840001Z",
"url": "https://files.pythonhosted.org/packages/ab/8e/ee4ad1f1c9e809625a07c98670df1f5b0f645c26ed9cd460b75d5eb5ec7b/lightning_graphcore-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "deec2d76d78d53c0a02fc4f1784dcc9d628b6d90b9371d1ffc63ecb533992c48",
"md5": "b195aa3378b01f80565fd1d57b4e2676",
"sha256": "548951beccd9ba7ce1822d34d19e3331dbbe14c1773a77f29c12689e2f8455fb"
},
"downloads": -1,
"filename": "lightning-graphcore-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "b195aa3378b01f80565fd1d57b4e2676",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 18823,
"upload_time": "2023-10-03T12:47:14",
"upload_time_iso_8601": "2023-10-03T12:47:14.073303Z",
"url": "https://files.pythonhosted.org/packages/de/ec/2d76d78d53c0a02fc4f1784dcc9d628b6d90b9371d1ffc63ecb533992c48/lightning-graphcore-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-03 12:47:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Lightning-AI",
"github_project": "lightning-graphcore",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "lightning-graphcore"
}