Skip to content

Commit

Permalink
[docs] Add thunder.dynamo.ThunderCompiler (#1263)
Browse files Browse the repository at this point in the history
Signed-off-by: Masaki Kozuki <[email protected]>
  • Loading branch information
crcrpar authored Oct 7, 2024
1 parent b4ca020 commit 5dcbc55
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ API reference
reference/torch/index
reference/extend/index
reference/transforms/index
reference/dynamo/index


Indices and tables
Expand Down
9 changes: 9 additions & 0 deletions docs/source/reference/dynamo/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. module:: thunder.dynamo

thunder.dynamo
==============

.. autosummary::
:toctree:

ThunderCompiler
18 changes: 11 additions & 7 deletions thunder/dynamo/compiler.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from __future__ import annotations
from functools import partial
from looseversion import LooseVersion
from typing import TYPE_CHECKING
import warnings

import torch
import warnings

from thunder.core.baseutils import run_once

from thunder.dynamo.utils import SubgraphInfo, recompile_graph
from thunder.dynamo.utils import recompile_graph
from thunder.dynamo.splitter import _splitter

if TYPE_CHECKING:
from thunder.dynamo.utils import SubgraphInfo


@run_once
def _warn_thunder_compiler():
Expand All @@ -21,12 +25,12 @@ def _warn_thunder_compiler():
class ThunderCompiler:
def __init__(self, **thunder_options):
"""
A class that compiles a `fx.GraphModule` to a `thunder.ThunderModule`.
This class is meant to be used as a backend for the `torch.compile`
A class that compiles a :class:`torch.fx.GraphModule` to a :class:`thunder.ThunderModule`.
This class is meant to be used as a backend for the :func:`torch.compile`
function.
Keyword arguments:
thunder_options: a dictionary of options to pass to `thunder.jit`. Besides all the arguments to `thunder.jit`,
thunder_options: a dictionary of options to pass to :func:`thunder.jit`. Besides all the arguments to :func:`thunder.jit`,
it accepts `torch_inductor_options` which are passed to `torch.compile` if part of the graph
is not supported by thunder.
Expand All @@ -44,7 +48,7 @@ def __init__(self, **thunder_options):
... return x - 1
>>> out = func(x)
"""
from thunder import ThunderModule, jit
from thunder import jit

_warn_thunder_compiler()

Expand Down

0 comments on commit 5dcbc55

Please sign in to comment.