From e732ca5240002b137f8d4f604864a9ec17c711d1 Mon Sep 17 00:00:00 2001 From: Alanna Burke Date: Wed, 23 Apr 2025 12:37:13 -0400 Subject: [PATCH 01/32] Move back to use stable binaries 2.7. --- .ci/docker/requirements.txt | 2 +- .jenkins/build.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.ci/docker/requirements.txt b/.ci/docker/requirements.txt index 0e95c62c6b..df9b3c01fb 100644 --- a/.ci/docker/requirements.txt +++ b/.ci/docker/requirements.txt @@ -14,7 +14,7 @@ tqdm==4.66.1 numpy==1.24.4 matplotlib librosa -torch==2.6 +torch==2.7 torchvision torchdata networkx diff --git a/.jenkins/build.sh b/.jenkins/build.sh index 8786859d7d..e249c2a6b5 100755 --- a/.jenkins/build.sh +++ b/.jenkins/build.sh @@ -22,10 +22,10 @@ sudo apt-get install -y pandoc #Install PyTorch Nightly for test. # Nightly - pip install --pre torch torchvision torchaudio -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html # Install 2.5 to merge all 2.4 PRs - uncomment to install nightly binaries (update the version as needed). -# sudo pip uninstall -y torch torchvision torchaudio torchtext torchdata -# sudo pip3 install torch==2.6.0 torchvision --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124 -# sudo pip uninstall -y fbgemm-gpu torchrec -# sudo pip3 install fbgemm-gpu==1.1.0 torchrec==1.0.0 --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124 +sudo pip uninstall -y torch torchvision torchaudio torchtext torchdata +sudo pip3 install torch==2.7.0 torchvision --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124 +sudo pip uninstall -y fbgemm-gpu torchrec +sudo pip3 install fbgemm-gpu==1.1.0 torchrec==1.0.0 --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124 sudo pip uninstall -y torch torchvision torchaudio torchtext torchdata torchrl tensordict pip3 install torch==2.7.0 torchvision torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu126 #sudo pip uninstall -y fbgemm-gpu From e0c662229e440b3c1605da94dfd8fad081af9281 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Wed, 23 Apr 2025 09:39:26 -0700 Subject: [PATCH 02/32] Update .jenkins/build.sh --- .jenkins/build.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.jenkins/build.sh b/.jenkins/build.sh index e249c2a6b5..87bf454568 100755 --- a/.jenkins/build.sh +++ b/.jenkins/build.sh @@ -22,12 +22,12 @@ sudo apt-get install -y pandoc #Install PyTorch Nightly for test. # Nightly - pip install --pre torch torchvision torchaudio -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html # Install 2.5 to merge all 2.4 PRs - uncomment to install nightly binaries (update the version as needed). -sudo pip uninstall -y torch torchvision torchaudio torchtext torchdata -sudo pip3 install torch==2.7.0 torchvision --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124 -sudo pip uninstall -y fbgemm-gpu torchrec -sudo pip3 install fbgemm-gpu==1.1.0 torchrec==1.0.0 --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124 -sudo pip uninstall -y torch torchvision torchaudio torchtext torchdata torchrl tensordict -pip3 install torch==2.7.0 torchvision torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu126 +# sudo pip uninstall -y torch torchvision torchaudio torchtext torchdata +# sudo pip3 install torch==2.7.0 torchvision --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124 +# sudo pip uninstall -y fbgemm-gpu torchrec +# sudo pip3 install fbgemm-gpu==1.1.0 torchrec==1.0.0 --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124 +# sudo pip uninstall -y torch torchvision torchaudio torchtext torchdata torchrl tensordict +# pip3 install torch==2.7.0 torchvision torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu126 #sudo pip uninstall -y fbgemm-gpu # Install two language tokenizers for Translation with TorchText tutorial python -m spacy download en_core_web_sm From c0e6b7c11aa3e76b2abbf55dcc46abd1bb942068 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Wed, 23 Apr 2025 17:50:39 -0700 Subject: [PATCH 03/32] Update requirements.txt --- .ci/docker/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/docker/requirements.txt b/.ci/docker/requirements.txt index df9b3c01fb..ca7dd0204a 100644 --- a/.ci/docker/requirements.txt +++ b/.ci/docker/requirements.txt @@ -28,8 +28,8 @@ tensorboard jinja2==3.1.3 pytorch-lightning torchx -torchrl==0.7.2 -tensordict==0.7.2 +# torchrl==0.7.2 +# tensordict==0.7.2 ax-platform>=0.4.0 nbformat>=5.9.2 datasets From 5e137d95dd02ceae336347a08c89597085e0e4ab Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 09:59:03 -0700 Subject: [PATCH 04/32] Update .ci/docker/requirements.txt --- .ci/docker/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/docker/requirements.txt b/.ci/docker/requirements.txt index ca7dd0204a..df9b3c01fb 100644 --- a/.ci/docker/requirements.txt +++ b/.ci/docker/requirements.txt @@ -28,8 +28,8 @@ tensorboard jinja2==3.1.3 pytorch-lightning torchx -# torchrl==0.7.2 -# tensordict==0.7.2 +torchrl==0.7.2 +tensordict==0.7.2 ax-platform>=0.4.0 nbformat>=5.9.2 datasets From ba270bfcca8bf64a7d7fb19896d59d47a771176e Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 10:01:15 -0700 Subject: [PATCH 05/32] Update requirements.txt --- .ci/docker/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/docker/requirements.txt b/.ci/docker/requirements.txt index df9b3c01fb..dd6991715c 100644 --- a/.ci/docker/requirements.txt +++ b/.ci/docker/requirements.txt @@ -69,5 +69,5 @@ pycocotools semilearn==0.3.2 torchao==0.5.0 segment_anything==1.0 -torchrec==1.1.0; platform_system == "Linux" -fbgemm-gpu==1.1.0; platform_system == "Linux" +torchrec==1.2.0; platform_system == "Linux" +fbgemm-gpu==1.2.0; platform_system == "Linux" From 142a191009ce18d51707e4272b5a7645f8350165 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 10:21:07 -0700 Subject: [PATCH 06/32] Update .ci/docker/requirements.txt --- .ci/docker/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/docker/requirements.txt b/.ci/docker/requirements.txt index dd6991715c..1f9fd4dd6d 100644 --- a/.ci/docker/requirements.txt +++ b/.ci/docker/requirements.txt @@ -69,5 +69,5 @@ pycocotools semilearn==0.3.2 torchao==0.5.0 segment_anything==1.0 -torchrec==1.2.0; platform_system == "Linux" +torchrec==1.1.0; platform_system == "Linux" fbgemm-gpu==1.2.0; platform_system == "Linux" From 56304b718894ab9c18ce94460c74871809d25356 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 11:29:54 -0700 Subject: [PATCH 07/32] Update requirements.txt --- .ci/docker/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/docker/requirements.txt b/.ci/docker/requirements.txt index 1f9fd4dd6d..e6802cb045 100644 --- a/.ci/docker/requirements.txt +++ b/.ci/docker/requirements.txt @@ -67,7 +67,7 @@ iopath pygame==2.6.0 pycocotools semilearn==0.3.2 -torchao==0.5.0 +torchao==0.10.0 segment_anything==1.0 torchrec==1.1.0; platform_system == "Linux" fbgemm-gpu==1.2.0; platform_system == "Linux" From 6a2279554a440deef726ed7a676c561500ebddc4 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 12:40:26 -0700 Subject: [PATCH 08/32] Update --- .jenkins/validate_tutorials_built.py | 7 ------- conf.py | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.jenkins/validate_tutorials_built.py b/.jenkins/validate_tutorials_built.py index 3ed1e0c028..298b80b02a 100644 --- a/.jenkins/validate_tutorials_built.py +++ b/.jenkins/validate_tutorials_built.py @@ -51,13 +51,6 @@ "intermediate_source/text_to_speech_with_torchaudio", "intermediate_source/tensorboard_profiler_tutorial", # reenable after 2.0 release. "advanced_source/semi_structured_sparse", # reenable after 3303 is fixed. - "intermediate_source/mario_rl_tutorial", # reenable after 3302 is fixed - "intermediate_source/reinforcement_ppo", # reenable after 3302 is fixed - "intermediate_source/pinmem_nonblock", # reenable after 3302 is fixed - "intermediate_source/dqn_with_rnn_tutorial", # reenable after 3302 is fixed - "advanced_source/pendulum", # reenable after 3302 is fixed - "advanced_source/coding_ddpg", # reenable after 3302 is fixed - "intermediate_source/torchrec_intro_tutorial", # reenable after 3302 is fixed "recipes_source/recipes/reasoning_about_shapes" # reenable after 3326 is fixed ] diff --git a/conf.py b/conf.py index a12a05d21c..c8bb59477d 100644 --- a/conf.py +++ b/conf.py @@ -86,6 +86,13 @@ 'sphinx_sitemap' ] +katex_prerender = False + +# Add this KaTeX configuration +katex_options = { + "throwOnError": False, +} + intersphinx_mapping = { "torch": ("https://pytorch.org/docs/stable/", None), "tensordict": ("https://pytorch.github.io/tensordict/", None), From f655e3ca2ebb79a996ddd53d1c5c380ecebcf99d Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 13:01:31 -0700 Subject: [PATCH 09/32] Update --- conf.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/conf.py b/conf.py index c8bb59477d..bec55e5692 100644 --- a/conf.py +++ b/conf.py @@ -86,12 +86,6 @@ 'sphinx_sitemap' ] -katex_prerender = False - -# Add this KaTeX configuration -katex_options = { - "throwOnError": False, -} intersphinx_mapping = { "torch": ("https://pytorch.org/docs/stable/", None), From 21c197833710018b68a0baa83a474b200269c1f7 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 15:34:02 -0700 Subject: [PATCH 10/32] Update --- conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf.py b/conf.py index bec55e5692..77c72553fc 100644 --- a/conf.py +++ b/conf.py @@ -105,6 +105,8 @@ def reset_seeds(gallery_conf, fname): random.seed(10) numpy.random.seed(10) gc.collect() + torch._dynamo() + torch._inductor.clear_compile_cache() sphinx_gallery_conf = { 'examples_dirs': ['beginner_source', 'intermediate_source', From 2fc656f8f2a8b7d6694957a879aa0865620c40e8 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 16:07:45 -0700 Subject: [PATCH 11/32] Update --- conf.py | 207 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 120 insertions(+), 87 deletions(-) diff --git a/conf.py b/conf.py index 77c72553fc..26d8df8d57 100644 --- a/conf.py +++ b/conf.py @@ -29,34 +29,44 @@ # import os import sys -sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath('./.jenkins')) -import pytorch_sphinx_theme -import torch -import numpy + +sys.path.insert(0, os.path.abspath(".")) +sys.path.insert(0, os.path.abspath("./.jenkins")) +import distutils.file_util import gc import glob import random -import shutil -from custom_directives import IncludeDirective, GalleryItemDirective, CustomGalleryItemDirective, CustomCalloutItemDirective, CustomCardItemDirective -import distutils.file_util import re -from get_sphinx_filenames import SPHINX_SHOULD_RUN +import shutil +from pathlib import Path + +import numpy import pandocfilters -import pypandoc import plotly.io as pio -from pathlib import Path -pio.renderers.default = 'sphinx_gallery' +import pypandoc +import pytorch_sphinx_theme +import torch +from custom_directives import ( + CustomCalloutItemDirective, + CustomCardItemDirective, + CustomGalleryItemDirective, + GalleryItemDirective, + IncludeDirective, +) +from get_sphinx_filenames import SPHINX_SHOULD_RUN + +pio.renderers.default = "sphinx_gallery" try: import torchvision except ImportError: import warnings + warnings.warn('unable to load "torchvision" package') import pytorch_sphinx_theme -rst_epilog =""" +rst_epilog = """ .. |edit| image:: /_static/pencil-16.png :width: 16px :height: 16px @@ -69,21 +79,21 @@ # needs_sphinx = '1.0' html_meta = { - 'description': 'Master PyTorch with our step-by-step tutorials for all skill levels. Start your journey to becoming a PyTorch expert today!', - 'keywords': 'PyTorch, tutorials, Getting Started, deep learning, AI', - 'author': 'PyTorch Contributors' + "description": "Master PyTorch with our step-by-step tutorials for all skill levels. Start your journey to becoming a PyTorch expert today!", + "keywords": "PyTorch, tutorials, Getting Started, deep learning, AI", + "author": "PyTorch Contributors", } # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinxcontrib.katex', - 'sphinx.ext.intersphinx', - 'sphinx_copybutton', - 'sphinx_gallery.gen_gallery', - 'sphinx_design', - 'sphinx_sitemap' + "sphinxcontrib.katex", + "sphinx.ext.intersphinx", + "sphinx_copybutton", + "sphinx_gallery.gen_gallery", + "sphinx_design", + "sphinx_sitemap", ] @@ -98,6 +108,7 @@ # -- Sphinx-gallery configuration -------------------------------------------- + def reset_seeds(gallery_conf, fname): torch.cuda.empty_cache() torch.manual_seed(42) @@ -105,27 +116,36 @@ def reset_seeds(gallery_conf, fname): random.seed(10) numpy.random.seed(10) gc.collect() - torch._dynamo() + torch._dynamo.reset() torch._inductor.clear_compile_cache() + 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), - 'promote_jupyter_magic': True, - 'backreferences_dir': None, - 'first_notebook_cell': ("# For tips on running notebooks in Google Colab, see\n" - "# https://pytorch.org/tutorials/beginner/colab\n" - "%matplotlib inline"), - 'reset_modules': (reset_seeds), - 'ignore_pattern': r'_torch_export_nightly_tutorial.py', - 'pypandoc': {'extra_args': ['--mathjax', '--toc'], - 'filters': ['.jenkins/custom_pandoc_filter.py'], + "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), + "promote_jupyter_magic": True, + "backreferences_dir": None, + "first_notebook_cell": ( + "# For tips on running notebooks in Google Colab, see\n" + "# https://pytorch.org/tutorials/beginner/colab\n" + "%matplotlib inline" + ), + "reset_modules": (reset_seeds), + "ignore_pattern": r"_torch_export_nightly_tutorial.py", + "pypandoc": { + "extra_args": ["--mathjax", "--toc"], + "filters": [".jenkins/custom_pandoc_filter.py"], }, } -html_baseurl = 'https://pytorch.org/tutorials/' # needed for sphinx-sitemap +html_baseurl = "https://pytorch.org/tutorials/" # needed for sphinx-sitemap sitemap_locales = [None] sitemap_excludes = [ "search.html", @@ -133,7 +153,7 @@ def reset_seeds(gallery_conf, fname): ] sitemap_url_scheme = "{link}" -if os.getenv('GALLERY_PATTERN'): +if os.getenv("GALLERY_PATTERN"): # GALLERY_PATTERN is to be used when you want to work on a single # tutorial. Previously this was fed into filename_pattern, but # if you do that, you still end up parsing all of the other Python @@ -141,9 +161,11 @@ def reset_seeds(gallery_conf, fname): # ignore_pattern also skips parsing. # See https://github.com/sphinx-gallery/sphinx-gallery/issues/721 # for a more detailed description of the issue. - sphinx_gallery_conf['ignore_pattern'] = r'/(?!' + re.escape(os.getenv('GALLERY_PATTERN')) + r')[^/]+$' + sphinx_gallery_conf["ignore_pattern"] = ( + r"/(?!" + re.escape(os.getenv("GALLERY_PATTERN")) + r")[^/]+$" + ) -for i in range(len(sphinx_gallery_conf['examples_dirs'])): +for i in range(len(sphinx_gallery_conf["examples_dirs"])): gallery_dir = Path(sphinx_gallery_conf["gallery_dirs"][i]) source_dir = Path(sphinx_gallery_conf["examples_dirs"][i]) @@ -155,21 +177,21 @@ def reset_seeds(gallery_conf, fname): distutils.file_util.copy_file(f, gallery_subdir_path, update=True) # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'PyTorch Tutorials' -copyright = '2024, PyTorch' -author = 'PyTorch contributors' +project = "PyTorch Tutorials" +copyright = "2024, PyTorch" +author = "PyTorch contributors" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -185,17 +207,22 @@ def reset_seeds(gallery_conf, fname): # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = 'en' +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'src/pytorch-sphinx-theme/docs*'] -exclude_patterns += sphinx_gallery_conf['examples_dirs'] -exclude_patterns += ['*/index.rst'] +exclude_patterns = [ + "_build", + "Thumbs.db", + ".DS_Store", + "src/pytorch-sphinx-theme/docs*", +] +exclude_patterns += sphinx_gallery_conf["examples_dirs"] +exclude_patterns += ["*/index.rst"] # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -223,7 +250,7 @@ def reset_seeds(gallery_conf, fname): # # Add any paths that contain custom static files (such as style sheets) here, # # relative to this directory. They are copied after the builtin static files, # # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # # Custom sidebar templates, maps document names to template names. # html_sidebars = { @@ -232,23 +259,23 @@ def reset_seeds(gallery_conf, fname): # } -html_theme = 'pytorch_sphinx_theme' +html_theme = "pytorch_sphinx_theme" html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()] -html_logo = '_static/img/pytorch-logo-dark.svg' +html_logo = "_static/img/pytorch-logo-dark.svg" html_theme_options = { - 'pytorch_project': 'tutorials', - 'collapse_navigation': False, - 'display_version': True, - 'navigation_with_keys': True, - 'logo_only': False, - 'analytics_id': 'GTM-T8XT4PS', + "pytorch_project": "tutorials", + "collapse_navigation": False, + "display_version": True, + "navigation_with_keys": True, + "logo_only": False, + "analytics_id": "GTM-T8XT4PS", } # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = 'PyTorchTutorialsdoc' +htmlhelp_basename = "PyTorchTutorialsdoc" # -- Options for LaTeX output --------------------------------------------- @@ -257,15 +284,12 @@ def reset_seeds(gallery_conf, fname): # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. # # 'preamble': '', - # Latex figure (float) alignment # # 'figure_align': 'htbp', @@ -275,8 +299,13 @@ def reset_seeds(gallery_conf, fname): # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'PyTorchTutorials.tex', 'PyTorch Tutorials', - 'Sasank, PyTorch contributors', 'manual'), + ( + master_doc, + "PyTorchTutorials.tex", + "PyTorch Tutorials", + "Sasank, PyTorch contributors", + "manual", + ), ] @@ -284,10 +313,7 @@ def reset_seeds(gallery_conf, fname): # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'pytorchtutorials', 'PyTorch Tutorials', - [author], 1) -] +man_pages = [(master_doc, "pytorchtutorials", "PyTorch Tutorials", [author], 1)] # -- Options for Texinfo output ------------------------------------------- @@ -296,40 +322,47 @@ def reset_seeds(gallery_conf, fname): # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'PyTorchTutorials', 'PyTorch Tutorials', - author, 'PyTorchTutorials', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "PyTorchTutorials", + "PyTorch Tutorials", + author, + "PyTorchTutorials", + "One line description of project.", + "Miscellaneous", + ), ] html_css_files = [ - 'https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.css', - 'css/custom.css', - 'css/custom2.css' - ] + "https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.css", + "css/custom.css", + "css/custom2.css", +] html_js_files = [ "js/custom.js", ] + def setup(app): # NOTE: in Sphinx 1.8+ `html_css_files` is an official configuration value # and can be moved outside of this function (and the setup(app) function # can be deleted). - #html_css_files = [ + # html_css_files = [ # 'https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.css', # 'css/custom.css' - #] + # ] # In Sphinx 1.8 it was renamed to `add_css_file`, 1.7 and prior it is # `add_stylesheet` (deprecated in 1.8). - #add_css = getattr(app, 'add_css_file', app.add_stylesheet) - #for css_file in html_css_files: + # add_css = getattr(app, 'add_css_file', app.add_stylesheet) + # for css_file in html_css_files: # add_css(css_file) # Custom CSS - #app.add_stylesheet('css/pytorch_theme.css') + # app.add_stylesheet('css/pytorch_theme.css') # app.add_stylesheet('https://fonts.googleapis.com/css?family=Lato') # Custom directives - app.add_directive('includenodoc', IncludeDirective) - app.add_directive('galleryitem', GalleryItemDirective) - app.add_directive('customgalleryitem', CustomGalleryItemDirective) - app.add_directive('customcarditem', CustomCardItemDirective) - app.add_directive('customcalloutitem', CustomCalloutItemDirective) + app.add_directive("includenodoc", IncludeDirective) + app.add_directive("galleryitem", GalleryItemDirective) + app.add_directive("customgalleryitem", CustomGalleryItemDirective) + app.add_directive("customcarditem", CustomCardItemDirective) + app.add_directive("customcalloutitem", CustomCalloutItemDirective) From b0b7f111b4e0b0dd767650fac3221e21cca943d9 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 17:23:45 -0700 Subject: [PATCH 12/32] Update --- conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 26d8df8d57..ae54b9dc9e 100644 --- a/conf.py +++ b/conf.py @@ -117,7 +117,9 @@ def reset_seeds(gallery_conf, fname): numpy.random.seed(10) gc.collect() torch._dynamo.reset() - torch._inductor.clear_compile_cache() + from torch._inductor.utils import clear_inductor_caches + + clear_inductor_caches() sphinx_gallery_conf = { From 8db0356b4c9751e0ea5049045f1cd6dc61fabc75 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 18:57:39 -0700 Subject: [PATCH 13/32] Update --- conf.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/conf.py b/conf.py index ae54b9dc9e..7d791e6e96 100644 --- a/conf.py +++ b/conf.py @@ -117,9 +117,12 @@ def reset_seeds(gallery_conf, fname): numpy.random.seed(10) gc.collect() torch._dynamo.reset() - from torch._inductor.utils import clear_inductor_caches + import torch._inductor - clear_inductor_caches() + torch._inductor.metrics.reset() + from torch._inductor.codecache import PyCodeCache + + PyCodeCache.cache_clear(purge=True) sphinx_gallery_conf = { From 6020a80e837382b733b2d6e04b1ba3adf2535194 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 19:04:31 -0700 Subject: [PATCH 14/32] Update --- .jenkins/validate_tutorials_built.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.jenkins/validate_tutorials_built.py b/.jenkins/validate_tutorials_built.py index 298b80b02a..1a7f52f4d2 100644 --- a/.jenkins/validate_tutorials_built.py +++ b/.jenkins/validate_tutorials_built.py @@ -52,6 +52,7 @@ "intermediate_source/tensorboard_profiler_tutorial", # reenable after 2.0 release. "advanced_source/semi_structured_sparse", # reenable after 3303 is fixed. "recipes_source/recipes/reasoning_about_shapes" # reenable after 3326 is fixed + "intermediate_source/torchrec_intro_tutorial" # reenable after torchrec releases 1.2.0 ] def tutorial_source_dirs() -> List[Path]: From 47e89a0809636c08e443c235e5e0fa86155ad50f Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 19:16:07 -0700 Subject: [PATCH 15/32] update --- .jenkins/validate_tutorials_built.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jenkins/validate_tutorials_built.py b/.jenkins/validate_tutorials_built.py index 1a7f52f4d2..6a54bf8c47 100644 --- a/.jenkins/validate_tutorials_built.py +++ b/.jenkins/validate_tutorials_built.py @@ -51,7 +51,7 @@ "intermediate_source/text_to_speech_with_torchaudio", "intermediate_source/tensorboard_profiler_tutorial", # reenable after 2.0 release. "advanced_source/semi_structured_sparse", # reenable after 3303 is fixed. - "recipes_source/recipes/reasoning_about_shapes" # reenable after 3326 is fixed + "recipes_source/recipes/reasoning_about_shapes", # reenable after 3326 is fixed "intermediate_source/torchrec_intro_tutorial" # reenable after torchrec releases 1.2.0 ] From b5b0261ffa5fbf49eaf32a50f6bc6835701a1879 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 19:24:46 -0700 Subject: [PATCH 16/32] update --- conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/conf.py b/conf.py index 7d791e6e96..463fb1ecb9 100644 --- a/conf.py +++ b/conf.py @@ -110,6 +110,7 @@ def reset_seeds(gallery_conf, fname): + global torch torch.cuda.empty_cache() torch.manual_seed(42) torch.set_default_device(None) From 8c77c998ba2730c1dcc95296c4e0f27ae74f003b Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 19:44:22 -0700 Subject: [PATCH 17/32] update --- conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 463fb1ecb9..34eb82b36d 100644 --- a/conf.py +++ b/conf.py @@ -121,9 +121,10 @@ def reset_seeds(gallery_conf, fname): import torch._inductor torch._inductor.metrics.reset() - from torch._inductor.codecache import PyCodeCache + from torch._inductor.codecache import CppCodeCache, PyCodeCache PyCodeCache.cache_clear(purge=True) + CppCodeCache.cache_clear() sphinx_gallery_conf = { From 09a8489ac64b6f3a2f6fdb36851d5b1fe3cba26b Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 20:16:25 -0700 Subject: [PATCH 18/32] Update --- conf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conf.py b/conf.py index 34eb82b36d..e6b99b6643 100644 --- a/conf.py +++ b/conf.py @@ -112,6 +112,8 @@ def reset_seeds(gallery_conf, fname): global torch torch.cuda.empty_cache() + if torch.cuda.is_available(): + torch.cuda.reset_peak_memory_stats() torch.manual_seed(42) torch.set_default_device(None) random.seed(10) @@ -119,10 +121,9 @@ def reset_seeds(gallery_conf, fname): gc.collect() torch._dynamo.reset() import torch._inductor - - torch._inductor.metrics.reset() from torch._inductor.codecache import CppCodeCache, PyCodeCache + torch._inductor.clear_inductor_caches() PyCodeCache.cache_clear(purge=True) CppCodeCache.cache_clear() From 2122895c351803d143c2cf955882657f6d6f54e8 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 28 Apr 2025 20:26:12 -0700 Subject: [PATCH 19/32] Update --- conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/conf.py b/conf.py index e6b99b6643..c775ddca6d 100644 --- a/conf.py +++ b/conf.py @@ -123,7 +123,6 @@ def reset_seeds(gallery_conf, fname): import torch._inductor from torch._inductor.codecache import CppCodeCache, PyCodeCache - torch._inductor.clear_inductor_caches() PyCodeCache.cache_clear(purge=True) CppCodeCache.cache_clear() From c67817eb764a2cd4a5771f8d9373dad2b540fd47 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 08:32:23 -0700 Subject: [PATCH 20/32] Update --- conf.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/conf.py b/conf.py index c775ddca6d..32f5324e88 100644 --- a/conf.py +++ b/conf.py @@ -111,20 +111,18 @@ def reset_seeds(gallery_conf, fname): global torch + torch._dynamo.reset() torch.cuda.empty_cache() if torch.cuda.is_available(): + torch.cuda.empty_cache() torch.cuda.reset_peak_memory_stats() torch.manual_seed(42) torch.set_default_device(None) random.seed(10) numpy.random.seed(10) gc.collect() - torch._dynamo.reset() - import torch._inductor - from torch._inductor.codecache import CppCodeCache, PyCodeCache - - PyCodeCache.cache_clear(purge=True) - CppCodeCache.cache_clear() + import torch._inductor.utils + torch_inductor.utils.clear_inductor_caches() sphinx_gallery_conf = { From 7300783f66a406f5dbcc58c491db2827c7a6dc7c Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 08:45:14 -0700 Subject: [PATCH 21/32] Update --- conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 32f5324e88..1739cd1bba 100644 --- a/conf.py +++ b/conf.py @@ -122,7 +122,7 @@ def reset_seeds(gallery_conf, fname): numpy.random.seed(10) gc.collect() import torch._inductor.utils - torch_inductor.utils.clear_inductor_caches() + torch._inductor.utils.clear_inductor_caches() sphinx_gallery_conf = { From 20f418908e01c2ce27bb967d6ca3ee98eef44b83 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 09:21:36 -0700 Subject: [PATCH 22/32] Update --- conf.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/conf.py b/conf.py index 1739cd1bba..c81af0f1f2 100644 --- a/conf.py +++ b/conf.py @@ -112,17 +112,13 @@ def reset_seeds(gallery_conf, fname): global torch torch._dynamo.reset() - torch.cuda.empty_cache() - if torch.cuda.is_available(): - torch.cuda.empty_cache() - torch.cuda.reset_peak_memory_stats() + torch.dynamo.reset() + torch.cuda.empty_cache() torch.manual_seed(42) torch.set_default_device(None) random.seed(10) numpy.random.seed(10) gc.collect() - import torch._inductor.utils - torch._inductor.utils.clear_inductor_caches() sphinx_gallery_conf = { From 54495c756ba8dde534ce29e7c091a95ee6f8ceeb Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 09:31:01 -0700 Subject: [PATCH 23/32] Update --- conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/conf.py b/conf.py index c81af0f1f2..87783b03a8 100644 --- a/conf.py +++ b/conf.py @@ -112,7 +112,6 @@ def reset_seeds(gallery_conf, fname): global torch torch._dynamo.reset() - torch.dynamo.reset() torch.cuda.empty_cache() torch.manual_seed(42) torch.set_default_device(None) From cdf2da65b1610759d87958203475cc6b280c9a59 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 09:59:07 -0700 Subject: [PATCH 24/32] Update --- conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 87783b03a8..8396bd6881 100644 --- a/conf.py +++ b/conf.py @@ -112,7 +112,8 @@ def reset_seeds(gallery_conf, fname): global torch torch._dynamo.reset() - torch.cuda.empty_cache() + torch._inductor.utils.fresh_inductor_cache() + torch.cuda.empty_cache() torch.manual_seed(42) torch.set_default_device(None) random.seed(10) From 69ab9269c904d5ac57307128ae935dab1243a2f4 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 11:08:18 -0700 Subject: [PATCH 25/32] Update --- conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/conf.py b/conf.py index 8396bd6881..78330ba9f7 100644 --- a/conf.py +++ b/conf.py @@ -114,6 +114,7 @@ def reset_seeds(gallery_conf, fname): torch._dynamo.reset() torch._inductor.utils.fresh_inductor_cache() torch.cuda.empty_cache() + torch.cuda.ipc_collect() torch.manual_seed(42) torch.set_default_device(None) random.seed(10) From 2414a2d26eea75bcf21692618ef8c56302967632 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 11:47:56 -0700 Subject: [PATCH 26/32] Update --- conf.py | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/conf.py b/conf.py index 78330ba9f7..0af6bd0c5a 100644 --- a/conf.py +++ b/conf.py @@ -111,8 +111,38 @@ def reset_seeds(gallery_conf, fname): global torch - torch._dynamo.reset() - torch._inductor.utils.fresh_inductor_cache() + + import importlib + import sys + + modules_to_reload = [] + for module_name in list(sys.modules.keys()): + if module_name.startswith("torch") or module_name in ["numpy", "random"]: + if module_name in sys.modules: + modules_to_reload.append(module_name) + + if hasattr(torch, "_dynamo"): + torch._dynamo.reset() + + if hasattr(torch, "_inductor"): + torch._inductor.aot_compile = False + torch._inductor.config.triton.cudagraphs = False + torch._inductor.config.debug = False + torch._inductor.config.max_autotune = True + torch._inductor.config.triton.unique_kernel_names = True + torch._inductor.config.max_autotune_gemm_backends = "TRITON" + torch._inductor.config.search_autotune_cache = True + torch._inductor.config.compile_threads = 1 + + if hasattr(torch, "onnx"): + torch.onnx._operator_importers.triton._reset() + torch.onnx._internal.exporter._reset() + torch.onnx._internal.fx._reset() + + torch.backends.cudnn.deterministic = False + torch.backends.cudnn.benchmark = True + if hasattr(torch, "_inductor") and hasattr(torch._inductor, "utils"): + torch._inductor.utils.fresh_inductor_cache() torch.cuda.empty_cache() torch.cuda.ipc_collect() torch.manual_seed(42) @@ -121,6 +151,19 @@ def reset_seeds(gallery_conf, fname): numpy.random.seed(10) gc.collect() + import __main__ + + for var in dir(__main__): + if not var.startswith("_"): + delattr(__main__, var) + + for module_name in modules_to_reload: + if module_name in sys.modules: + try: + importlib.reload(sys.modules[module_name]) + except: + pass + sphinx_gallery_conf = { "examples_dirs": [ From e8c4e173b57f4e9e2a0468200bf9155c780f1151 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 11:50:03 -0700 Subject: [PATCH 27/32] Update --- conf.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 0af6bd0c5a..f12724ec17 100644 --- a/conf.py +++ b/conf.py @@ -165,6 +165,20 @@ def reset_seeds(gallery_conf, fname): pass +def kill_procs(gallery_conf, fname): + import os + + import psutil + + # Get the current process + current_proc = psutil.Process(os.getpid()) + # Iterate over all child processes + for child in current_proc.children(recursive=True): + # Kill the child process + child.terminate() + print(f"Killed child process with PID {child.pid}") + + sphinx_gallery_conf = { "examples_dirs": [ "beginner_source", @@ -182,7 +196,7 @@ def reset_seeds(gallery_conf, fname): "# https://pytorch.org/tutorials/beginner/colab\n" "%matplotlib inline" ), - "reset_modules": (reset_seeds), + "reset_modules": (reset_seeds, kill_procs), "ignore_pattern": r"_torch_export_nightly_tutorial.py", "pypandoc": { "extra_args": ["--mathjax", "--toc"], From 1f70c73b4e58a9e0aad6dee22a83c4db233f43ba Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 12:30:47 -0700 Subject: [PATCH 28/32] Update --- conf.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/conf.py b/conf.py index f12724ec17..70753967be 100644 --- a/conf.py +++ b/conf.py @@ -134,11 +134,6 @@ def reset_seeds(gallery_conf, fname): torch._inductor.config.search_autotune_cache = True torch._inductor.config.compile_threads = 1 - if hasattr(torch, "onnx"): - torch.onnx._operator_importers.triton._reset() - torch.onnx._internal.exporter._reset() - torch.onnx._internal.fx._reset() - torch.backends.cudnn.deterministic = False torch.backends.cudnn.benchmark = True if hasattr(torch, "_inductor") and hasattr(torch._inductor, "utils"): From 83c98b27c0ff74898b2d64d1c36c7deb8f1d3693 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 12:45:26 -0700 Subject: [PATCH 29/32] Update --- conf.py | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/conf.py b/conf.py index 70753967be..88c04e0e43 100644 --- a/conf.py +++ b/conf.py @@ -115,36 +115,23 @@ def reset_seeds(gallery_conf, fname): import importlib import sys - modules_to_reload = [] - for module_name in list(sys.modules.keys()): - if module_name.startswith("torch") or module_name in ["numpy", "random"]: - if module_name in sys.modules: - modules_to_reload.append(module_name) - - if hasattr(torch, "_dynamo"): - torch._dynamo.reset() + random.seed(10) + numpy.random.seed(10) + torch.manual_seed(42) - if hasattr(torch, "_inductor"): - torch._inductor.aot_compile = False - torch._inductor.config.triton.cudagraphs = False - torch._inductor.config.debug = False - torch._inductor.config.max_autotune = True - torch._inductor.config.triton.unique_kernel_names = True - torch._inductor.config.max_autotune_gemm_backends = "TRITON" - torch._inductor.config.search_autotune_cache = True - torch._inductor.config.compile_threads = 1 + torch.cuda.empty_cache() + torch.cuda.ipc_collect() + torch.set_default_device(None) + # Reset torch settings torch.backends.cudnn.deterministic = False torch.backends.cudnn.benchmark = True + + if hasattr(torch, "_dynamo"): + torch._dynamo.reset() + if hasattr(torch, "_inductor") and hasattr(torch._inductor, "utils"): torch._inductor.utils.fresh_inductor_cache() - torch.cuda.empty_cache() - torch.cuda.ipc_collect() - torch.manual_seed(42) - torch.set_default_device(None) - random.seed(10) - numpy.random.seed(10) - gc.collect() import __main__ @@ -152,12 +139,7 @@ def reset_seeds(gallery_conf, fname): if not var.startswith("_"): delattr(__main__, var) - for module_name in modules_to_reload: - if module_name in sys.modules: - try: - importlib.reload(sys.modules[module_name]) - except: - pass + gc.collect() def kill_procs(gallery_conf, fname): From e781c6a3a9d6febc18f9dce998eeb4105c36d599 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 13:08:31 -0700 Subject: [PATCH 30/32] Update --- conf.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/conf.py b/conf.py index 88c04e0e43..b42228a7d1 100644 --- a/conf.py +++ b/conf.py @@ -142,20 +142,6 @@ def reset_seeds(gallery_conf, fname): gc.collect() -def kill_procs(gallery_conf, fname): - import os - - import psutil - - # Get the current process - current_proc = psutil.Process(os.getpid()) - # Iterate over all child processes - for child in current_proc.children(recursive=True): - # Kill the child process - child.terminate() - print(f"Killed child process with PID {child.pid}") - - sphinx_gallery_conf = { "examples_dirs": [ "beginner_source", @@ -173,7 +159,7 @@ def kill_procs(gallery_conf, fname): "# https://pytorch.org/tutorials/beginner/colab\n" "%matplotlib inline" ), - "reset_modules": (reset_seeds, kill_procs), + "reset_modules": (reset_seeds), "ignore_pattern": r"_torch_export_nightly_tutorial.py", "pypandoc": { "extra_args": ["--mathjax", "--toc"], From 0354cbbc4c232844ecbc5cb90c7e5485f687cd40 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 13:17:27 -0700 Subject: [PATCH 31/32] Update --- conf.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/conf.py b/conf.py index b42228a7d1..e42cee8a24 100644 --- a/conf.py +++ b/conf.py @@ -129,9 +129,19 @@ def reset_seeds(gallery_conf, fname): if hasattr(torch, "_dynamo"): torch._dynamo.reset() - - if hasattr(torch, "_inductor") and hasattr(torch._inductor, "utils"): - torch._inductor.utils.fresh_inductor_cache() + if hasattr(torch._dynamo, "optimizations"): + torch._dynamo.optimizations.clear() + if hasattr(torch._dynamo, "config"): + torch._dynamo.config.clear_cache() + + if hasattr(torch, "_inductor"): + if hasattr(torch._inductor, "utils"): + torch._inductor.utils.fresh_inductor_cache() + if hasattr(torch._inductor, "metrics"): + torch._inductor.metrics.reset() + + if hasattr(torch, "_logging"): + torch._logging.set_logs() import __main__ From 829cbc3ce278a8527924714022eb46a902d4d42d Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 29 Apr 2025 13:33:58 -0700 Subject: [PATCH 32/32] Update --- conf.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/conf.py b/conf.py index e42cee8a24..0bd612ce91 100644 --- a/conf.py +++ b/conf.py @@ -131,8 +131,6 @@ def reset_seeds(gallery_conf, fname): torch._dynamo.reset() if hasattr(torch._dynamo, "optimizations"): torch._dynamo.optimizations.clear() - if hasattr(torch._dynamo, "config"): - torch._dynamo.config.clear_cache() if hasattr(torch, "_inductor"): if hasattr(torch._inductor, "utils"):