Skip to content

[test] memory format tutorial #3351

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

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
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
14 changes: 0 additions & 14 deletions .github/workflows/build-tutorials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,7 @@ jobs:
strategy:
matrix:
include:
- { shard: 1, num_shards: 15, runner: "linux.g5.12xlarge.nvidia.gpu" }
- { shard: 2, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 3, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 4, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 5, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 6, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 7, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 8, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 9, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 10, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 11, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 12, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 13, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 14, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
- { shard: 15, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
fail-fast: false
runs-on: ${{ matrix.runner }}
steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ cleanup.sh

# pyspelling
dictionary.dic

# CI stuff
tutorials-review-data.json
5 changes: 4 additions & 1 deletion .jenkins/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ if [[ "${JOB_TYPE}" == "worker" ]]; then

# Step 3: Run `make docs` to generate HTML files and static files for these tutorialis
pip3 install -e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
make docs
make download
make download-last-reviewed-json
python .jenkins/sphinx_files.py
make postprocess

# Step 3.1: Run the post-processing script:
python .jenkins/post_process_notebooks.py
Expand Down
2 changes: 2 additions & 0 deletions .jenkins/get_files_to_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
from pathlib import Path
from remove_runnable_code import remove_runnable_code
from validate_tutorials_built import NOT_RUN


# Calculate repo base dir
Expand Down Expand Up @@ -96,6 +97,7 @@ def main() -> None:

all_files = get_all_files()
files_to_run = calculate_shards(all_files, num_shards=args.num_shards)[args.shard_num - 1]
files_to_run = [x for x in files_to_run if x not in [f"{f}.py" for f in NOT_RUN]]
if not args.dry_run:
remove_other_files(all_files, compute_files_to_keep(files_to_run))
stripped_file_names = [Path(x).stem for x in files_to_run]
Expand Down
36 changes: 36 additions & 0 deletions .jenkins/sphinx_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import glob
from pathlib import Path
import shutil
import subprocess
import os
from get_files_to_run import remove_other_files, compute_files_to_keep, calculate_shards, get_all_files
from validate_tutorials_built import NOT_RUN

def main() -> None:
all_files = get_all_files()
files_to_run = calculate_shards(all_files, num_shards=20)[int(os.environ.get("WORKER_ID", "1")) - 1]
files_to_run = [x for x in files_to_run if x not in [f"{f}.py" for f in NOT_RUN]]

os.makedirs("/tmp/docs_to_zip", exist_ok=True)

env = os.environ.copy()
for file in files_to_run:
remove_other_files(all_files, compute_files_to_keep(file))
print(f"Running {file}")
stem = Path(file).stem
env["RUNTHIS"] = stem
subprocess.check_output(["make", "html"], env=env)
subprocess.check_output(["make", "postprocess"], env=env)
print("Done running")
for file in glob.glob(f"docs/**/*", recursive=True):
if stem in file:
relative_path = Path(os.path.relpath(file, "docs"))
print(relative_path)
print(relative_path.parent)
os.makedirs(os.path.dirname(f"/tmp/docs_to_zip/{relative_path}"), exist_ok=True)
shutil.copy(file, f"/tmp/docs_to_zip/{relative_path}")
subprocess.check_output(["git", "reset", "--hard", "HEAD"])
shutil.move("/tmp/docs_to_zip", "docs")

if __name__ == "__main__":
main()
1 change: 0 additions & 1 deletion .jenkins/validate_tutorials_built.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"intermediate_source/tensorboard_profiler_tutorial", # reenable after 2.0 release.
"advanced_source/semi_structured_sparse", # reenable after 3303 is fixed.
"intermediate_source/torchrec_intro_tutorial", # reenable after 3302 is fixe
"intermediate_source/memory_format_tutorial", # causes other tutorials like torch_logs fail. "state" issue, reseting dynamo didn't help
]

def tutorial_source_dirs() -> List[Path]:
Expand Down
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,18 @@ download-last-reviewed-json:
@echo "Downloading tutorials-review-data.json..."
curl -o tutorials-review-data.json https://raw.githubusercontent.com/pytorch/tutorials/refs/heads/last-reviewed-data-json/tutorials-review-data.json
@echo "Finished downloading tutorials-review-data.json."
docs:
make download
make download-last-reviewed-json
make html

postprocess:
@python .jenkins/insert_last_verified.py $(BUILDDIR)/html
rm -rf docs
cp -r $(BUILDDIR)/html docs
touch docs/.nojekyll
rm -rf tutorials-review-data.json

docs:
make download
make download-last-reviewed-json
make html
make postprocess

html-noplot:
$(SPHINXBUILD) -D plot_gallery=0 -b html $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html"
Expand Down
15 changes: 2 additions & 13 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,13 @@
# -- Sphinx-gallery configuration --------------------------------------------

def reset_seeds(gallery_conf, fname):
torch.cuda.empty_cache()
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
torch._dynamo.reset()
torch._inductor.config.force_disable_caches = True
torch.manual_seed(42)
torch.set_default_device(None)
random.seed(10)
numpy.random.seed(10)
torch.set_grad_enabled(True)

gc.collect()
pass

sphinx_gallery_conf = {
'examples_dirs': ['beginner_source', 'intermediate_source',
'advanced_source', 'recipes_source', 'prototype_source'],
'gallery_dirs': ['beginner', 'intermediate', 'advanced', 'recipes', 'prototype'],
'filename_pattern': re.compile(SPHINX_SHOULD_RUN),
'filename_pattern': os.getenv("RUNTHIS"),
'promote_jupyter_magic': True,
'backreferences_dir': None,
'first_notebook_cell': ("# For tips on running notebooks in Google Colab, see\n"
Expand Down
Loading