Skip to content

Add placeholder for the User Guide #159379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

svekars
Copy link
Contributor

@svekars svekars commented Jul 29, 2025

  • Add pytorch_overview.md
  • Add pytorch_main_components.md
  • Reorganize top nav to have Get Started, User Guide, Reference API, Community, Tutorials
  • Move notes under user guide

cc @sekyondaMeta @AlannaBurke

- Add pytorch_overview.md
- Add pytorch_main_components.md
- Reorganize top nav to have Get Started, User Guide, Reference API, COmmunity, Tutorials
- Move notes under user guide
@svekars svekars requested review from zou3519 and albanD July 29, 2025 16:51
@svekars svekars added the topic: not user facing topic category label Jul 29, 2025
Copy link

pytorch-bot bot commented Jul 29, 2025

🔗 Helpful Links

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

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

✅ You can merge normally! (4 Unrelated Failures)

As of commit bfbe0fd with merge base 59e261b (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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

@svekars svekars added module: docs Related to our documentation, both in docs/ and docblocks topic: docs topic category labels Jul 29, 2025

# What is PyTorch?

PyTorch, or torch, is an open-source machine learning library written in Python that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

written in Python seems misleading...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, probably just drop this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@svekars svekars force-pushed the add-user-guide-structure branch from ee86c94 to 8c8ae0e Compare July 29, 2025 23:29
process can be represented as:

```{math}
\theta_{\text{new}} = \theta_{\text{old}} - \alpha \nabla_{\theta} J(\theta)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albanD 's our mathemetician, I just look at formulas and they look approximately fine to me lol


PyTorch can do so much more beyond the basic alarithmetic operations. It supports complex neural network architectures through
its {mod}`torch.nn` module, provides efficient data loading utilities with {mod}
`torch.utils.data`, and offers a suite of optimization algorithms in {mod}`torch.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

torch.utils.data, torch.optim not rendering correctly
image

Comment on lines 70 to 80
```{code-cell}
@torch.compile
def compute(x):
return x**2 + 3*x
x = torch.tensor([1.0, 2.0], requires_grad=True)
y = compute(x)
y.backward(torch.ones_like(x))
print(y)
print(x.grad)
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

tf32 warning by default is not good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how should we change the code above to not have it =)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would adding this to the example help? Or is that doing too much?
import torch

torch.backends.cuda.matmul.fp32_precision = "tf32"
torch.backends.cudnn.conv.fp32_precision = "tf32"


Learn more about torch.compile in the {ref}`torch.compiler_overview` section.

## GPU Acceleration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably list this above torch.compile, GPU acceleration is more core to pytorch than compile.

Comment on lines 91 to 92
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(f"Using device: {device}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image If the CI runner does CPU then we should just not evaluate the code cell

Comment on lines 95 to 96
x = torch.randn(1000, 1000)
x = x.to(device)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Probably better to just construct it on the right device torch.randn(1000, 1000, device=device) instead of doing the movement.

@@ -23,17 +23,10 @@ The APIs and performance characteristics of these features may change.
:glob:
:maxdepth: 2
Get Started <https://pytorch.org/get-started/locally/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be "install pytorch" or something, I don't know what "get started means"


* **Autograd** - PyTorch's automatic differentiation engine that tracks operations performed on tensors and builds a computational graph dynamically. It enables efficient gradient computation for backpropagation during model training with minimal overhead.

* **Neural Network API** - A modular framework for building neural networks with pre-defined layers, activation functions, and loss functions. The `nn.Module` base class provides a clean interface for creating custom network architectures with parameter management.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nn.Module should link back to torch.nn.Module API somehow

Comment on lines 26 to 27
* **torch.compile** - Just-in-Time (JIT) compilation for accelerated execution. torch.compile transforms PyTorch code into optimized computational graphs at runtime. It can provide significant speedups with minimal code changes by analyzing execution patterns and applying hardware-specific optimizations.
* **torch.export** - Exporting models for deployment in resource-constrained environments. torch.export generates standalone artifacts that can run without the PyTorch runtime. It supports various deployment targets, including mobile, embedded, and cloud.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally these link to the torch.compile API and the torch.export API, respectively. There should be some way to do this with myst-markdown

Comment on lines 37 to 38
* **Distributed Training** - Includes data parallelism (`DistributedDataParallel`), model parallelism, and pipeline parallelism options. Supports communication backends like NCCL and Gloo for efficient multi-node training. **`Fully Sharded Data Parallel`(FSDP2)** provides memory-efficient training for large models by sharding model parameters, gradients, and optimizer states across devices while maintaining training efficiency.
* **Profiling and Monitoring** - Tools like `torch.profiler` help identify bottlenecks, visualize execution traces, and monitor resource utilization during training and inference.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here- DDP, torch.profiler, should link back to their doc pages.


* **Tensors** ({class}`torch.tensor`)- N-dimensional arrays that serve as PyTorch's fundamental
data structure. They support automatic differentiation, GPU acceleration, and provide a comprehensive
API for mathematical operations. Tensors can seamlessly move between CPU and GPU for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tensors can seamlessly move between CPU and GPU

Not sure I agree with that statement

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't either. Let's delete it

Comment on lines 29 to 34
## PyTorch Components for Production-Grade Performance and Deployment

PyTorch extends beyond basic deep learning capabilities with advanced features designed for
production-grade performance and deployment. These components optimize model execution,
reduce resource requirements, and enable scaling across multiple compute devices.
These components include:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this section and just leave torch.compile here?

resource-constrained environments. torch.export generates standalone artifacts
that can run without the PyTorch runtime. It supports various deployment targets,
including mobile, embedded, and cloud.
* **Inductor** ([TorchInductor](../torch.compiler_inductor_profiling.html))- The default backend
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it needs to be there? I.e. aren't inductor a compiler internal implementation details that could be added later?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with deleting Inductor and AOTInductor together

Comment on lines 52 to 54
* **AOTInductor** ({ref}`torch.compiler_aot_inductor`)- Compiles models Ahead-Of-Time (AOT) for deployment environments
where JIT compilation isn't feasible. **AOTInductor** generates standalone artifacts
that can run without the PyTorch runtime.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @albanD
Shouldn't it be called something else? (Or again, may be removed from top-level menu?)

where JIT compilation isn't feasible. **AOTInductor** generates standalone artifacts
that can run without the PyTorch runtime.

### Deployment and Optimization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be called something else? At least I don't see a single deployment framework/technology/API mentioned there

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What in this PR is causing the top bar to change between this and trunk?

Comment on lines 5 to 7
ecosystem of tools and libraries. Whether you are a beginner or an
experienced practitioner, this guide will help you harness the power
of PyTorch to create and deploy machine learning models effectively.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ecosystem of tools and libraries. Whether you are a beginner or an
experienced practitioner, this guide will help you harness the power
of PyTorch to create and deploy machine learning models effectively.
ecosystem of tools and libraries.

@@ -0,0 +1,107 @@
---
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this page and point to the tutorial intro: as done below: https://docs.pytorch.org/tutorials/beginner/basics/intro.html

The overall intro the done more in depth there and the two particular examples here don't really work right now and I don't think it's worth blocking this page on fixing them.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think keeping this actually helps (assuming fixing the examples isnt a big issue). This doc provides a quick overview without getting too lost in the weeds especially for those users who dont need to go into ML basics but want a quick overview of PyTorch. The page does still link to Learn the basics for those who need it and as suck the two complement each other.

Plus for seo purposes this is one more thing that can surface and bring users to the necessary pages.

If fixing the examples would take a lot, we could take those out for now since it is a work in progress anyways.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specific examples here look very weird and I expect will be a lot of work to cleanup.
You can make this just a link to the starting tutorial if you want though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albanD took the examples out and just left a basic overview. I do think an overview with basic examples would be good but I agree that we cant let the examples hold up landing his and getting work done on it. Let me know what you think.


* **Tensors** ({class}`torch.tensor`)- N-dimensional arrays that serve as PyTorch's fundamental
data structure. They support automatic differentiation, GPU acceleration, and provide a comprehensive
API for mathematical operations. Tensors can seamlessly move between CPU and GPU for
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't either. Let's delete it


Some of the basic PyTorch components include:

* **Tensors** ({class}`torch.tensor`)- N-dimensional arrays that serve as PyTorch's fundamental
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what the class/module below try to do but these don't work. Let's remove

Comment on lines 17 to 18
graph dynamically. It enables efficient gradient computation for backpropagation
during model training with minimal overhead.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
graph dynamically. It enables efficient gradient computation for backpropagation
during model training with minimal overhead.
graph dynamically to be able to compute gradients.

during model training with minimal overhead.

* **Neural Network API** ({mod}`nn.Module`)- A modular framework for building neural networks with pre-defined layers,
activation functions, and loss functions. The {mod}`nn.Module` base class provides a clean interface
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these don't really work as links. Not sure if that's expected

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed them for now

Comment on lines 28 to 34

## PyTorch Components for Production-Grade Performance and Deployment

PyTorch extends beyond basic deep learning capabilities with advanced features designed for
production-grade performance and deployment. These components optimize model execution,
reduce resource requirements, and enable scaling across multiple compute devices.
These components include:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## PyTorch Components for Production-Grade Performance and Deployment
PyTorch extends beyond basic deep learning capabilities with advanced features designed for
production-grade performance and deployment. These components optimize model execution,
reduce resource requirements, and enable scaling across multiple compute devices.
These components include:

agreed with Nikita, that doesn't exist today

Comment on lines 39 to 54
reduce resource requirements. It includes:
* **torch.compile** ({func}`torch.compile`)- Just-in-Time (JIT) compilation for accelerated execution.
torch.compile transforms PyTorch code into optimized computational graphs at runtime.
It can provide significant speedups with minimal code changes by analyzing execution
patterns and applying hardware-specific optimizations.
* **torch.export** ({func}`torch.export`)- Exporting models for deployment in
resource-constrained environments. torch.export generates standalone artifacts
that can run without the PyTorch runtime. It supports various deployment targets,
including mobile, embedded, and cloud.
* **Inductor** ([TorchInductor](../torch.compiler_inductor_profiling.html))- The default backend
for {func}`torch.compile` that converts PyTorch operations
into efficient machine code. Uses TorchIR as an intermediate representation to apply
optimizations like operator fusion, memory planning, and loop transformations.
* **AOTInductor** ({ref}`torch.compiler_aot_inductor`)- Compiles models Ahead-Of-Time (AOT) for deployment environments
where JIT compilation isn't feasible. **AOTInductor** generates standalone artifacts
that can run without the PyTorch runtime.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reduce resource requirements. It includes:
* **torch.compile** ({func}`torch.compile`)- Just-in-Time (JIT) compilation for accelerated execution.
torch.compile transforms PyTorch code into optimized computational graphs at runtime.
It can provide significant speedups with minimal code changes by analyzing execution
patterns and applying hardware-specific optimizations.
* **torch.export** ({func}`torch.export`)- Exporting models for deployment in
resource-constrained environments. torch.export generates standalone artifacts
that can run without the PyTorch runtime. It supports various deployment targets,
including mobile, embedded, and cloud.
* **Inductor** ([TorchInductor](../torch.compiler_inductor_profiling.html))- The default backend
for {func}`torch.compile` that converts PyTorch operations
into efficient machine code. Uses TorchIR as an intermediate representation to apply
optimizations like operator fusion, memory planning, and loop transformations.
* **AOTInductor** ({ref}`torch.compiler_aot_inductor`)- Compiles models Ahead-Of-Time (AOT) for deployment environments
where JIT compilation isn't feasible. **AOTInductor** generates standalone artifacts
that can run without the PyTorch runtime.
reduce resource requirements.

Let's just link to the compiler page from here.

Comment on lines 56 to 72
### Deployment and Optimization

PyTorch provides tools for optimizing model performance and deployment in various environments. These include:

* **Quantization** ([torchao](https://docs.pytorch.org/ao/stable/index.html))- Precision-reduction
techniques for model efficiency. Qunatization features of PyTorch reduce model precision
from 32-bit to 8-bit or lower formats. They support post-training quantization, quantization-aware training, and dynamic
quantization to balance accuracy and efficiency.
* **Edge Deployment** ([Executorch](../index.html))- ExecuTorch is a PyTorch-compatible library that supports
resource-constrained environments.
* **Distributed Training** ([torch.distributed](../distributed.html)) - Includes data parallelism (`DistributedDataParallel`),
model parallelism, and pipeline parallelism options. Supports communication backends
like NCCL and Gloo for efficient multi-node training. **`Fully Sharded Data Parallel`(FSDP2)** provides
memory-efficient training for large models by sharding model parameters, gradients,
and optimizer states across devices while maintaining training efficiency.
* **Profiling and Monitoring** - Tools like {class}`torch.profiler` help identify bottlenecks,
visualize execution traces, and monitor resource utilization during training and inference.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Deployment and Optimization
PyTorch provides tools for optimizing model performance and deployment in various environments. These include:
* **Quantization** ([torchao](https://docs.pytorch.org/ao/stable/index.html))- Precision-reduction
techniques for model efficiency. Qunatization features of PyTorch reduce model precision
from 32-bit to 8-bit or lower formats. They support post-training quantization, quantization-aware training, and dynamic
quantization to balance accuracy and efficiency.
* **Edge Deployment** ([Executorch](../index.html))- ExecuTorch is a PyTorch-compatible library that supports
resource-constrained environments.
* **Distributed Training** ([torch.distributed](../distributed.html)) - Includes data parallelism (`DistributedDataParallel`),
model parallelism, and pipeline parallelism options. Supports communication backends
like NCCL and Gloo for efficient multi-node training. **`Fully Sharded Data Parallel`(FSDP2)** provides
memory-efficient training for large models by sharding model parameters, gradients,
and optimizer states across devices while maintaining training efficiency.
* **Profiling and Monitoring** - Tools like {class}`torch.profiler` help identify bottlenecks,
visualize execution traces, and monitor resource utilization during training and inference.

Not sure what we're trying to do here, let's delete for v0 and we can discuss later to add things back

Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final rendering looks off ?
image

@@ -0,0 +1,107 @@
---
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specific examples here look very weird and I expect will be a lot of work to cleanup.
You can make this just a link to the starting tutorial if you want though.

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: docs Related to our documentation, both in docs/ and docblocks topic: docs topic category topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants