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

Remove CompileData.processed_function #127

Merged
merged 3 commits into from
Apr 4, 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
19 changes: 3 additions & 16 deletions thunder/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,7 @@ def __init__(
self.additional_return_names = None
self.num_constant_args = 0

self._processed_function: Callable

assert disable_preprocessing, "please use thunder.jit if you need preprocessing"
self._processed_function = fn

# Disallows overwriting processed_function
@property
def processed_function(self):
return self._processed_function
assert disable_preprocessing, "please use thunder.compile if you need preprocessing"


# Common UX functions
Expand Down Expand Up @@ -665,7 +657,7 @@ def _create_callable(
post_optimization_transforms: list[Callable] = [],
_using_grad_transform: bool = False,
) -> Callable:
@wraps(cd.processed_function)
@wraps(cd.fn)
def _fn(*args, **kwargs) -> tuple[Any, list[TraceCtx]]:
cs.last_trace_host_start = time.time_ns()
cs.calls += 1
Expand Down Expand Up @@ -728,11 +720,7 @@ def _fn(*args, **kwargs) -> tuple[Any, list[TraceCtx]]:
cs.last_trace_cache_stop = time.time_ns()

# Applies the autocast transform if PyTorch's autocast behavior is enabled
processed_function = (
cd.processed_function
if not is_autocast_enabled
else autocast(cd.processed_function, dtype=autocast_thunder_dtype)
)
processed_function = cd.fn if not is_autocast_enabled else autocast(cd.fn, dtype=autocast_thunder_dtype)

# Resets use of compile flags
cs.last_compile_reasons = defaultdict(list)
Expand Down Expand Up @@ -839,7 +827,6 @@ def _fn(*args, **kwargs) -> tuple[Any, list[TraceCtx]]:
return result

# NOTE is_module is False
_fn._pfn = cd.processed_function
_fn._lc_cd = cd
_fn._lc_cs = cs
_fn._lc_transforms = transforms
Expand Down
Loading