Skip to content
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

feat: add fullgraph argument for torch compile #1007

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
8 changes: 7 additions & 1 deletion thunder/executors/torch_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from thunder.executors.passes import update_fusion_call_ctx
from thunder.executors.utils import Region
from thunder.extend import FusionExecutor, register_executor, ImplInfo
from thunder.core.compile_data import get_compile_option

_TORCH_GREATER_EQUAL_2_3 = compare_version("torch", operator.ge, "2.3.0", use_base_version=True)

Expand Down Expand Up @@ -84,7 +85,12 @@ def torch_interpreted_func(*args):
# torch.compile executor"
torch_trace = trace(inline_trace=False)(torch_interpreted_func, *sorted_unique_inputs)
trace_callable = torch_trace.python_callable(include_decorators=False)
compiled_func = torch.compile(trace_callable, fullgraph=True)
torch_compile_fullgraph: None | bool = get_compile_option(
k223kim marked this conversation as resolved.
Show resolved Hide resolved
"torch_compile_fullgraph", "Whether to enable `fullgraph` from `torch.compile`. Defaults to `True`."
)
if torch_compile_fullgraph is None:
torch_compile_fullgraph = True
k223kim marked this conversation as resolved.
Show resolved Hide resolved
compiled_func = torch.compile(trace_callable, fullgraph=torch_compile_fullgraph)
# For each of `@torch.no_grad(), and `torch.autocast(device_type="cpu"|"cuda")` torch.compile
# create caches with a guard for the wrapped function. Since the torch.compile caches are per code object, not
# frame, all the dynamic copies of these context managers share the same code cache.
Expand Down
Loading