# Contributor handoff — pytorch/pytorch

> Canonical page: https://codevetter.com/unpack/pytorch/agent-handoff

# Contributor handoff — pytorch/pytorch

Scanned commit 5711f1a4586cb0a3dbb3d67538df814db48f94f4 (2026-09-22). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

AGENTS.md is mandatory reading and unusually specific: build ONLY via `pip install -e . -v --no-build-isolation`, test via run_tests/TestCase + instantiate_device_type_tests, lint via spin lint/fixlint plus `lintrunner -a` before commits, and never `noqa: S101` an assert (rewrite as raise AssertionError). Edit .pyi.in templates not generated .pyi; never touch .ci/docker (content-hash rebuilds); respect the ghstack workflow (detached HEAD is intentional, never push, preserve trailers). Style: minimal comments, ASCII-only in new comments, explicit state, match existing patterns. Use agent_space/ for scratch. AI_POLICY.md requires marking all AI-generated content in GitHub interactions.
- Build rule: 'All build (both codegen, C++ and python) is done via pip install -e . -v --no-build-isolation. You should NEVER run any other command to build PyTorch.' — [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md)
- Test rule: tests subclass torch.testing._internal.common_utils TestCase and call run_tests(); assertEqual for tensor equality, @parametrize for input sets, instantiate_device_type_tests for device-generic numerics tests. — [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md) [torch/testing/_internal/common_utils.py#L3720](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/torch/testing/_internal/common_utils.py#L3720)
- Lint rule: only spin-provided commands (spin lint / spin fixlint); run `lintrunner -a` before committing and fix what it reports. — [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md) [.lintrunner.toml](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/.lintrunner.toml)
- S101 rule: never silence 'use of assert' with noqa — rewrite `assert cond, msg` as `if not cond: raise AssertionError(msg)` because python -O strips asserts; do not invert float comparisons (NaN). — [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md)
- Generated-file rule: many .pyi files are generated from .pyi.in templates — always edit the .pyi.in, never the generated .pyi. — [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md) [pyproject.toml#L239](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/pyproject.toml#L239)
- .ci/docker/ is content-hashed for image rebuilds — any change (even README) triggers a full Docker rebuild; don't touch it unless intending to rebuild, and avoid it entirely when Docker builds are broken upstream. — [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md)
- Git/ghstack rules: detached HEAD means ghstack flow (commit directly, don't branch); never amend or push ghstack commits unless asked; preserve ghstack-source-id and Pull-Request trailers; submit with ghstack (--no-stack for single commits); never push to gh/USER/N branches. — [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md)
- Commit message rules: include a Test Plan section with literal fenced commands, explain root cause for bug fixes, disclose AI authorship, and don't bullet-list individual changes. — [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md)
- Use agent_space/ (git-ignored, repo root) for scratch scripts and throwaway experiments; never commit from it. Check for a .venv in repo root/parent before assuming missing tools. — [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md)
- Dynamo debugging kit: TORCH_LOGS=guards,graph_breaks,graph_code,+dynamo,bytecode; TORCH_TRACE=dir + tlparse for production artifacts via trace_structured; torch._dynamo.config.patch for config toggles; bytecode_debugger for generated-code segfaults. — [torch/_dynamo/CLAUDE.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/torch/_dynamo/CLAUDE.md) [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md)
- Style rules: minimal self-documenting code, no trivial one-use helpers, explicit class state (no dynamic setattr/getattr), match existing patterns, ASCII-only in new comments, and prefer keeping long lines readable via locals instead of ruff-driven splits (noqa: B950 on the closing quote for golden strings). — [AGENTS.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/AGENTS.md)
- Build configuration is env-var driven (MAX_JOBS, DEBUG, REL_WITH_DEB_INFO, USE_*/BUILD_*); cmake/EnvVarForwarding.cmake is the single source of truth for env vars — add and document new knobs there. — [pyproject.toml#L32-83](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/pyproject.toml#L32-L83) [CMakeLists.txt#L1-46](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/CMakeLists.txt#L1-L46)
- For op work the first reads are aten/src/ATen/native/README.md (schema language + dispatch table conventions), native_functions.yaml, and torchgen/gen.py; for compile work read torch/_dynamo/CLAUDE.md then eval_frame.py/convert_frame.py/symbolic_convert.py. — [aten/src/ATen/native/README.md#L1-27](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/aten/src/ATen/native/README.md#L1-L27) [torch/_dynamo/CLAUDE.md](https://github.com/pytorch/pytorch/blob/5711f1a4586cb0a3dbb3d67538df814db48f94f4/torch/_dynamo/CLAUDE.md)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
