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