Skip to content

Commit 5709eeb

Browse files
authored
Merge branch 'main' into mgs28-char-rnn-update
2 parents 76b5f55 + 11d9e5c commit 5709eeb

31 files changed

+2498
-288
lines changed

.ci/docker/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,7 @@ iopath
6868
pygame==2.6.0
6969
pycocotools
7070
semilearn==0.3.2
71-
torchao==0.0.3
71+
torchao==0.5.0
7272
segment_anything==1.0
73+
torchrec==0.8.0
74+
fbgemm-gpu==0.8.0

.github/workflows/StalePRs.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# A workflow copied from the pytorch/pytorch repo stale PRs that implements similar logic to actions/stale.
2+
#
3+
# Compared to actions/stale, it is implemented to make API requests proportional
4+
# to the number of stale PRs, not the total number of issues in the repo. This
5+
# is because PyTorch has a lot of issues/PRs, so the actions/stale runs into
6+
# rate limits way too quickly.
7+
#
8+
# The behavior is:
9+
# - If a PR is not labeled stale, after 60 days inactivity label the PR as stale and comment about it.
10+
# - If a PR is labeled stale, after 30 days inactivity close the PR.
11+
# - `high priority` and `no-stale` PRs are exempt.
12+
13+
name: Close stale pull requests
14+
15+
on:
16+
schedule:
17+
# Run at midnight UTC.
18+
- cron: '0 0 * * *'
19+
workflow_dispatch:
20+
21+
jobs:
22+
stale:
23+
if: ${{ github.repository == 'pytorch/tutorials' }}
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
pull-requests: write
28+
29+
steps:
30+
- uses: actions/github-script@v6
31+
with:
32+
script: |
33+
// Do some dumb retries on requests.
34+
const retries = 7;
35+
const baseBackoff = 100;
36+
const sleep = timeout => new Promise(resolve => setTimeout(resolve, timeout));
37+
github.hook.wrap('request', async (request, options) => {
38+
for (let attempt = 1; attempt <= retries; attempt++) {
39+
try {
40+
return await request(options);
41+
} catch (err) {
42+
if (attempt < retries) {
43+
core.warning(`Request getting retried. Attempt: ${attempt}`);
44+
await sleep(baseBackoff * Math.pow(2, attempt));
45+
continue;
46+
}
47+
throw err;
48+
}
49+
}
50+
});
51+
52+
const MAX_API_REQUESTS = 100;
53+
54+
// If a PRs not labeled stale, label them stale after no update for 60 days.
55+
const STALE_LABEL_THRESHOLD_MS = 1000 * 60 * 60 * 24 * 60;
56+
// For PRs already labeled stale, close after not update for 30 days.
57+
const STALE_CLOSE_THRESHOLD_MS = 1000 * 60 * 60 * 24 * 30;
58+
59+
const STALE_MESSAGE =
60+
"Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as `Stale`. <br>" +
61+
"Feel free to remove the `Stale` label if you feel this was a mistake. <br>" +
62+
"If you are unable to remove the `Stale` label please contact a maintainer in order to do so. <br>" +
63+
"If you want the bot to never mark this PR stale again, add the `no-stale` label.<br>" +
64+
"`Stale` pull requests will automatically be closed after 30 days of inactivity.<br>";
65+
66+
let numAPIRequests = 0;
67+
let numProcessed = 0;
68+
69+
async function processPull(pull) {
70+
core.info(`[${pull.number}] URL: ${pull.html_url}`);
71+
numProcessed += 1;
72+
const labels = pull.labels.map((label) => label.name);
73+
74+
// Skip if certain labels are present.
75+
if (labels.includes("no-stale") || labels.includes("high priority")) {
76+
core.info(`[${pull.number}] Skipping because PR has an exempting label.`);
77+
return false;
78+
}
79+
80+
// Check if the PR is stale, according to our configured thresholds.
81+
let staleThresholdMillis;
82+
if (labels.includes("Stale")) {
83+
core.info(`[${pull.number}] PR is labeled stale, checking whether we should close it.`);
84+
staleThresholdMillis = STALE_CLOSE_THRESHOLD_MS;
85+
} else {
86+
core.info(`[${pull.number}] Checking whether to label PR as stale.`);
87+
staleThresholdMillis = STALE_LABEL_THRESHOLD_MS;
88+
}
89+
90+
const millisSinceLastUpdated =
91+
new Date().getTime() - new Date(pull.updated_at).getTime();
92+
93+
if (millisSinceLastUpdated < staleThresholdMillis) {
94+
core.info(`[${pull.number}] Skipping because PR was updated recently`);
95+
return false;
96+
}
97+
98+
// At this point, we know we should do something.
99+
// For PRs already labeled stale, close them.
100+
if (labels.includes("Stale")) {
101+
core.info(`[${pull.number}] Closing PR.`);
102+
numAPIRequests += 1;
103+
await github.rest.issues.update({
104+
owner: "pytorch",
105+
repo: "tutorials",
106+
issue_number: pull.number,
107+
state: "closed",
108+
});
109+
} else {
110+
// For PRs not labeled stale, label them stale.
111+
core.info(`[${pull.number}] Labeling PR as stale.`);
112+
113+
numAPIRequests += 1;
114+
await github.rest.issues.createComment({
115+
owner: "pytorch",
116+
repo: "tutorials",
117+
issue_number: pull.number,
118+
body: STALE_MESSAGE,
119+
});
120+
121+
numAPIRequests += 1;
122+
await github.rest.issues.addLabels({
123+
owner: "pytorch",
124+
repo: "tutorials",
125+
issue_number: pull.number,
126+
labels: ["Stale"],
127+
});
128+
}
129+
}
130+
131+
for await (const response of github.paginate.iterator(
132+
github.rest.pulls.list,
133+
{
134+
owner: "pytorch",
135+
repo: "tutorials",
136+
state: "open",
137+
sort: "created",
138+
direction: "asc",
139+
per_page: 100,
140+
}
141+
)) {
142+
numAPIRequests += 1;
143+
const pulls = response.data;
144+
// Awaiting in a loop is intentional here. We want to serialize execution so
145+
// that log groups are printed correctl
146+
for (const pull of pulls) {
147+
if (numAPIRequests > MAX_API_REQUESTS) {
148+
core.warning("Max API requests exceeded, exiting.");
149+
process.exit(0);
150+
}
151+
await core.group(`Processing PR #${pull.number}`, async () => {
152+
await processPull(pull);
153+
});
154+
}
155+
}
156+
core.info(`Processed ${numProcessed} PRs total.`);
157+

.github/workflows/link_checkPR.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#Checks links in a PR to ensure they are valid. If link is valid but failing, it can be added to the .lycheeignore file
2+
#Code source: https://github.com/lycheeverse/lychee-action/issues/238
3+
4+
name: link check on PR
5+
6+
on:
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
check-links:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Clone repository
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
ref: ${{github.event.pull_request.head.ref}}
19+
repository: ${{github.event.pull_request.head.repo.full_name}}
20+
21+
- name: Check out main branch
22+
run: git checkout main
23+
24+
- name: Dump all links from main
25+
id: dump_links_from_main
26+
uses: lycheeverse/lychee-action@v1
27+
with:
28+
args: |
29+
--dump
30+
--include-fragments
31+
.
32+
output: ./links-main.txt
33+
34+
- name: Stash untracked files
35+
run: git stash push --include-untracked
36+
37+
- name: Check out feature branch
38+
run: git checkout ${{ github.head_ref }}
39+
40+
- name: Apply stashed changes
41+
# Apply stashed changes, ignore errors if stash is empty
42+
run: git stash pop || true
43+
44+
- name: Append links-main.txt to .lycheeignore
45+
run: cat links-main.txt >> .lycheeignore
46+
47+
- name: Check links
48+
uses: lycheeverse/lychee-action@v1
49+
with:
50+
args: |
51+
--no-progress
52+
--include-fragments
53+
.
54+
# Fail action on broken links
55+
fail: true
56+
57+
- name: Suggestions
58+
if: failure()
59+
run: |
60+
echo -e "\nPlease review the links reported in the Check links step above."
61+
echo -e "If a link is valid but fails due to a CAPTCHA challenge, IP blocking, login requirements, etc.,
62+
consider adding such links to .lycheeignore file to bypass future checks.\n"
63+
exit 1

.jenkins/build.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ sudo apt-get install -y pandoc
2121

2222
#Install PyTorch Nightly for test.
2323
# Nightly - pip install --pre torch torchvision torchaudio -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html
24-
# Install 2.4 to merge all 2.4 PRs - uncomment to install nightly binaries (update the version as needed).
25-
# pip uninstall -y torch torchvision torchaudio torchtext torchdata
26-
# pip3 install torch==2.4.0 torchvision torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124
24+
# Install 2.5 to merge all 2.4 PRs - uncomment to install nightly binaries (update the version as needed).
25+
pip uninstall -y torch torchvision torchaudio torchtext torchdata
26+
pip3 install torch==2.5.0 torchvision torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124
27+
pip3 install fbgemm-gpu==1.0.0 torchrec==1.0.0 --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124
2728

2829
# Install two language tokenizers for Translation with TorchText tutorial
2930
python -m spacy download en_core_web_sm

.jenkins/metadata.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"intermediate_source/model_parallel_tutorial.py": {
2929
"needs": "linux.16xlarge.nvidia.gpu"
3030
},
31+
"intermediate_source/torchrec_intro_tutorial.py": {
32+
"needs": "linux.g5.4xlarge.nvidia.gpu"
33+
},
3134
"recipes_source/torch_export_aoti_python.py": {
3235
"needs": "linux.g5.4xlarge.nvidia.gpu"
3336
},
@@ -58,6 +61,9 @@
5861
"recipes_source/torch_compile_user_defined_triton_kernel_tutorial.py": {
5962
"needs": "linux.g5.4xlarge.nvidia.gpu"
6063
},
64+
"recipes_source/regional_compilation.py": {
65+
"needs": "linux.g5.4xlarge.nvidia.gpu"
66+
},
6167
"advanced_source/semi_structured_sparse.py": {
6268
"needs": "linux.g5.4xlarge.nvidia.gpu"
6369
},

.lycheeignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Used for links to be ignored during the link check.
2+
# Add link to file along with comment as to why it should be ignored
549 KB
Loading

beginner_source/basics/saveloadrun_tutorial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
########################
5858
# We can then load the model as demonstrated below.
5959
#
60-
# As described in `Saving and loading torch.nn.Modules <pytorch.org/docs/main/notes/serialization.html#saving-and-loading-torch-nn-modules>`__,
61-
# saving ``state_dict``s is considered the best practice. However,
60+
# As described in `Saving and loading torch.nn.Modules <https://pytorch.org/docs/main/notes/serialization.html#saving-and-loading-torch-nn-modules>`_,
61+
# saving ``state_dict`` is considered the best practice. However,
6262
# below we use ``weights_only=False`` because this involves loading the
6363
# model, which is a legacy use case for ``torch.save``.
6464

beginner_source/dist_overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Sharding primitives
3535

3636
``DTensor`` and ``DeviceMesh`` are primitives used to build parallelism in terms of sharded or replicated tensors on N-dimensional process groups.
3737

38-
- `DTensor <https://github.com/pytorch/pytorch/blob/main/torch/distributed/_tensor/README.md>`__ represents a tensor that is sharded and/or replicated, and communicates automatically to reshard tensors as needed by operations.
38+
- `DTensor <https://github.com/pytorch/pytorch/blob/main/torch/distributed/tensor/README.md>`__ represents a tensor that is sharded and/or replicated, and communicates automatically to reshard tensors as needed by operations.
3939
- `DeviceMesh <https://pytorch.org/docs/stable/distributed.html#devicemesh>`__ abstracts the accelerator device communicators into a multi-dimensional array, which manages the underlying ``ProcessGroup`` instances for collective communications in multi-dimensional parallelisms. Try out our `Device Mesh Recipe <https://pytorch.org/tutorials/recipes/distributed_device_mesh.html>`__ to learn more.
4040

4141
Communications APIs

beginner_source/introyt/modelsyt_tutorial.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,7 @@ def forward(self, sentence):
311311
# ``TransformerDecoder``) and subcomponents (``TransformerEncoderLayer``,
312312
# ``TransformerDecoderLayer``). For details, check out the
313313
# `documentation <https://pytorch.org/docs/stable/nn.html#transformer-layers>`__
314-
# on transformer classes, and the relevant
315-
# `tutorial <https://pytorch.org/tutorials/beginner/transformer_tutorial.html>`__
316-
# on pytorch.org.
314+
# on transformer classes.
317315
#
318316
# Other Layers and Functions
319317
# --------------------------

0 commit comments

Comments
 (0)