Commit Graph

60 Commits

Author SHA1 Message Date
Klaus Zimmermann
31345fb4f7 Make functorch notebook symlinks PEP 517 valid (#157813)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157813
Approved by: https://github.com/zou3519, https://github.com/atalman
2025-09-12 03:52:08 +00:00
PyTorch MergeBot
053251b98d Revert "Make functorch notebook symlinks PEP 517 valid (#157813)"
This reverts commit b494547f0b.

Reverted https://github.com/pytorch/pytorch/pull/157813 on behalf of https://github.com/huydhn due to Sorry for reverting your change, but this surfaces a weird discrepancy between GitHub and Mecurial used internally ([comment](https://github.com/pytorch/pytorch/pull/157813#issuecomment-3276442242))
2025-09-10 20:45:48 +00:00
Klaus Zimmermann
b494547f0b Make functorch notebook symlinks PEP 517 valid (#157813)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157813
Approved by: https://github.com/zou3519, https://github.com/atalman
2025-09-10 10:13:24 +00:00
PyTorch MergeBot
023887fc5a Revert "Switch to standard pep517 sdist generation (#152098)"
This reverts commit f16053f0c9.

Reverted https://github.com/pytorch/pytorch/pull/152098 on behalf of https://github.com/malfet due to IMO this PR needs to be split into few helper ones, with better test plan ([comment](https://github.com/pytorch/pytorch/pull/152098#issuecomment-3024223880))
2025-07-01 14:14:52 +00:00
Klaus Zimmermann
f16053f0c9 Switch to standard pep517 sdist generation (#152098)
Generate source tarball with PEP 517 conform build tools instead of the custom routine in place right now.

Closes #150461.

The current procedure for generating the source tarball consists in creation of a source tree by manual copying and pruning of source files.

This PR replaces that with a call to the standard [build tool](https://build.pypa.io/en/stable/), which works with the build backend to produce an sdist. For that to work correctly, the build backend also needs to be configured. In the case of Pytorch, the backend currently is (the legacy version of) the setuptools backend, the source dist part of which is mostly configured via the `MANIFEST.in` file.

The resulting source distribution can be used to install directly from source with `pip install ./torch-{version}.tar.gz` or to build wheels directly from source with `pip wheel ./torch-{version}.tar.gz`; both should be considered experimental for now.

## Issues

### sdist name
According to PEP 517, the name of the source distribution file must coincide with the project name, or [more precisely](https://peps.python.org/pep-0517/#source-distributions), the source distribution of a project that generates `{NAME}-{...}.whl` wheels are required to be named `{NAME}-{...}.tar.gz`. Currently, the source tarball is called `pytorch-{...}.tar.gz`, but the generated wheels and python package are called `torch-{...}`.

### Symbolic Links
The source tree at the moment contains a small number of symbolic links. This [has been seen as problematic](https://github.com/pypa/pip/issues/5919) largely because of lack of support on Windows, but also because of [a problem in setuptools](https://github.com/pypa/setuptools/issues/4937). Particularly unfortunate is a circular symlink in the third party `ittapi` module, which can not be resolved by replacing it with a copy.

PEP 721 (now integrated in the [Source Distribution Format Specification](https://packaging.python.org/en/latest/specifications/source-distribution-format/#source-distribution-archive-features)) allows for symbolic links, but only if they don't point outside the destination directory and if they don't contain `../` in their target.

The list of symbolic links currently is as follows:

<details>

|source|target|problem|solution|
|-|-|-|-|
| `.dockerignore` | `.gitignore` |  ok (individual file) ||
| `docs/requirements.txt` | `../.ci/docker/requirements-docs.txt` |`..` in target|swap source and target[^1]|
| `functorch/docs/source/notebooks` | `../../notebooks/` |`..` in target|swap source and target[^1]|
| `.github/ci_commit_pins/triton.txt` | `../../.ci/docker/ci_commit_pins/triton.txt` |  ok (omitted from sdist)||
| `third_party/flatbuffers/docs/source/CONTRIBUTING.md` | `../../CONTRIBUTING.md` |`..` in target|omit from sdist[^2]|
| `third_party/flatbuffers/java/src/test/java/DictionaryLookup` | `../../../../tests/DictionaryLookup` |`..` in target|omit from sdist[^3]|
| `third_party/flatbuffers/java/src/test/java/MyGame` | `../../../../tests/MyGame` |`..` in target|omit from sdist[^3]|
| `third_party/flatbuffers/java/src/test/java/NamespaceA` | `../../../../tests/namespace_test/NamespaceA` |`..` in target|omit from sdist[^3]|
| `third_party/flatbuffers/java/src/test/java/NamespaceC` | `../../../../tests/namespace_test/NamespaceC` |`..` in target|omit from sdist[^3]|
| `third_party/flatbuffers/java/src/test/java/optional_scalars` | `../../../../tests/optional_scalars` |`..` in target|omit from sdist[^3]|
| `third_party/flatbuffers/java/src/test/java/union_vector` | `../../../../tests/union_vector` |`..` in target|omit from sdist[^3]|
| `third_party/flatbuffers/kotlin/benchmark/src/jvmMain/java` | `../../../../java/src/main/java` |`..` in target|omit from sdist[^3]|
| `third_party/ittapi/rust/ittapi-sys/c-library` | `../../` |`..` in target|omit from sdist[^4]|
| `third_party/ittapi/rust/ittapi-sys/LICENSES` | `../../LICENSES` |`..` in target|omit from sdist[^4]|
| `third_party/opentelemetry-cpp/buildscripts/pre-merge-commit` | `./pre-commit` | ok (individual file)||
| `third_party/opentelemetry-cpp/third_party/prometheus-cpp/cmake/project-import-cmake/sample_client.cc` | `../../push/tests/integration/sample_client.cc` |`..` in target|omit from sdist[^5]|
| `third_party/opentelemetry-cpp/third_party/prometheus-cpp/cmake/project-import-cmake/sample_server.cc` | `../../pull/tests/integration/sample_server.cc` |`..` in target|omit from sdist[^5]|
| `third_party/opentelemetry-cpp/third_party/prometheus-cpp/cmake/project-import-pkgconfig/sample_client.cc` | `../../push/tests/integration/sample_client.cc` |`..` in target|omit from sdist[^5]|
| `third_party/opentelemetry-cpp/third_party/prometheus-cpp/cmake/project-import-pkgconfig/sample_server.cc` | `../../pull/tests/integration/sample_server.cc` |`..` in target|omit from sdist[^5]|
| `third_party/XNNPACK/tools/xngen` | `xngen.py` |  ok (individual file)||

</details>

The introduction of symbolic links inside the `.ci/docker` folder creates a new problem, however, because Docker's `COPY` command does not allow symlinks in this way. We work around that by using `tar ch` to dereference the symlinks before handing them over to `docker build`.

[^1]: These resources can be naturally considered to be part of the docs, so moving the actual files into the place of the current symlinks and replacing them with (unproblematic) symlinks can be said to improve semantics as well.

[^2]: The flatbuffers docs already actually use the original file, not the symlink and in the most recent releases, starting from flatbuffers-25.1.21 the symlink is replaced by the actual file thanks to a documentation overhaul.

[^3]: These resources are flatbuffers tests for java and kotlin and can be omitted from our sdist.

[^4]: We don't need to ship the rust bindings for ittapi.

[^5]: These are demonstration examples for how to link to prometheus-cpp using cmake and can be omitted.

### Nccl
Nccl used to be included as a submodule. However, with #146073 (first released in v2.7.0-rc1), the submodule was removed and replaced with a build time checkout procedure in `tools/build_pytorch_libs.py`, which checks out the required version of nccl from the upstream repository based on a commit pin recorded in `.ci/docker/ci_commit_pins/nccl-cu{11,12}.txt`.
This means that a crucial third party dependency is missing from the source distribution and as the `.ci` folder is omitted from the source distribution, it is not possible to use the build time download.
However, it *is* possible to use a system provided Nccl using the `USE_SYSTEM_NCCL` environment variable, which now also is the default for the official Pytorch wheels.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/152098
Approved by: https://github.com/atalman
2025-06-30 19:07:34 +00:00
Svetlana Karslioglu
cd7bc60e11 Migrate to new theme (#149331)
- Migrate pytorch docs, cpp docs and functorch docs to the pytorch_sphinx_theme2
- Migrate index.rst to markdown and restructure to use high-level horizontal bar sections Python API, Developer Notes
- Added python-api.md which becomes the main container for the API docs. This file will be used to add all api references in the toctree. It would be great to have lint for this file: https://github.com/pytorch/pytorch/issues/150718
- Enabled mermaid sphinx extension and opengraph sphinx extension

Pull Request resolved: https://github.com/pytorch/pytorch/pull/149331
Approved by: https://github.com/malfet, https://github.com/atalman, https://github.com/albanD
2025-04-16 21:35:19 +00:00
Xuehai Pan
740fb22966 [BE][Easy][4/19] enforce style for empty lines in import segments in functorch/ (#129755)
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501. Most changes are auto-generated by linter.

You can review these PRs via:

```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129755
Approved by: https://github.com/zou3519
ghstack dependencies: #129752
2024-07-18 05:08:03 +00:00
Nikita Shulga
f9a611a3ce Update Jinja to 3.1.3 (#124976)
To fix CVE-2024-22195

Also, delete unused docs/cpp/requirements.txt and functorch/docs/requirements.txt

Pull Request resolved: https://github.com/pytorch/pytorch/pull/124976
Approved by: https://github.com/kit1980
2024-04-26 02:57:55 +00:00
lezcano
8a5a377190 Move doc links to point to main (#121823)
The previous links were pointing to an outdated branch

Command: `find . -type f -exec sed -i "s:docs/main:docs/master:g" {} + `

Pull Request resolved: https://github.com/pytorch/pytorch/pull/121823
Approved by: https://github.com/albanD, https://github.com/malfet
2024-03-15 19:49:37 +00:00
Aaron Gokaslan
33938cfddd [BE][Ez] Update ruff to 0.2.2 (#120517)
Updates ruff to 0.2.2. This updates the config and handles some of the new rules that have come out of preview.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/120517
Approved by: https://github.com/albanD
2024-02-24 07:13:53 +00:00
Edward Z. Yang
e6ec0efaf8 Apply UFMT to all non test/torch files (#106205)
Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/106205
Approved by: https://github.com/albanD
2023-07-29 02:56:24 +00:00
Huy Do
bb6b24c622 [BE] Dockerize PyTorch docs jobs (#100601)
Saw some connection error to pip in docs jobs today, so let's dockerize it:

* https://github.com/pytorch/pytorch/actions/runs/4877612277/jobs/8702572072
* https://github.com/pytorch/pytorch/actions/runs/4877612277/jobs/8702572072

Some additional fixes:
* Moving the docs script from under `.circleci` to under `.ci` as they should be
* Linter (as scripts under .ci are subjected to shellcheck)
* Fix some minor Sphinx warnings in functorch docs

### Testing
Docs previews look fine:

* https://docs-preview.pytorch.org/100601/index.html
* https://docs-preview.pytorch.org/100601/cppdocs/index.html
* https://docs-preview.pytorch.org/100601/functorchdocs/index.html

Pull Request resolved: https://github.com/pytorch/pytorch/pull/100601
Approved by: https://github.com/clee2000
2023-05-05 06:24:46 +00:00
PyTorch MergeBot
6d2f8114be Revert "[BE] Dockerize PyTorch docs jobs (#100601)"
This reverts commit 2703684acf.

Reverted https://github.com/pytorch/pytorch/pull/100601 on behalf of https://github.com/huydhn due to Curiously, this breaks inductor jobs ([comment](https://github.com/pytorch/pytorch/pull/100601#issuecomment-1535515587))
2023-05-04 23:13:15 +00:00
Huy Do
2703684acf [BE] Dockerize PyTorch docs jobs (#100601)
Saw some connection error to pip in docs jobs today, so let's dockerize it:

* https://github.com/pytorch/pytorch/actions/runs/4877612277/jobs/8702572072
* https://github.com/pytorch/pytorch/actions/runs/4877612277/jobs/8702572072

Some additional fixes:
* Moving the docs script from under `.circleci` to under `.ci` as they should be
* Linter (as scripts under .ci is subjected to shellcheck)
* Fix some minor Sphinx warnings in functorch docs

### Testing
Docs previews look fine:

* https://docs-preview.pytorch.org/100601/index.html
* https://docs-preview.pytorch.org/100601/cppdocs/index.html
* https://docs-preview.pytorch.org/100601/functorchdocs/index.html

Pull Request resolved: https://github.com/pytorch/pytorch/pull/100601
Approved by: https://github.com/clee2000
2023-05-04 20:33:51 +00:00
Svetlana Karslioglu
d425da8bf3 Replace master with main in links and docs/conf.py (#100176)
Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/100176
Approved by: https://github.com/albanD, https://github.com/malfet
2023-05-02 18:20:32 +00:00
Huy Do
56e235ad8c Pin functorch docs requirements (#100257)
The job https://github.com/pytorch/pytorch/actions/runs/4830815291/jobs/8607848573 starts to fail with the new IPython https://pypi.org/project/ipython/#history

Pull Request resolved: https://github.com/pytorch/pytorch/pull/100257
Approved by: https://github.com/clee2000
2023-04-28 17:58:58 +00:00
Richard Zou
a8a44a1aa2 Add deprecation messages for functorch.* function transforms (#92279)
This PR:
- adds deprecation warnings when calling the functorch APIs
- adds documentation saying that those APIs are deprecated

It does this by creating thin wrappers around the original APIs that (1)
raise deprecation warnings and (2) have an additional line in their
documentation that they are deprecated.

NB:
- Python surpresses DeprecationWarning, so we use UserWarning instead.

Test Plan:
- New tests
- the functorch.* APIs are still tested for correctness because that's
what test/functorch/* use (as opposed to directly calling the
torch.func.* APIs)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/92279
Approved by: https://github.com/albanD, https://github.com/soulitzer
2023-01-18 14:26:25 +00:00
Kazuaki Ishizaki
a3d495bd4e Fix typos under functorch directory (#87663)
This PR fixes typos in `.md` and `.rst` files under functorch directory

Pull Request resolved: https://github.com/pytorch/pytorch/pull/87663
Approved by: https://github.com/kit1980
2022-10-25 21:50:02 +00:00
Richard Zou
3d9fd060f4 [functorch] Add more details to the functorch install page (#86823)
Added some details about:
- `pip uninstall functorch` being helpful if there are problems
- `pip install functorch` still working for BC reasons.

Test Plan:
- wait for docs preview
Pull Request resolved: https://github.com/pytorch/pytorch/pull/86823
Approved by: https://github.com/samdow
2022-10-13 14:53:04 +00:00
Richard Zou
937d677d9f Add version selector back to functorch docs (#86602)
I accidentally deleted it in
https://github.com/pytorch/pytorch/pull/85856/ . This brings the version
selector back.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/86602
Approved by: https://github.com/samdow
2022-10-11 14:49:42 +00:00
Richard Zou
50000f3cdc Align functorch docs with PyTorch's (#85856)
This PR:
- changes the header/footer to be the same as PyTorch docs
- removes the functorch logo (we don't need it anymore, functorch has
been adopted into PyTorch)
- adjusts the functorch docs to make it clear that the page is functorch
documentation.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85856
Approved by: https://github.com/svekars, https://github.com/samdow
2022-09-29 20:00:34 +00:00
Richard Zou
48b3582e28 [functorch] Update install instructions in docs (#85854)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85854
Approved by: https://github.com/samdow
2022-09-29 20:00:31 +00:00
Brian Hirsh
913f5784d7 move functionalize out of experimental namespace (#85742)
Did a very quick sanity check - it looks like functorch docs don't get the nice preview link that pytofch-bot gives for normal pytorch docs, so I built locally and scanned `html/generated/functorch.functionalize.html`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/85742
Approved by: https://github.com/zou3519
2022-09-28 20:56:14 +00:00
Matthew LeMay
62786a09d3 Fix indentation in functorch limitations docs (#85346)
Fixes a minor indentation error in the `functorch` UX limitations documentation.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85346
Approved by: https://github.com/kit1980
2022-09-20 19:11:30 +00:00
Richard Zou
f42ed3f98f Turn on linting for functorch (#81987)
Test Plan:
- wait for CI
Pull Request resolved: https://github.com/pytorch/pytorch/pull/81987
Approved by: https://github.com/samdow
2022-07-25 14:36:22 +00:00
Richard Zou
2e5c837abf [functorch] We support windows 2022-07-21 13:41:36 -07:00
Richard Zou
3182642b2c [functorch] Beef up transform limitations doc (pytorch/functorch#879)
I want to be able to point someone at this page whenever we get asked
about the limitations of vmap. Please let me know if there are things
we're still missing from here
2022-07-21 13:41:36 -07:00
Brian Hirsh
512a22c55f [functorch] docs for functionalize (pytorch/functorch#874)
ghstack-source-id: c27a88652778950edb2f3bfcae482a0b8e6243ac
Pull Request resolved: https://github.com/pytorch/functorch/pull/876
2022-07-21 13:41:35 -07:00
Richard Zou
647882bf19 [functorch] In ux_limitations: use "elements" instead of "memory"
To avoid any confusion. Previously the messaging about in-place operations
was ambiguous and could have been taken to mean "you need more memory",
which is not the case.

Fixes https://github.com/pytorch/functorch/issues/604
2022-07-21 13:41:29 -07:00
Richard Zou
b2f03d7f7d [functorch] Better intro to functorch (pytorch/functorch#688)
For our docs landing page.

Fixes https://github.com/pytorch/functorch/issues/605
2022-07-21 13:41:29 -07:00
Richard Zou
bdc306569b [functorch] Doc fix
Fixes https://github.com/pytorch/functorch/issues/604
2022-07-21 13:41:29 -07:00
Richard Zou
236e1dff81 [functorch] newline at eof 2022-07-21 13:41:27 -07:00
vfdev
5fd680867d [functorch] Fixing docs building issues with jinja and sphinx (pytorch/functorch#625)
* Fixing jinja2 issue in sphinx

* Put upper limit into requirements
2022-07-21 13:41:27 -07:00
Richard Zou
7095647db6 [functorch] Fix some lint issues (pytorch/functorch#606) 2022-07-21 13:41:26 -07:00
Horace He
f20c1ed115 [functorch] fixed docs issue 2022-07-21 13:41:26 -07:00
Samantha Andow
3245652427 [functorch] Add website note on randomness (pytorch/functorch#587)
* add note on randomness

* add note matching docstring on operators

* fixes

* typo
2022-07-21 13:41:26 -07:00
Richard Zou
1682996616 [functorch] Update functorch install instructions 2022-07-21 13:41:26 -07:00
Richard Zou
33aead5f7b [functorch] Update readme (pytorch/functorch#589)
and minor main-branch-only website changes.
2022-07-21 13:41:26 -07:00
Animesh Jain
911458776a [functorch] Sphinx and docstrings for AOT Autograd (pytorch/functorch#580)
* Sphinx and docstrings for AOT Autograd

* Comments
2022-07-21 13:41:26 -07:00
Samantha Andow
34643a6c87 [functorch] Update batch norm error message to be more informative (pytorch/functorch#567)
* update batch norm error message

* add docs for batch norm fixes
2022-07-21 13:41:25 -07:00
vfdev
0828438d71 [functorch] Updated logo alignment (pytorch/functorch#573) 2022-07-21 13:41:25 -07:00
Richard Zou
664cd284c5 [functorch] Docs website modification (pytorch/functorch#563)
I modified the docs website:
- It has a new install page which we'll fill out l ater
- It has a new "whirlwind tour" section with is just our README
copy-pasted
- It has a "UX Limitations" section describing arbitrary python
mutation, in-place operations, and control flow.

Please let me know if you think anything else should be here.

Future work:
- I'm going to put up a table of what operators we have support for and
which ones we don't, autogenerated via OpInfo
2022-07-21 13:41:25 -07:00
Richard Zou
3110183992 [functorch] Neural Tangent Kernels tutorial (pytorch/functorch#540) 2022-07-21 13:41:25 -07:00
vfdev
3adc8167c9 [functorch] Updated css to reduce badge size and code-block bottom padding (pytorch/functorch#526)
* Updated css to reduce badge size and code-block bottom padding

* [skip ci] Added new line
2022-07-21 13:41:23 -07:00
Richard Zou
67948ebd9a [functorch] Fix docs build 2022-07-21 13:41:23 -07:00
Richard Zou
565365baaf [functorch] GHA docs build; nbsphinx -> myst-nb (pytorch/functorch#517) 2022-07-21 13:41:22 -07:00
vfdev
1be9042dc3 [functorch] Removed pytorch footer in docs (pytorch/functorch#499)
* Fixes pytorch/functorch#498

Removed footer

* Removed completely the footer
2022-07-21 13:41:22 -07:00
Richard Zou
cc68964c06 [functorch] Improve version rendering on docs website 2022-07-21 13:41:22 -07:00
Richard Zou
e4d20b58c4 [functorch] Change docs name 2022-07-21 13:41:22 -07:00
vfdev
dda66b2cae [functorch] Switched docs theme to pytorch-theme (pytorch/functorch#453)
* Switched to pytorch-theme

* Added missing function transforms

* Updated layout

* Added simple text logo and added vjp docs
2022-07-21 13:41:21 -07:00