Skip to content

[DO NOT MERGE] [native_aot] AOT_README: design + how-to for native-AOT ops - #191669

Draft
slayton58 wants to merge 54 commits into
gh/slayton58/141/basefrom
gh/slayton58/141/head
Draft

slayton58 wants to merge 54 commits into
gh/slayton58/141/basefrom
gh/slayton58/141/head

Conversation

@slayton58

@slayton58 slayton58 commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/191669

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 Unclassified Failure

As of commit 530d47c with merge base 81deebd (image):

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 10, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```


ghstack-source-id: b29853b
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 10, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: 1137f4d
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 11, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: e8330a8
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 12, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: fa5b40c
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 12, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: 02b7847
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 12, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: e554ccc
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 12, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: ed4c5e6
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 12, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: 0e4a31c
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 13, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: e284673
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 13, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: 23b01a4
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Aug 13, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across five commit messages.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and the
patterns the shipped ops demonstrate (a prelude that classifies with
TensorIterator, one kernel body serving two aten ops, a Triton declaration,
table-driven families, and a pitfall checklist).

Marked DO NOT MERGE for two reasons. Section 6 draws its examples from the
tail commits of this stack, so it forward-references code that is not in the
prefix PRs under review; and the contract it documents is still being changed
by review feedback. Land it once the ops it teaches from are landed, or split
the design half forward into the topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command, env var and
performance number was verified, and the file is ASCII-only per repo rules.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (22 file-attributed blocks, 0 drift)
# referenced repo paths all exist (23 paths)
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: c0348bb
Pull-Request: #191669
@slayton58

Copy link
Copy Markdown
Contributor Author

@pytorchbot import

@pytorch-bot

pytorch-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

❌ 🤖 pytorchbot command failed:

@pytorchbot: error: argument command: invalid choice: 'import' (choose from 'merge', 'revert', 'rebase', 'label', 'drci', 'lint', 'fix-lint', 'apply-lint', 'cherry-pick')

usage: @pytorchbot [-h]
                   
                   {merge,revert,rebase,label,drci,lint,fix-lint,apply-lint,cherry-pick}
                   ...

Try @pytorchbot --help for more info.

[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Sep 4, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: ffad5e1
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Sep 4, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: 905ed75
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Sep 4, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: 70817ad
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Sep 4, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: 7a572f0
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Sep 8, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: d6b2573
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Sep 8, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: 85df4e2
Pull-Request: #191669
slayton58 added a commit that referenced this pull request Sep 8, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: 85df4e2
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Sep 8, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: aef8a34
Pull-Request: #191669
slayton58 added a commit that referenced this pull request Sep 8, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: aef8a34
Pull-Request: #191669
slayton58 added a commit that referenced this pull request Sep 8, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: aef8a34
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Sep 8, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: 1fb114f
Pull-Request: #191669
[ghstack-poisoned]
slayton58 added a commit that referenced this pull request Sep 8, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: ac2e556
Pull-Request: #191669
slayton58 added a commit that referenced this pull request Sep 8, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: ac2e556
Pull-Request: #191669
slayton58 added a commit that referenced this pull request Sep 8, 2026
…T ops

Documentation only, no code. Kept out of the implementation commits so it can
be rewritten freely while the design is still moving, and so a reviewer can
read the design without it being spread across the implementation commits.

Two audiences in one file. The first half is the design document: what
native-AOT is, why the kernels are embedded in the aten implementation rather
than reached through the Python JIT router, the DispatchStub that torchgen
emits between meta() and impl(), the runtime dispatch path, the two-stage
build, and the measured effect (quoted from the design doc's tables, including
the shapes where the AOT route loses to aten, and why that is a property of a
declaration rather than of the layer). The second half is the how-to: every
export in the declaration contract with its signature and cardinality, an
annotated declaration, a step-by-step walkthrough for a new op, and a pitfall
checklist of the traps recorded in the code and the design doc.

Marked DO NOT MERGE for two reasons. It teaches from topk's declaration and
the runtime, which land in the tail commits of this stack, so it
forward-references code that is not in the prefix PRs under review; and the
contract it documents is still being changed by review feedback. Land it once
the ops it teaches from are landed, or split the design half forward into the
topk commit if that is more useful for review.

Authored with an AI assistant (Claude Code). The content was mined from the
original design doc and from the implementation, then fact-checked against the
tree: every quoted code block, file path, API name, command and env var was
verified, and the file is ASCII-only per repo rules. The performance tables are
quoted from the design doc and say so; they were measured on the prototype tree,
which declared 41 ops where this stack declares one.

Test Plan:

Documentation only. Verified mechanically rather than by test:

```
# quoted code blocks match the tree (12 file-attributed blocks, 0 drift)
# referenced repo paths all exist (34 rooted, plus ops/<op>/<file>.py)
# every op named as an AOT DECLARATION has an aot.py (topk is the only one)
# test modules named in command blocks exist
# APIs resolve: torch._native._native_aot_embedded, aot_enabled,
#   aot_manifest.covers; env vars NATIVE_AOT, TORCH_DISABLE_NATIVE_AOT,
#   TORCH_DISABLE_NATIVE_JIT; tests test/python_native/test_native_aot.py,
#   test/python_native/test_aot_manifest.py
lintrunner --take NEWLINE,SPACES,TABS,COPYRIGHT torch/_native/AOT_README.md
```

ghstack-source-id: ac2e556
Pull-Request: #191669
[ghstack-poisoned]
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant