PyTorch's playbook for AI coding, as of May 2026

Edward Yang (@ezyang) · May 30, 2026 · 9 min read
ai-agentscode-reviewossllm

One of the important topics being discussed among the PyTorch team is how the PyTorch codebase should engage with AI coding agents. Today, many PRs to PyTorch are AI-authored, and there have been obvious growing pains as we’ve figured things out. Based on discussions at the most recent PyTorch compiler offsite (May 2026), I’ve assembled this playbook for AI coding in PyTorch. It is half descriptive, half prescriptive: it is trying to codify practices that are being used among some members of the team, and bring everyone else along. Hopefully, this post is just the beginning of our ongoing conversation about how to engage with AI coding agents.

Norms for AI coding

We can think of AI generated code as living in a spectrum, where on one hand we have code that is almost exactly the same as human code, except that it was typed by an AI, and on the other hand completely vibe-coded software which has never been read by a human.

PyTorch is production software, used and relied upon by many people. We have a duty to our users to ensure that the code we ship is correct, understandable and maintainable. We think that SOTA coding agents can help us build better software than we could have built purely by hand today, but they present us with novel situations that require adapting our old rules. We think different norms are required depending on where code lives on the spectrum.

As a substitution for human written code

On the most conservative end, we are adding AI coding but trying to keep as many other aspects of the process fixed. The human should read every line of code. You are responsible for every line of code.

Not everything stays the same though. We propose these new norms:

Mass AI PRs

Mass AI PRs are when we use agents to generate many PRs in parallel; e.g., using agents to burn down issues on an issue tracker. Many bugs are not individually important enough for a human to dedicate a few days fixing, but in aggregate, fixing bugs is important, and AI coding agents are a big opportunity to kill low hanging fruit (in the same way AI agents are really good at discovering security vulnerabilities.)

The general ask here is that we should have high-level agreement that these fixes, in aggregate have an ROI that justifies the human time spent on it. While the operator of the agent swarm is responsible for doing initial reviews, guiding it and improving it based on feedback, a mass of AI PRs will increase reviewer burden. The point is to have agreed that this review burden is worth it!

Well-encapsulated unreviewed code

As of today, we do not accept unreviewed AI generated code (aka slop) to the main pytorch/pytorch repo. However, we think the capability of SOTA models today enables the creation of systems that otherwise could not have existed (e.g., via hill climbing.) We have several live experiments in unreviewed AI generated code; for now, these all live in out-of-tree repositories. This makes clear the experimental nature of the package; it also makes mistakes in the code lower stakes (as we can more rapidly ship releases).

Even unreviewed code still needs to follow some standards:

Many of us at PyTorch have vibe-coded useful personal tools without these standards. We don’t mean to discourage this! However, our current opinion is that this level of quality is not appropriate for PyTorch features proper (even in experimental repositories).

Tooling

We think the following tools will be helpful for a world of AI coding agents, and we plan to implement them in the near future: