Skip to content

Commit

Permalink
Remove CompileData.processed_function (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
carmocca authored Apr 4, 2024
1 parent c915335 commit 5c86534
Showing 1 changed file with 3 additions and 16 deletions.
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

0 comments on commit 5c86534

Please sign in to comment.