Repository navigation
Add TorchTPU entry #2137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ejmartinezm
wants to merge
6
commits into
pytorch:site
Choose a base branch
from
ejmartinezm:add-torchtpu
base: site
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add TorchTPU entry #2137
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f06b3e5
Add TorchTPU entry
ejmartinezm 6503a32
Update TorchTPU installation documentation
ejmartinezm 235c29a
Update _get_started/additional_platforms/torch_tpu.md
ejmartinezm 35796c3
Update _get_started/additional_platforms/torch_tpu.md
ejmartinezm ec9b17a
Remove TCMalloc recommendation from torch_tpu.md
ejmartinezm 5297ccc
Update _get_started/additional_platforms/torch_tpu.md
ejmartinezm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "name": "TorchTPU", | ||
| "support_channel": "https://github.com/google-pytorch/torch_tpu/issues", | ||
| "stable": { | ||
| "linux": "pip3 install torch --index-url https://download.pytorch.org/whl/cpu && pip3 install torch-tpu" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Installing on Google Cloud TPU (TorchTPU) | ||
|
|
||
| **TorchTPU (`torch_tpu`)** is a native PyTorch backend built for Google Cloud Tensor Processing Units (TPUs). It enables Google Cloud TPUs to run PyTorch workloads natively by integrating as a `PrivateUse1` backend using the dispatch key `"tpu"`. TorchTPU supports eager execution, `torch.compile()`, distributed training (`torch.distributed`, `DTensor`, `FSDP2`), and custom kernels (`Pallas`, `Helion`). | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Hardware Requirements | ||
|
|
||
| * A provisioned Google Cloud TPU VM (TPU v5e, v5p, v6e, or v7x) on Google Compute Engine (GCE), access to Google Kubernetes Engine (GKE) cluster, or a TPU runtime in Google Colab. | ||
|
|
||
| ### Software Requirements | ||
|
|
||
| * Linux (Ubuntu 22.04+ recommended) | ||
| * Python >= 3.10 | ||
| * `libtpu` runtime library (automatically installed with `torch-tpu`) | ||
|
|
||
| ## Installation | ||
|
|
||
| ### pip | ||
|
|
||
| ```bash | ||
| pip3 install torch --index-url https://download.pytorch.org/whl/cpu && pip3 install torch-tpu | ||
| ``` | ||
|
|
||
| Use the `pip` package manager to install the CPU build of PyTorch alongside `torch-tpu`. Select your preferred options in the selector above to get the installation command. | ||
|
|
||
| ## Verification | ||
|
|
||
| To ensure that PyTorch was installed correctly with TorchTPU support, run the following code: | ||
|
|
||
| ```python | ||
| import torch | ||
| device = torch.device("tpu") | ||
|
|
||
| x = torch.randn(2, 2, device="tpu") | ||
| y = torch.randn(2, 2, device="tpu") | ||
| z = x.mm(y) | ||
|
|
||
| print(z) | ||
| ``` | ||
|
|
||
| The following, or a similar output, indicates successful installation: | ||
|
|
||
| ```bash | ||
| tensor([[-0.4218, 0.8912], | ||
| [ 0.1534, -1.1045]], device='tpu:0') | ||
| ``` | ||
|
|
||
| ## Documentation | ||
|
|
||
| For more information, please visit: | ||
|
|
||
| * [TorchTPU Official Documentation & User Guide](https://google-pytorch.github.io/torch_tpu/) | ||
| * [Supported vs. Unsupported Feature Matrix](https://github.com/google-pytorch/torch_tpu/blob/main/docs/features_matrix.md) | ||
| * [Google Cloud TPU Documentation](https://cloud.google.com/tpu/docs) | ||
| * [GitHub Repository](https://github.com/google-pytorch/torch_tpu) | ||
| * [PyPI](https://pypi.org/project/torch-tpu/) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.