docs: move fabric on its own (#16742)

* docs: move fabric to Lai

* update imports

* links

* drop link to Trainer

* own docs

* ci

* trigger

* prune cross-links

* cleaning

* cleaning

* template

* imports

* template

* path

* links

* tensorboardX

* plugins

* label

* drop fixme

* drop copy nb + examples

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

* try again

* rev

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Jirka Borovec 2023-03-01 12:36:14 +01:00 committed by GitHub
parent ac815ec8a1
commit 0e8ac7e1c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 703 additions and 70 deletions

View File

@ -132,6 +132,22 @@ subprojects:
# checks:
# - "test-on-tpus"
- id: "fabric: Docs"
paths:
- "src/lightning/fabric/**"
- "src/lightning_fabric/*"
- "docs/source-fabric/**"
- ".github/workflows/docs-checks.yml"
- "requirements/docs.txt"
- "requirements/fabric/**"
- "setup.py"
- "pyproject.toml" # includes metadata used in the package creation
- "!*.md"
- "!**/*.md"
checks:
- "make-doctest (fabric)"
- "make-html (fabric)"
- id: "pytorch_lightning: Docs"
paths:
- "src/lightning/pytorch/**"

View File

@ -39,7 +39,7 @@ jobs:
strategy:
fail-fast: false
matrix:
pkg-name: ["app", "pytorch"]
pkg-name: ["app", "fabric", "pytorch"]
steps:
- uses: actions/checkout@v3
with:
@ -47,14 +47,14 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
- uses: aws-actions/configure-aws-credentials@v1
if: ${{ matrix.pkg-name == 'app' }}
if: ${{ matrix.pkg-name != 'pytorch' }}
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_ID }}
aws-region: us-east-1
- run: aws s3 sync s3://sphinx-packages/ pypi/
if: ${{ matrix.pkg-name == 'app' }}
if: ${{ matrix.pkg-name != 'pytorch' }}
# Note: This uses an internal pip API and may not always work
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
@ -85,7 +85,7 @@ jobs:
strategy:
fail-fast: false
matrix:
pkg-name: ["app", "pytorch"]
pkg-name: ["app", "fabric", "pytorch"]
steps:
- uses: actions/checkout@v3
with:

View File

@ -134,7 +134,7 @@ master_doc = "index"
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'
# List of patterns, relative to source-app directory, that match files and
# directories to ignore when looking for source-app files.
@ -396,5 +396,13 @@ doctest_global_setup = """
import importlib
import os
import lightning as L
from lightning.fabric.loggers.tensorboard import _TENSORBOARD_AVAILABLE, _TENSORBOARDX_AVAILABLE
"""
coverage_skip_undoc_in_source = True
# skip false positive linkcheck errors from anchors
linkcheck_anchors = False
# ignore all links in any CHANGELOG file
linkcheck_exclude_documents = [r"^(.*\/)*CHANGELOG.*$"]

View File

@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS = -T -W
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = ../build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

@ -0,0 +1,64 @@
/* Copied from the official Python docs: https://docs.python.org/3/_static/copybutton.js */
$(document).ready(function() {
/* Add a [>>>] button on the top-right corner of code samples to hide
* the >>> and ... prompts and the output and thus make the code
* copyable. */
var div = $('.highlight-python .highlight,' +
'.highlight-python3 .highlight,' +
'.highlight-pycon .highlight,' +
'.highlight-default .highlight');
var pre = div.find('pre');
// get the styles from the current theme
pre.parent().parent().css('position', 'relative');
var hide_text = 'Hide the prompts and output';
var show_text = 'Show the prompts and output';
var border_width = pre.css('border-top-width');
var border_style = pre.css('border-top-style');
var border_color = pre.css('border-top-color');
var button_styles = {
'cursor':'pointer', 'position': 'absolute', 'top': '0', 'right': '0',
'border-color': border_color, 'border-style': border_style,
'border-width': border_width, 'color': border_color, 'text-size': '75%',
'font-family': 'monospace', 'padding-left': '0.2em', 'padding-right': '0.2em',
'border-radius': '0 3px 0 0'
}
// create and add the button to all the code blocks that contain >>>
div.each(function(index) {
var jthis = $(this);
if (jthis.find('.gp').length > 0) {
var button = $('<span class="copybutton">&gt;&gt;&gt;</span>');
button.css(button_styles)
button.attr('title', hide_text);
button.data('hidden', 'false');
jthis.prepend(button);
}
// tracebacks (.gt) contain bare text elements that need to be
// wrapped in a span to work with .nextUntil() (see later)
jthis.find('pre:has(.gt)').contents().filter(function() {
return ((this.nodeType == 3) && (this.data.trim().length > 0));
}).wrap('<span>');
});
// define the behavior of the button when it's clicked
$('.copybutton').click(function(e){
e.preventDefault();
var button = $(this);
if (button.data('hidden') === 'false') {
// hide the code output
button.parent().find('.go, .gp, .gt').hide();
button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
button.css('text-decoration', 'line-through');
button.attr('title', show_text);
button.data('hidden', 'true');
} else {
// show the code output
button.parent().find('.go, .gp, .gt').show();
button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
button.css('text-decoration', 'none');
button.attr('title', hide_text);
button.data('hidden', 'false');
}
});
});

View File

@ -0,0 +1,9 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.6932 0.0821815L1.30579 3.77571C1.21278 3.82957 1.13557 3.90694 1.08189 4.00006C1.02822 4.09317 0.999984 4.19875 1 4.30622V11.6943C1.00003 11.8017 1.0283 11.9073 1.08196 12.0004C1.13563 12.0935 1.21281 12.1709 1.30579 12.2248L7.6932 15.9178C7.78648 15.9716 7.89229 16 8 16C8.10771 16 8.21351 15.9716 8.30679 15.9178L14.6942 12.2248C14.7872 12.1709 14.8644 12.0935 14.918 12.0004C14.9717 11.9073 15 11.8017 15 11.6943V4.30622C15 4.19875 14.9718 4.09317 14.9181 4.00006C14.8644 3.90694 14.7872 3.82957 14.6942 3.77571L8.30679 0.0821815C8.21351 0.0283364 8.10771 0 8 0C7.89229 0 7.78648 0.0283364 7.6932 0.0821815ZM6.65211 12.3978L7.41055 9.16688C7.41599 9.14352 7.41528 9.11917 7.40849 9.09617C7.4017 9.07317 7.38907 9.05231 7.37182 9.03564L5.53355 7.24295C5.51998 7.22994 5.50918 7.21431 5.5018 7.19703C5.49442 7.17975 5.49063 7.16117 5.49063 7.14237C5.49063 7.12358 5.49442 7.10498 5.5018 7.08769C5.50918 7.07041 5.51998 7.0548 5.53355 7.0418L9.12811 3.46996C9.14946 3.44852 9.17724 3.43466 9.20721 3.43046C9.23718 3.42626 9.2677 3.43196 9.29413 3.44671C9.32056 3.46146 9.34144 3.48444 9.3536 3.51215C9.36575 3.53986 9.36852 3.57079 9.36147 3.60022L8.60203 6.83864C8.59634 6.86203 8.59687 6.88649 8.60358 6.9096C8.61028 6.93272 8.62293 6.95367 8.64025 6.97037L10.4679 8.75303C10.4811 8.76603 10.4915 8.7815 10.4986 8.79855C10.5057 8.8156 10.5094 8.83388 10.5094 8.85235C10.5094 8.87082 10.5057 8.8891 10.4986 8.90615C10.4915 8.92319 10.4811 8.93867 10.4679 8.95167L6.88597 12.5265C6.86459 12.5475 6.83701 12.5611 6.8073 12.5652C6.77759 12.5693 6.74736 12.5637 6.72109 12.5492C6.69482 12.5348 6.67392 12.5122 6.66149 12.4849C6.64906 12.4576 6.64577 12.4271 6.65211 12.3978Z" fill="url(#paint0_linear_1878_170374)"/>
<defs>
<linearGradient id="paint0_linear_1878_170374" x1="11.5573" y1="2.06173" x2="-1.81768" y2="25.1199" gradientUnits="userSpaceOnUse">
<stop stop-color="#792EE5"/>
<stop offset="1" stop-color="#3EABB3"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,9 @@
<svg width="224" height="224" viewBox="0 0 224 224" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M107.705 1.15054L18.281 52.8599C16.9789 53.614 15.8979 54.6972 15.1465 56.0008C14.3951 57.3044 13.9998 58.7825 14 60.287V163.72C14.0005 165.224 14.3961 166.702 15.1475 168.005C15.8988 169.309 16.9794 170.392 18.281 171.147L107.705 222.849C109.011 223.603 110.492 224 112 224C113.508 224 114.989 223.603 116.295 222.849L205.719 171.147C207.021 170.392 208.101 169.309 208.853 168.005C209.604 166.702 210 165.224 210 163.72V60.287C210 58.7825 209.605 57.3044 208.853 56.0008C208.102 54.6972 207.021 53.614 205.719 52.8599L116.295 1.15054C114.989 0.39671 113.508 0 112 0C110.492 0 109.011 0.39671 107.705 1.15054ZM93.1295 173.569L103.748 128.336C103.824 128.009 103.814 127.668 103.719 127.346C103.624 127.024 103.447 126.732 103.206 126.499L77.4698 101.401C77.2798 101.219 77.1285 101 77.0252 100.758C76.9219 100.516 76.8688 100.256 76.8688 99.9932C76.8688 99.7301 76.9219 99.4697 77.0252 99.2277C77.1285 98.9857 77.2798 98.7672 77.4698 98.5852L127.794 48.5795C128.092 48.2793 128.481 48.0852 128.901 48.0264C129.321 47.9676 129.748 48.0475 130.118 48.254C130.488 48.4604 130.78 48.7821 130.95 49.1701C131.121 49.558 131.159 49.9911 131.061 50.4031L120.428 95.741C120.349 96.0684 120.356 96.4108 120.45 96.7345C120.544 97.0581 120.721 97.3513 120.964 97.5852L146.551 122.542C146.735 122.724 146.881 122.941 146.981 123.18C147.08 123.418 147.131 123.674 147.131 123.933C147.131 124.191 147.08 124.447 146.981 124.686C146.881 124.925 146.735 125.141 146.551 125.323L96.4036 175.371C96.1043 175.665 95.7181 175.855 95.3022 175.913C94.8863 175.97 94.463 175.891 94.0952 175.689C93.7275 175.487 93.4348 175.171 93.2608 174.789C93.0868 174.407 93.0408 173.979 93.1295 173.569Z" fill="url(#paint0_linear_1878_170388)"/>
<defs>
<linearGradient id="paint0_linear_1878_170388" x1="161.803" y1="28.8643" x2="-25.4475" y2="351.678" gradientUnits="userSpaceOnUse">
<stop stop-color="#792EE5"/>
<stop offset="1" stop-color="#3EABB3"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,9 @@
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M23.0796 0.246544L3.91737 11.3271C3.63833 11.4887 3.4067 11.7208 3.24568 12.0002C3.08467 12.2795 2.99995 12.5962 3 12.9186V35.0828C3.0001 35.4052 3.08489 35.7218 3.24589 36.0012C3.40688 36.2805 3.63844 36.5126 3.91737 36.6744L23.0796 47.7534C23.3594 47.9149 23.6769 48 24 48C24.3231 48 24.6405 47.9149 24.9204 47.7534L44.0826 36.6744C44.3615 36.5126 44.5931 36.2805 44.7541 36.0012C44.9151 35.7218 44.9999 35.4052 45 35.0828V12.9186C45 12.5962 44.9153 12.2795 44.7543 12.0002C44.5933 11.7208 44.3617 11.4887 44.0826 11.3271L24.9204 0.246544C24.6405 0.0850093 24.3231 0 24 0C23.6769 0 23.3594 0.0850093 23.0796 0.246544ZM19.9563 37.1933L22.2317 27.5006C22.248 27.4306 22.2458 27.3575 22.2255 27.2885C22.2051 27.2195 22.1672 27.1569 22.1155 27.1069L16.6007 21.7288C16.56 21.6898 16.5275 21.6429 16.5054 21.5911C16.4833 21.5392 16.4719 21.4835 16.4719 21.4271C16.4719 21.3707 16.4833 21.3149 16.5054 21.2631C16.5275 21.2112 16.56 21.1644 16.6007 21.1254L27.3843 10.4099C27.4484 10.3456 27.5317 10.304 27.6216 10.2914C27.7115 10.2788 27.8031 10.2959 27.8824 10.3401C27.9617 10.3844 28.0243 10.4533 28.0608 10.5364C28.0973 10.6196 28.1055 10.7124 28.0844 10.8007L25.8061 20.5159C25.789 20.5861 25.7906 20.6595 25.8107 20.7288C25.8308 20.7982 25.8688 20.861 25.9208 20.9111L31.4039 26.2591C31.4432 26.2981 31.4745 26.3445 31.4958 26.3956C31.5172 26.4468 31.5281 26.5016 31.5281 26.557C31.5281 26.6124 31.5172 26.6673 31.4958 26.7184C31.4745 26.7696 31.4432 26.816 31.4039 26.855L20.6579 37.5795C20.5938 37.6426 20.511 37.6833 20.4219 37.6956C20.3328 37.7079 20.2421 37.691 20.1633 37.6476C20.0845 37.6043 20.0217 37.5367 19.9845 37.4548C19.9472 37.3729 19.9373 37.2812 19.9563 37.1933Z" fill="url(#paint0_linear_1878_170386)"/>
<defs>
<linearGradient id="paint0_linear_1878_170386" x1="34.672" y1="6.1852" x2="-5.45303" y2="75.3597" gradientUnits="userSpaceOnUse">
<stop stop-color="#792EE5"/>
<stop offset="1" stop-color="#3EABB3"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@ -0,0 +1,3 @@
col {
width: 50% !important;
}

View File

@ -0,0 +1,41 @@
{{ name | escape | underline }}
.. currentmodule:: {{ fullname }}
{% block functions %}
{% if functions %}
.. rubric:: Functions
.. autosummary::
:nosignatures:
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block classes %}
{% if classes %}
.. rubric:: Classes
.. autosummary::
:nosignatures:
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block exceptions %}
{% if exceptions %}
.. rubric:: Exceptions
.. autosummary::
:nosignatures:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
.. automodule:: {{ fullname }}

View File

@ -0,0 +1,14 @@
.. role:: hidden
:class: hidden-section
.. currentmodule:: {{ module }}
{{ name | underline }}
.. autoclass:: {{ name }}
:members:
..
autogenerated from source-fabric/_templates/classtemplate.rst
note it does not have :inherited-members:

View File

@ -0,0 +1,12 @@
:orphan:
.. role:: hidden
:class: hidden-section
.. currentmodule:: {{ module }}
{{ name | underline }}
.. autoclass:: {{ name }}
:members:
:noindex:

View File

@ -0,0 +1,10 @@
{% extends "!layout.html" %}
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html" />
{% block footer %}
{{ super() }}
<script script type="text/javascript">
var collapsedSections = ['Best practices', 'Optional Extensions', 'Tutorials', 'API References', 'Bolts', 'Examples', 'Partner Domain Frameworks', 'Community'];
</script>
{% endblock %}

View File

@ -0,0 +1,18 @@
{%- set external_urls = {
'github': 'https://github.com/Lightning-AI/lightning',
'github_issues': 'https://github.com/Lightning-AI/lightning/issues',
'contributing': 'https://github.com/Lightning-AI/lightning/blob/master/.github/CONTRIBUTING.md',
'governance': 'https://github.com/Lightning-AI/lightning/blob/master/docs/source-pytorch/governance.rst',
'docs': 'https://lightning.rtfd.io/en/latest',
'twitter': 'https://twitter.com/PyTorchLightnin',
'discuss': 'https://pytorch-lightning.slack.com',
'tutorials': 'https://pt-lightning.readthedocs.io/en/latest/#tutorials',
'previous_pytorch_versions': 'https://pt-lightning.rtfd.io/en/latest/',
'home': 'https://lightning.ai/',
'get_started': 'https://pt-lightning.readthedocs.io/en/latest/introduction_guide.html',
'features': 'https://pt-lightning.rtfd.io/en/latest/',
'blog': 'https://www.pytorchlightning.ai/blog',
'resources': 'https://pt-lightning.readthedocs.io/en/latest/#community-examples',
'support': 'https://pt-lightning.rtfd.io/en/latest/',
}
-%}

View File

@ -140,7 +140,7 @@ See also: :doc:`../fundamentals/precision`
plugins
=======
:ref:`Plugins` allow you to connect arbitrary backends, precision libraries, clusters, etc. For example:
Plugins allow you to connect arbitrary backends, precision libraries, clusters, etc. For example:
To define your own behavior, subclass the relevant class and pass it in. Here's an example linking up your own
:class:`~lightning.fabric.plugins.environments.ClusterEnvironment`.

View File

@ -1,6 +1,6 @@
:orphan:
.. include:: ../../links.rst
.. include:: links.rst
#############
API Reference
@ -13,7 +13,7 @@ Fabric
.. currentmodule:: lightning.fabric.fabric
.. autosummary::
:toctree: ../../api
:toctree: api
:nosignatures:
:template: classtemplate.rst
@ -26,7 +26,7 @@ Accelerators
.. currentmodule:: lightning.fabric.accelerators
.. autosummary::
:toctree: ../../api
:toctree: api
:nosignatures:
:template: classtemplate.rst
@ -43,7 +43,7 @@ Loggers
.. currentmodule:: lightning.fabric.loggers
.. autosummary::
:toctree: ../../api
:toctree: api
:nosignatures:
:template: classtemplate.rst
@ -51,10 +51,6 @@ Loggers
CSVLogger
TensorBoardLogger
Plugins
^^^^^^^
Precision
"""""""""
@ -63,7 +59,7 @@ Precision
.. currentmodule:: lightning.fabric.plugins.precision
.. autosummary::
:toctree: ../../api
:toctree: api
:nosignatures:
:template: classtemplate.rst
@ -81,7 +77,7 @@ Environments
.. currentmodule:: lightning.fabric.plugins.environments
.. autosummary::
:toctree: ../../api
:toctree: api
:nosignatures:
:template: classtemplate_noindex.rst
@ -101,7 +97,7 @@ IO
.. currentmodule:: lightning.fabric.plugins.io
.. autosummary::
:toctree: ../../api
:toctree: api
:nosignatures:
:template: classtemplate.rst
@ -116,7 +112,7 @@ Collectives
.. currentmodule:: lightning.fabric.plugins.collectives
.. autosummary::
:toctree: ../../api
:toctree: api
:nosignatures:
:template: classtemplate.rst
@ -133,7 +129,7 @@ Strategies
.. currentmodule:: lightning.fabric.strategies
.. autosummary::
:toctree: ../../api
:toctree: api
:nosignatures:
:template: classtemplate.rst

392
docs/source-fabric/conf.py Normal file
View File

@ -0,0 +1,392 @@
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
import glob
import inspect
import os
import shutil
import sys
import lai_sphinx_theme
import lightning
_PATH_HERE = os.path.abspath(os.path.dirname(__file__))
_PATH_ROOT = os.path.realpath(os.path.join(_PATH_HERE, "..", ".."))
sys.path.insert(0, os.path.abspath(_PATH_ROOT))
SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True))
# -- Project information -----------------------------------------------------
# this name shall match the project name in Github as it is used for linking to code
project = "lightning"
copyright = lightning.__copyright__
author = lightning.__author__
# The short X.Y version
version = lightning.__version__
# The full version, including alpha/beta/rc tags
release = lightning.__version__
# Options for the linkcode extension
# ----------------------------------
github_user = "Lightning-AI"
github_repo = project
# -- Project documents -------------------------------------------------------
# def _transform_changelog(path_in: str, path_out: str) -> None:
# with open(path_in) as fp:
# chlog_lines = fp.readlines()
# # enrich short subsub-titles to be unique
# chlog_ver = ""
# for i, ln in enumerate(chlog_lines):
# if ln.startswith("## "):
# chlog_ver = ln[2:].split("-")[0].strip()
# elif ln.startswith("### "):
# ln = ln.replace("###", f"### {chlog_ver} -")
# chlog_lines[i] = ln
# with open(path_out, "w") as fp:
# fp.writelines(chlog_lines)
# export the READme
# _convert_markdown(os.path.join(_PATH_ROOT, "README.md"), "readme.md")
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = "4.5"
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
# 'sphinxcontrib.mockautodoc', # raises error: directive 'automodule' is already registered ...
# 'sphinxcontrib.fulltoc', # breaks pytorch-theme with unexpected kw argument 'titles_only'
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx_toolbox.collapse",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx.ext.imgmath",
"sphinx.ext.autosectionlabel",
"myst_parser",
"sphinx_autodoc_typehints",
"sphinx_copybutton",
"sphinx_paramlinks",
"sphinx_togglebutton",
"lai_sphinx_theme.extensions.lightning",
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# myst-parser, forcing to parse all html pages with mathjax
# https://github.com/executablebooks/MyST-Parser/issues/394
myst_update_mathjax = False
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html?highlight=anchor#auto-generated-header-anchors
myst_heading_anchors = 3
# https://berkeley-stat159-f17.github.io/stat159-f17/lectures/14-sphinx..html#conf.py-(cont.)
# https://stackoverflow.com/questions/38526888/embed-ipython-notebook-in-sphinx-document
# I execute the notebooks manually in advance. If notebooks test the code,
# they should be run at build time.
nbsphinx_execute = "never"
nbsphinx_allow_errors = True
nbsphinx_requirejs_path = ""
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
# source_suffix = ['.rst', '.md', '.ipynb']
source_suffix = {
".rst": "restructuredtext",
".txt": "markdown",
".md": "markdown",
".ipynb": "nbsphinx",
}
# The master toctree document.
master_doc = "index"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# 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"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [
"PULL_REQUEST_TEMPLATE.md",
"**/README.md/*",
"readme.md",
"_templates",
"code_samples/convert_pl_to_app/requirements.txt",
"**/_static/*",
]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "lai_sphinx_theme"
html_theme_path = [os.environ.get("LIT_SPHINX_PATH", lai_sphinx_theme.get_html_theme_path())]
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"pytorch_project": lightning.__homepage__,
"analytics_id": "G-D3Q2ESCTZR",
"canonical_url": lightning.__homepage__,
"collapse_navigation": False,
"display_version": True,
"logo_only": False,
}
html_favicon = "_static/images/icon.svg"
# 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 = ["_templates", "_static"]
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = project + "-doc"
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# 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",
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, project + ".tex", project + " Documentation", author, "manual"),
]
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, project, project + " Documentation", [author], 1)]
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
project,
project + " Documentation",
author,
project,
lightning.__docs__,
"Miscellaneous",
),
]
# -- Options for Epub output -------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''
# A unique identification for the text.
#
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ["search.html"]
# -- Extension configuration -------------------------------------------------
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"torch": ("https://pytorch.org/docs/stable/", None),
"pytorch_lightning": ("https://pytorch-lightning.readthedocs.io/en/stable/", None),
}
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
def setup(app):
# this is for hiding doctest decoration,
# see: http://z4r.github.io/python/2011/12/02/hides-the-prompts-and-output/
app.add_js_file("copybutton.js")
app.add_css_file("main.css")
# Ignoring Third-party packages
# https://stackoverflow.com/questions/15889621/sphinx-how-to-exclude-imports-in-automodule
def _package_list_from_file(file):
list_pkgs = []
with open(file) as fp:
lines = fp.readlines()
for ln in lines:
found = [ln.index(ch) for ch in list(",=<>#") if ch in ln]
pkg = ln[: min(found)] if found else ln
if pkg.rstrip():
list_pkgs.append(pkg.rstrip())
return list_pkgs
# define mapping from PyPI names to python imports
PACKAGE_MAPPING = {
"PyYAML": "yaml",
}
MOCK_PACKAGES = []
if SPHINX_MOCK_REQUIREMENTS:
# mock also base packages when we are on RTD since we don't install them there
MOCK_PACKAGES += _package_list_from_file(os.path.join(_PATH_ROOT, "requirements.txt"))
MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES]
autodoc_mock_imports = MOCK_PACKAGES
# Resolve function
# This function is used to populate the (source) links in the API
def linkcode_resolve(domain, info):
def find_source():
# try to find the file and line number, based on code from numpy:
# https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L286
obj = sys.modules[info["module"]]
for part in info["fullname"].split("."):
obj = getattr(obj, part)
fname = inspect.getsourcefile(obj)
# https://github.com/rtfd/readthedocs.org/issues/5735
if any(s in fname for s in ("readthedocs", "rtfd", "checkouts")):
# /home/docs/checkouts/readthedocs.org/user_builds/pytorch_lightning/checkouts/
# devel/pytorch_lightning/utilities/cls_experiment.py#L26-L176
path_top = os.path.abspath(os.path.join("..", "..", ".."))
fname = os.path.relpath(fname, start=path_top)
else:
# Local build, imitate master
fname = "master/" + os.path.relpath(fname, start=os.path.abspath(".."))
source, lineno = inspect.getsourcelines(obj)
return fname, lineno, lineno + len(source) - 1
if domain != "py" or not info["module"]:
return None
try:
filename = "%s#L%d-L%d" % find_source()
except Exception:
filename = info["module"].replace(".", "/") + ".py"
# import subprocess
# tag = subprocess.Popen(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE,
# universal_newlines=True).communicate()[0][:-1]
branch = filename.split("/")[0]
# do mapping from latest tags to master
branch = {"latest": "master", "stable": "master"}.get(branch, branch)
filename = "/".join([branch] + filename.split("/")[1:])
return f"https://github.com/{github_user}/{github_repo}/blob/{filename}"
autosummary_generate = True
autodoc_member_order = "groupwise"
autoclass_content = "both"
# the options are fixed and will be soon in release,
# see https://github.com/sphinx-doc/sphinx/issues/5459
autodoc_default_options = {
"members": None,
"methods": None,
# 'attributes': None,
"special-members": "__call__",
"exclude-members": "_abc_impl",
"show-inheritance": True,
"private-members": True,
"noindex": True,
}
# Sphinx will add “permalinks” for each heading and description environment as paragraph signs that
# become visible when the mouse hovers over them.
# This value determines the text for the permalink; it defaults to "¶". Set it to None or the empty
# string to disable permalinks.
# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_permalinks
# html_add_permalinks = "¶"
# True to prefix each section label with the name of the document it is in, followed by a colon.
# For example, index:Introduction for a section called Introduction that appears in document index.rst.
# Useful for avoiding ambiguity when the same section heading appears in different documents.
# http://www.sphinx-doc.org/en/master/usage/extensions/autosectionlabel.html
autosectionlabel_prefix_document = True
# only run doctests marked with a ".. doctest::" directive
doctest_test_doctest_blocks = ""
doctest_global_setup = """
import importlib
import os
import lightning as L
from lightning_utilities.core.imports import package_available
from lightning import LightningModule, Trainer
from lightning.fabric.loggers.tensorboard import _TENSORBOARD_AVAILABLE, _TENSORBOARDX_AVAILABLE
_TORCHVISION_AVAILABLE = package_available("torchvision")
"""
coverage_skip_undoc_in_source = True
# skip false positive linkcheck errors from anchors
linkcheck_anchors = False
# ignore all links in any CHANGELOG file
linkcheck_exclude_documents = [r"^(.*\/)*CHANGELOG.*$"]

View File

@ -20,7 +20,7 @@ Here are five easy steps to let :class:`~lightning.fabric.fabric.Fabric` scale y
fabric.launch()
**Step 3:** Call :meth:`~lightning_fabric.fabric.Fabric.setup` on each model and optimizer pair and :meth:`~lightning_fabric.fabric.Fabric.setup_dataloaders` on all your data loaders.
**Step 3:** Call :meth:`~lightning.fabric.fabric.Fabric.setup` on each model and optimizer pair and :meth:`~lightning_fabric.fabric.Fabric.setup_dataloaders` on all your data loaders.
.. code-block:: python

View File

@ -7,7 +7,7 @@ Organize Your Code
Any raw PyTorch can be converted to Fabric with zero refactoring required, giving maximum flexibility in how you want to organize your projects.
However, when developing a project in a team or sharing the code publicly, it can be beneficial to conform to a standard format of how core pieces of the code are organized.
This is what the :doc:`LightningModule <../../common/lightning_module>` was made for!
This is what the :class:`pytorch_lightning.core.module.LightningModule` was made for!
Here is how you can neatly separate the research code (model, loss, optimization, etc.) from the "trainer" code (training loop, checkpointing, logging, etc.).
@ -62,7 +62,7 @@ Take these main ingredients and put them in a LightningModule:
...
This is a minimal LightningModule, but there are :doc:`many other useful hooks <../../common/lightning_module>` you can use.
This is a minimal :class:`pytorch_lightning.LightningModule`, but there are `many other useful hooks <https://pytorch-lightning.readthedocs.io/en/stable/common/lightning_module.html#hooks>`_ you can use.
----

View File

@ -60,20 +60,20 @@ Fabric is the fast and lightweight way to scale PyTorch models without boilerpla
Why Fabric?
***********
Fabric differentiates itself from a fully-fledged trainer like :doc:`Lightning Trainer <../common/trainer>` in these key aspects:
Fabric differentiates itself from a fully-fledged trainer like Lightning :class:`pytorch_lightning.Trainer` in these key aspects:
**Fast to implement**
There is no need to restructure your code: Just change a few lines in the PyTorch script and you'll be able to leverage Fabric features.
**Maximum Flexibility**
Write your own training and/or inference logic down to the individual optimizer calls.
You aren't forced to conform to a standardized epoch-based training loop like the one in :doc:`Lightning Trainer <../common/trainer>`.
You aren't forced to conform to a standardized epoch-based training loop like the one in Lightning :class:`pytorch_lightning.Trainer`.
You can do flexible iteration based training, meta-learning, cross-validation and other types of optimization algorithms without digging into framework internals.
This also makes it super easy to adopt Fabric in existing PyTorch projects to speed-up and scale your models without the compromise on large refactors.
Just remember: With great power comes a great responsibility.
**Maximum Control**
The :doc:`Lightning Trainer <../common/trainer>` has many built in features to make research simpler with less boilerplate, but debugging it requires some familiarity with the framework internals.
The Lightning :class:`pytorch_lightning.Trainer` has many built-in features to make research simpler with less boilerplate, but debugging it requires some familiarity with the framework internals.
In Fabric, everything is opt-in. Think of it as a toolbox: You take out the tools (Fabric functions) you need and leave the other ones behind.
This makes it easier to develop and debug your PyTorch code as you gradually add more features to it.
Fabric provides important tools to remove undesired boilerplate code (distributed, hardware, checkpoints, logging, ...), but leaves the design and orchestration fully up to you.
@ -344,7 +344,7 @@ API
.. displayitem::
:header: Full API Reference
:description: Reference of all public classes, methods and functions. Useful for developers.
:button_link: api/api_reference.html
:button_link: api_reference.html
:col_css: col-md-4
:height: 150
:tag: intermediate

View File

@ -0,0 +1,2 @@
.. _PyTorchJob: https://www.kubeflow.org/docs/components/training/pytorch/
.. _Kubeflow: https://www.kubeflow.org

View File

@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=../build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd

View File

@ -10,5 +10,5 @@
..
autogenerated from source/_templates/classtemplate.rst
autogenerated from source-pytorch/_templates/classtemplate.rst
note it does not have :inherited-members:

View File

@ -74,7 +74,7 @@ for md in glob.glob(os.path.join(PATH_ROOT, ".github", "*.md")):
shutil.copy(md, os.path.join(PATH_HERE, FOLDER_GENERATED, os.path.basename(md)))
# copy also the changelog
_transform_changelog(
os.path.join(PATH_ROOT, "src", "lightning", "pytorch", "CHANGELOG.md"),
os.path.join(PATH_ROOT, "src", "lightning", "fabric", "CHANGELOG.md"),
os.path.join(PATH_HERE, FOLDER_GENERATED, "CHANGELOG.md"),
)
@ -162,7 +162,7 @@ master_doc = "index"
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@ -396,9 +396,7 @@ from torch.utils.data import IterableDataset, DataLoader, Dataset
from lightning.pytorch import LightningDataModule, LightningModule, Trainer, seed_everything
from lightning.pytorch.callbacks import Callback
from lightning.pytorch.cli import _JSONARGPARSE_SIGNATURES_AVAILABLE as _JSONARGPARSE_AVAILABLE
from lightning.pytorch.utilities import (
_TORCHVISION_AVAILABLE,
)
from lightning.pytorch.utilities import _TORCHVISION_AVAILABLE
from lightning.fabric.loggers.tensorboard import _TENSORBOARD_AVAILABLE, _TENSORBOARDX_AVAILABLE
from lightning.pytorch.loggers.neptune import _NEPTUNE_AVAILABLE
from lightning.pytorch.loggers.comet import _COMET_AVAILABLE

View File

@ -174,7 +174,6 @@ Current Lightning Users
common/lightning_module
common/trainer
fabric/fabric
.. toctree::
:maxdepth: 2
@ -232,7 +231,6 @@ Current Lightning Users
Inference <deploy/production_intermediate>
IPU <accelerators/ipu>
Lightning CLI <cli/lightning_cli>
Lightning Fabric <fabric/fabric>
LightningDataModule <data/datamodule>
LightningModule <common/lightning_module>
Lightning Transformers <https://pytorch-lightning.readthedocs.io/en/stable/ecosystem/transformers.html>

View File

@ -23,14 +23,6 @@ Learn all the ways of owning your raw PyTorch loops with Lighting.
:height: 150
:tag: advanced
.. displayitem::
:header: Use a Raw PyTorch Loop
:description: Migrate complex PyTorch projects to Lightning and push bleeding-edge research with the raw PyTorch loop.
:col_css: col-md-4
:button_link: ../fabric/fabric.html
:height: 150
:tag: advanced
.. raw:: html
</div>

View File

@ -19,14 +19,6 @@ Use a pure PyTorch training loop
:height: 150
:tag: advanced
.. displayitem::
:header: Use a Raw PyTorch Loop
:description: Migrate complex PyTorch projects to Lightning and push bleeding-edge research with the raw PyTorch loop.
:col_css: col-md-4
:button_link: ../fabric/fabric.html
:height: 150
:tag: advanced
.. raw:: html
</div>

View File

@ -325,15 +325,6 @@ For certain types of work at the bleeding-edge of research, Lightning offers exp
:image_height: 220px
:height: 320
.. displayitem::
:header: Lightning Fabric
:description: Full control over loop for migrating complex PyTorch projects.
:col_css: col-md-4
:image_center: https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/lite.png
:button_link: ../fabric/fabric.html
:image_height: 220px
:height: 320
.. raw:: html
</div>
@ -371,14 +362,6 @@ Depending on your use case, you might want to check one of these out next.
:height: 180
:tag: basic
.. displayitem::
:header: I need my raw PyTorch Loop
:description: Expert-level control for researchers working on the bleeding-edge
:col_css: col-md-3
:button_link: ../fabric/fabric.html
:height: 180
:tag: expert
.. displayitem::
:header: Deploy your model
:description: Learn how to predict or put your model into production

View File

@ -1,6 +1,3 @@
-r ../docs.txt
ipython[notebook]
ipython_genutils
lai-sphinx-theme

View File

@ -0,0 +1,4 @@
-r ../docs.txt
lai-sphinx-theme
tensorboard