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 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,11 @@ The APIs and performance characteristics of these features may change.
:glob:
:maxdepth: 2

Install PyTorch <https://pytorch.org/get-started/locally/>
user_guide/index
pytorch-api
notes
```

```{toctree}
:glob:
:hidden:
:maxdepth: 2

community/index
C++ <https://docs.pytorch.org/cppdocs/>
```

## Indices and tables
Expand Down
9 changes: 8 additions & 1 deletion docs/source/pytorch-api.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
(pytorch_api)=
# Python API
# Reference API

```{toctree}
:maxdepth: 1

C++ <https://docs.pytorch.org/cppdocs/>
```

```{toctree}
:glob:
:maxdepth: 1
:caption: Python API

torch
nn
Expand Down
39 changes: 39 additions & 0 deletions docs/source/user_guide/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# User Guide

PyTorch provides a flexible and efficient platform for building deep
learning models, offering dynamic computation graphs and a rich
ecosystem of tools and libraries. This guide will help you harness the power
of PyTorch to create and deploy machine learning models effectively.

```{note}
This guide is a work in progress.
```

```{toctree}
:maxdepth: 1
:caption: Introduction

Pytorch Overview <https://docs.pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html>
Get Started <https://pytorch.org/get-started/locally/>
Learn the Basics <https://docs.pytorch.org/tutorials/beginner/basics/intro.html>
```

```{toctree}
:maxdepth: 1
:caption: Core Concepts

pytorch_main_components
```

```{toctree}
:maxdepth: 1
:caption: Beyond the Basics

```

```{toctree}
:maxdepth: 1
:caption: Developer Notes

../notes
```
29 changes: 29 additions & 0 deletions docs/source/user_guide/pytorch_main_components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(pytorch_main_components)=
# PyTorch Main Components

PyTorch is a flexible and powerful library for deep learning that provides a comprehensive set of tools for building, training, and deploying machine learning models.

## PyTorch Components for Basic Deep Learning

Some of the basic PyTorch components include:

* **Tensors** - N-dimensional arrays that serve as PyTorch's fundamental
data structure. They support automatic differentiation, hardware acceleration, and provide a comprehensive API for mathematical operations.

* **Autograd** - PyTorch's automatic differentiation engine
that tracks operations performed on tensors and builds a computational
graph dynamically to be able to compute gradients.

* **Neural Network API** - 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

for creating custom network architectures with parameter management.

* **DataLoaders** - Tools for efficient data handling that provide
features like batching, shuffling, and parallel data loading. They abstract away the complexities
of data preprocessing and iteration, allowing for optimized training loops.


## PyTorch Compiler

The PyTorch compiler is a suite of tools that optimize model execution and
reduce resource requirements. You can learn more about the PyTorch compiler [here](https://docs.pytorch.org/docs/stable/torch.compiler_get_started.html).
54 changes: 54 additions & 0 deletions docs/source/user_guide/pytorch_overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
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.

file_format: mystnb
kernelspec:
name: python3
mystnb:
execution_timeout: 30
merge_streams: True
---

```{code-cell}
:tags: [remove-cell]
import torch
```

(what_is_pytorch)=

# 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

provides a platform for deep learning. It features a dynamic computational graph
that allows for flexible model building and debugging.

At its core, PyTorch uses tensors (multidimensional arrays) that can run on GPUs
for accelerated computation. For example, the gradient descent optimization
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

```

* `θ_new` is the updated parameter
* `θ_old` is the current parameter
* `α` is the learning rate
* `∇_θ J(θ)` is the gradient of the cost function with respect to `θ`

PyTorch's autograd engine automatically computes the gradients needed for neural network training.

For a quick tutorial on PyTorch, see the [Learn the Basics tutorial](https://pytorch.org/tutorials/beginner/basics/intro.html).

# Beyond Basic Operations

PyTorch extends far beyond basic arithmetic operations to provide a complete ecosystem for machine learning development:
* {mod}`torch.nn` module: Offers pre-built neural network layers, activation functions, and loss functions for constructing complex architectures
* {mod}`torch.utils.data`: Provides efficient data loading utilities with support for batching, shuffling, and parallel data loading
* {mod}`torch.optim`: Contains a comprehensive suite of optimization algorithms including SGD, Adam, RMSprop, and many others
* {func}`torch.compile`: Allows for compiling PyTorch models to improve execution speed and efficiency
* {func}`torch.export`: Enables exporting models for deployment in various environments.
* Distributed training: Facilitates training across multiple GPUs and nodes, making it suitable for large-scale machine learning tasks

```{seealso}
* {ref}`torch.compiler_overview`
* {ref}`torch.export`
* [Learn the basics](https://docs.pytorch.org/tutorials/beginner/basics/intro.html)
```
Loading