Skip to content

Commit c0c3e5c

Browse files
authored
Merge branch 'main' into fix/rpc-tutorial-trajectory-mixing
2 parents b217c8a + bcb7e29 commit c0c3e5c

8 files changed

Lines changed: 31 additions & 23 deletions

File tree

.ci/docker/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pydantic>=2.10
2525
fastapi
2626
matplotlib
2727
librosa
28-
torch==2.11
28+
torch==2.12
2929
torchvision
3030
torchdata
3131
networkx

.github/workflows/build-tutorials-nightly.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ name: Build tutorials (nightly/test)
1515
# download the binaries in .jenkins/build.sh.
1616
on:
1717
# Only main branch for now. Uncomment the below line to enable it on PRs.
18-
pull_request:
18+
# pull_request:
1919

2020
# Comment out the below line to disable on the main branch
21-
push:
22-
branches:
23-
- main
21+
# push:
22+
# branches:
23+
# - main
2424
workflow_dispatch:
2525

2626
concurrency:

advanced_source/privateuseone.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Facilitating New Backend Integration by PrivateUse1
44
In this tutorial we will walk through some necessary steps to integrate a new backend
55
living outside ``pytorch/pytorch`` repo by ``PrivateUse1``. Note that this tutorial assumes that
66
you already have a basic understanding of PyTorch.
7-
you are an advanced user of PyTorch.
87

98
.. note::
109

beginner_source/blitz/tensor_tutorial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@
105105
#
106106

107107
# We move our tensor to the GPU if available
108-
if torch.cuda.is_available():
109-
tensor = tensor.to('cuda')
110-
print(f"Device tensor is stored on: {tensor.device}")
108+
device = torch.accelerator.current_accelerator().type if torch.accelerator.is_available() else 'cpu'
109+
tensor = tensor.to(device)
110+
print(f"Device tensor is stored on: {tensor.device}")
111111

112112

113113
######################################################################

beginner_source/ddp_series_multigpu.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ Running the distributed training job
202202
Here's what the code looks like:
203203

204204
.. code-block:: python
205+
205206
def main(rank, world_size, total_epochs, save_every):
206207
ddp_setup(rank, world_size)
207208
dataset, model, optimizer = load_train_objs()
@@ -218,7 +219,6 @@ Here's what the code looks like:
218219
mp.spawn(main, args=(world_size, total_epochs, save_every,), nprocs=world_size)
219220
220221
221-
222222
Further Reading
223223
---------------
224224

beginner_source/examples_autograd/polynomial_custom_function.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,24 @@ class LegendrePolynomial3(torch.autograd.Function):
2929
"""
3030

3131
@staticmethod
32-
def forward(ctx, input):
32+
def forward(input):
3333
"""
3434
In the forward pass we receive a Tensor containing the input and return
35-
a Tensor containing the output. ctx is a context object that can be used
36-
to stash information for backward computation. You can cache tensors for
37-
use in the backward pass using the ``ctx.save_for_backward`` method. Other
38-
objects can be stored directly as attributes on the ctx object, such as
39-
``ctx.my_object = my_object``. Check out `Extending torch.autograd <https://docs.pytorch.org/docs/stable/notes/extending.html#extending-torch-autograd>`_
35+
a Tensor containing the output. Check out `Extending torch.autograd <https://docs.pytorch.org/docs/stable/notes/extending.html#extending-torch-autograd>`_
4036
for further details.
4137
"""
42-
ctx.save_for_backward(input)
4338
return 0.5 * (5 * input ** 3 - 3 * input)
4439

40+
@staticmethod
41+
def setup_context(ctx, inputs, output):
42+
"""
43+
Store input for use in the backward pass using ``ctx.save_for_backward``.
44+
Other objects can be stored directly as attributes on the ctx object,
45+
such as ``ctx.my_object = my_object``.
46+
"""
47+
input, = inputs
48+
ctx.save_for_backward(input)
49+
4550
@staticmethod
4651
def backward(ctx, grad_output):
4752
"""
@@ -54,8 +59,11 @@ def backward(ctx, grad_output):
5459

5560

5661
dtype = torch.float
57-
device = torch.device("cpu")
58-
# device = torch.device("cuda:0") # Uncomment this to run on GPU
62+
device = (
63+
torch.accelerator.current_accelerator().type
64+
if torch.accelerator.is_available()
65+
else "cpu"
66+
)
5967

6068
# Create Tensors to hold input and outputs.
6169
# By default, requires_grad=False, which indicates that we do not need to

beginner_source/introyt/modelsyt_tutorial.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ class is a subclass of ``torch.Tensor``, with the special behavior that
4848
class TinyModel(torch.nn.Module):
4949

5050
def __init__(self):
51-
super(TinyModel, self).__init__()
51+
super().__init__()
5252

5353
self.linear1 = torch.nn.Linear(100, 200)
5454
self.activation = torch.nn.ReLU()
5555
self.linear2 = torch.nn.Linear(200, 10)
56-
self.softmax = torch.nn.Softmax()
56+
self.softmax = torch.nn.Softmax(dim=1)
5757

5858
def forward(self, x):
5959
x = self.linear1(x)
@@ -150,7 +150,7 @@ def forward(self, x):
150150
class LeNet(torch.nn.Module):
151151

152152
def __init__(self):
153-
super(LeNet, self).__init__()
153+
super().__init__()
154154
# 1 input image channel (black & white), 6 output channels, 5x5 square convolution
155155
# kernel
156156
self.conv1 = torch.nn.Conv2d(1, 6, 5)
@@ -249,7 +249,7 @@ def num_flat_features(self, x):
249249
class LSTMTagger(torch.nn.Module):
250250

251251
def __init__(self, embedding_dim, hidden_dim, vocab_size, tagset_size):
252-
super(LSTMTagger, self).__init__()
252+
super().__init__()
253253
self.hidden_dim = hidden_dim
254254

255255
self.word_embeddings = torch.nn.Embedding(vocab_size, embedding_dim)

index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Welcome to PyTorch Tutorials
33

44
**What's new in PyTorch tutorials?**
55

6+
* `Data Loading Optimization in PyTorch <https://docs.pytorch.org/tutorials/intermediate/intermediate_data_loading_tutorial.html>`__
67
* `Distributed Training with Ray Train <https://docs.pytorch.org/tutorials/beginner/distributed_training_with_ray_tutorial.html>`__
78
* `Serve PyTorch models at scale with Ray Serve <https://docs.pytorch.org/tutorials/beginner/serving_tutorial.html>`__
89
* `Hyperparameter tuning using Ray Tune <https://docs.pytorch.org/tutorials/beginner/hyperparameter_tuning_tutorial.html>`__

0 commit comments

Comments
 (0)