{
  "description": "Browse aymeric's, an independent, searchable archive of readable snapshots from followed feeds, preserved in Git with aggr.",
  "feed_url": "https://aggr.aymericbeaumet.com/sources/github.com/google-pytorch/feed.json",
  "home_page_url": "https://aggr.aymericbeaumet.com/sources/github.com/google-pytorch/",
  "items": [
    {
      "authors": [
        {
          "name": "ilreb"
        }
      ],
      "content_html": "<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/google-pytorch/torch_tpu/blob/main/docs/images/torchtpu_logo.avif\"><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://github.com/google-pytorch/torch_tpu/raw/main/docs/images/torchtpu_logo.avif\" alt=\"TorchTPU Logo\" loading=\"eager\" decoding=\"async\" fetchpriority=\"high\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></a></p>\n<h2>Description</h2>\n<p>This project provides a PyTorch backend for Google's Tensor Processing Units (TPUs), enabling users to run PyTorch models and operations on TPU devices. It includes custom ATen kernels for various PyTorch operations, a compilation cache for optimizing execution, and examples for distributed training and model inference.</p>\n<h2>Features</h2>\n<ul>\n<li>PyTorch ATen kernel implementation for TPU.</li>\n<li>Compilation cache for optimized execution of XLA computations.</li>\n<li>Support for distributed training (Data Parallelism, Tensor Parallelism).</li>\n<li>Examples for various models (Llama, Qwen, ResNet, DLRM, minGPT, UNet).</li>\n<li>Integration with <code>torch.compile()</code> for graph mode execution.</li>\n<li>Utilities for debugging and benchmarking.</li>\n</ul>\n<h2>User Guide and Interactive Notebooks</h2>\n<p>A user guide is available at <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://torchtpu.readthedocs.io/\">https://torchtpu.readthedocs.io/</a>. This is a static version of the interactive notebooks. They are available in the docs folder.</p>\n<p>The notebooks are Marimo (similar to Jupyter). They can be run with <code>marimo edit file.py</code> and then you can access them in your browser. You will need to be running this from a TPU VM, a v6e GCE instance is easiest.</p>\n<h2>Installation</h2>\n<p>The same instructions are available in the user guide linked above.</p>\n<p>TorchTPU's Python version support policy matches <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/pytorch/pytorch/blob/main/RELEASE.md#release-compatibility-matrix\">PyTorch's Release Compatibility Matrix</a>. Currently, <strong>Python 3.11+</strong> is supported. See the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/google-pytorch/torch_tpu/blob/main/docs/developers/python_support_policy.md\">Python Version Support Policy</a> for more details.</p>\n<p>First create a Python virtual environment:</p>\n<pre><code class=\"language-shell\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">python</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>m</span> venv .venv</span>\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-support syntax-function syntax-source syntax-shell\">source</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> .venv/bin/activate</span>\n</span></span></code></pre>\n<p>or, with <code>uv</code></p>\n<pre><code class=\"language-shell\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">uv</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> venv .venv</span>\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-support syntax-function syntax-source syntax-shell\">source</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> .venv/bin/activate</span>\n</span></span></code></pre>\n<h3>Install via pip</h3>\n<p>Install the latest public release (<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://pypi.org/project/torch-tpu/0.2.0/\">0.2.0 on PyPI</a>) (for <code>uv</code> prepend <code>uv</code> to all <code>pip</code> commands):</p>\n<pre><code class=\"language-shell\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">pip</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> install torch_tpu==0.2.0<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>extra-index-url</span> https://download.pytorch.org/whl/cpu</span>\n</span></span></code></pre>\n<h3>Build from source</h3>\n<p>Wheels can be built via:</p>\n<pre><code class=\"language-shell\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">bazel</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> build<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>config</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-option syntax-shell\">=</span>wheel_common //ci/wheel:torch_tpu_wheel</span>\n</span></span></code></pre>\n<p>All OSS Bazel builds default to optimized mode (<code>-c opt</code>) automatically via <code>.bazelrc</code>. Unoptimized builds (<code>-c fastbuild</code>, <code>-c dbg</code>) can degrade performance and are not used for wheel builds. If you are developing or debugging C++ code and explicitly want an unoptimized wheel, pass <code>--//:allow_unoptimized_wheel=True</code>:</p>\n<pre><code class=\"language-shell\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">bazel</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> build<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>c</span> dbg<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>config</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-option syntax-shell\">=</span>wheel_common //ci/wheel:torch_tpu_wheel <span class=\"syntax-punctuation syntax-separator syntax-continuation syntax-line syntax-shell\">\\\n</span>    --//:allow_unoptimized_wheel=True</span>\n</span></span></code></pre>\n<p><code>--config=wheel_common</code> is required, and the build fails at build time without it. The config sets <code>--//:wheel_build=True</code>, which routes the shared XLA/MLIR backend through the <code>torch_version</code>-reset transition so that pywrap factors it into a single <code>libxla_base.so</code>; built without the flag, every per-version common ships its own copy of the backend and the resulting wheel aborts on <code>import torch</code> with duplicate static registrations.</p>\n<p><code>wheel_common</code> also turns on the Remote Build Execution (RBE) remote cache and remote executor. If you do not have RBE credentials, append <code>--config=no_rbe</code> to strip those flags back out:</p>\n<pre><code class=\"language-shell\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">bazel</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> build<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>config</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-option syntax-shell\">=</span>wheel_common //ci/wheel:torch_tpu_wheel<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>config</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-option syntax-shell\">=</span>no_rbe</span>\n</span></span></code></pre>\n<p>The order matters here: <code>--config=no_rbe</code> has to come after <code>--config=wheel_common</code>, because the later config is the one that wins for the remote-cache and remote-executor flags they both set.</p>\n<p>Install wheel via:</p>\n<pre><code class=\"language-shell\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-support syntax-function syntax-cd syntax-shell\">cd</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&lt;</span>path_to_repo<span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&gt;</span>\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">python</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>m</span> venv .venv</span><span class=\"syntax-keyword syntax-operator syntax-logical syntax-continue syntax-shell\">;</span> <span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-support syntax-function syntax-source syntax-shell\">source</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> .venv/bin/activate</span>\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> The extra-index-url provides the CPU version of torch rather than the default CUDA build.</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">pip</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> install ../bazel-bin/ci/wheel/<span class=\"syntax-keyword syntax-operator syntax-regexp syntax-quantifier syntax-shell\">*</span>.whl<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>extra-index-url</span> https://download.pytorch.org/whl/cpu</span>\n</span></span></code></pre>\n<p>Note that installing without <code>--extra-index-url https://download.pytorch.org/whl/cpu</code> will install the CUDA version of <code>torch</code>; pass <code>--extra-index-url</code> as shown above or install the CPU build separately.</p>\n<h2>Getting Started</h2>\n<p>Some pointers to get you started:</p>\n<ul>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/pytorch/pytorch\">PyTorch: Official PyTorch documentation</a></li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://torchtpu.readthedocs.io/\">Tutorials and examples: easy to understand PyTorch code using TorchTPU</a></li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/google-pytorch/torch_tpu/blob/main/docs/public_apis.md\">Public APIs: the TorchTPU APIs that you can use</a></li>\n</ul>\n<h2>Dependencies</h2>\n<p>The project uses Bazel for dependency management. Key Python dependencies are:</p>\n<p>TBD</p>\n<h2>Bazel setup</h2>\n<p>This project uses Bazel for building and dependency management.</p>\n<p>To install Bazel, we actually install Bazelisk, which is a transparent wrapper that handles downloading and installing Bazel itself.</p>\n<p>There are several ways to install Bazelisk. Here are some common ways:</p>\n<ul>\n<li>\n<p>If you have Go installed:</p>\n<pre><code><span class=\"code-snippet\">go install github.com/bazelbuild/bazelisk@latest\n</span></code></pre>\n</li>\n<li>\n<p>Download the binary directly:</p>\n<pre><code><span class=\"code-snippet\">wget -O ~/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.27.0/bazelisk-linux-amd64\n</span></code></pre>\n</li>\n</ul>\n<p>See the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/bazelbuild/bazelisk/blob/master/README.md\">Bazelisk README</a> for more install instructions</p>\n<p>However you install it, add it's location to <code>PATH</code>.</p>\n<p>To verify the install, run <code>bazel info</code> in the repo's root directory:</p>\n<pre><code><span class=\"code-snippet\">bazel info\n</span></code></pre>\n<p>It should print information about the repo without errors.</p>\n<h2>VSCode <code>clangd</code> Setup</h2>\n<p>For C++ code navigation, it is recommended to use VSCode with <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd\"><code>clangd</code> extension</a>. Relying on a <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://clang.llvm.org/docs/JSONCompilationDatabase.html\">compilation database</a> generated from Bazel action graph, <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://clangd.llvm.org/\">clangd</a> is able to enrich the editor with various smart features, including code completions, go-to definitions, <em>etc.</em></p>\n<ol>\n<li>\n<p>Install VSCode extensions via UI or the following command:</p>\n<pre><code class=\"language-shell\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">code</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>install-extension</span> llvm-vs-code-extensions.vscode-clangd</span>\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Uninstall Microsoft C++ extensions to avoid interference.</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">code</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>uninstall-extension</span> ms-vscode.cpptools</span>\n</span></span></code></pre>\n</li>\n<li>\n<p>Generate the initial <code>compile_commands.json</code>:</p>\n<pre><code class=\"language-shell\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">tools/setup_clangd.py</span></span>\n</span></span></code></pre>\n</li>\n</ol>\n<p>It may take a while (&gt; 30 minutes) for the first run to make a full build, but reruns will be incremental and cheap. If you have run <code>bazel build</code> recently, generated files already exist so you can pass <code>--no-build</code> to skip waiting for heavy builds (note that on a fresh workspace, skipping the build may prevent <code>clangd</code> from resolving generated files). See more options in the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/google-pytorch/torch_tpu/blob/main/tools/setup_clangd.py\">script</a> file-level comments.</p>\n<p>Alternatively, you can invoke the script via <code>nox</code> (arguments after <code>--</code> are forwarded):</p>\n<pre><code class=\"language-shell\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">nox</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>s</span> refresh_compile_commands<span class=\"syntax-keyword syntax-operator syntax-end-of-options syntax-shell\"> --</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> --no-build</span>\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">nox</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>s</span> refresh_compile_commands<span class=\"syntax-keyword syntax-operator syntax-end-of-options syntax-shell\"> --</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> //src/torch_tpu/ops/...</span>\n</span></span></code></pre>\n<h2>Contributing</h2>\n<p>We welcome contributions to the PyTorch on TPU project! Please see our <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/google-pytorch/torch_tpu/blob/main/CONTRIBUTING.md\">CONTRIBUTING.md</a> for guidelines on how to contribute, including signing our Contributor License Agreement (CLA) and code review processes.</p>\n<h2>Star History</h2>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://www.star-history.com/?repos=google-pytorch%2Ftorch_tpu&amp;type=date&amp;legend=top-left\"><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://camo.githubusercontent.com/5dd8f8b127ebb9d4b8e81870ade5b9dea014587bc270e5ff7c4984ca8bf88d43/68747470733a2f2f6170692e737461722d686973746f72792e636f6d2f63686172743f7265706f733d676f6f676c652d7079746f7263682f746f7263685f74707526747970653d64617465266c6567656e643d746f702d6c656674\" alt=\"Star History Chart\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></a></p>\n<h2>License</h2>\n<p>This project is licensed under the Apache 2.0 License. See the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/google-pytorch/torch_tpu/blob/main/LICENSE\">LICENSE</a> file for details.</p>\n",
      "date_modified": "2026-10-20T16:40:24+00:00",
      "date_published": "2026-10-20T16:40:24+00:00",
      "external_url": "https://github.com/google-pytorch/torch_tpu",
      "id": "urn:aggr:item:ec897b5058ffe73a88e095b3f319f1a09c436003",
      "image": "https://opengraph.githubassets.com/cd86c84e93f7b104a4d7723deb52a1b58d9418986b422db17cdc92ee64b72b49/google-pytorch/torch_tpu",
      "summary": "Description This project provides a PyTorch backend for Google's Tensor Processing Units (TPUs), enabling users to run PyTorch models and operations on TPU devices. It includes custom ATen kernels for various PyTorch operations, a…",
      "tags": [
        "news"
      ],
      "title": "Google open-sources TorchTPU, a native PyTorch back end for TPUs",
      "url": "https://aggr.aymericbeaumet.com/items/hnrss-org/2026-10-20-google-open-sources-torchtpu-a-native-pytorch-back-end-for/"
    }
  ],
  "language": "en",
  "title": "github.com/google-pytorch",
  "version": "https://jsonfeed.org/version/1.1"
}