-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
base: main
Are you sure you want to change the base?
Conversation
- 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
🔗 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 ( 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. |
|
||
# What is PyTorch? | ||
|
||
PyTorch, or torch, is an open-source machine learning library written in Python that |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
ee86c94
to
8c8ae0e
Compare
process can be represented as: | ||
|
||
```{math} | ||
\theta_{\text{new}} = \theta_{\text{old}} - \alpha \nabla_{\theta} J(\theta) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```{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) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 =)?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | ||
print(f"Using device: {device}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x = torch.randn(1000, 1000) | ||
x = x.to(device) |
There was a problem hiding this comment.
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.
docs/source/index.md
Outdated
@@ -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/> |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
* **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. |
There was a problem hiding this comment.
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
* **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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
## 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: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
* **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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this 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?
docs/source/user_guide/index.md
Outdated
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 @@ | |||
--- |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
graph dynamically. It enables efficient gradient computation for backpropagation | ||
during model training with minimal overhead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed them for now
|
||
## 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## 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
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
### 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### 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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,107 @@ | |||
--- |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
cc @sekyondaMeta @AlannaBurke