-
Notifications
You must be signed in to change notification settings - Fork 81
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
Unrolling tensor subclasses in fwd/bwd split #1489
Unrolling tensor subclasses in fwd/bwd split #1489
Conversation
Signed-off-by: Masaki Kozuki <[email protected]>
Signed-off-by: Masaki Kozuki <[email protected]>
Signed-off-by: Masaki Kozuki <[email protected]>
Signed-off-by: Masaki Kozuki <[email protected]>
Signed-off-by: Masaki Kozuki <[email protected]>
Signed-off-by: Masaki Kozuki <[email protected]>
@@ -637,7 +637,7 @@ def _convert_pytorchfunc_to_thundertrace( | |||
trace = TraceCtx() | |||
trace.bound_symbols.extend(active_jit_ctx.computation_trace.pop_scope()) | |||
func_result = unwrap(wrapped_func_result) | |||
if shallow_copy_output: | |||
if shallow_copy_output and not trace.bound_symbols: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy from #1485
def _transpose_grad(a: TensorLike, /, dim0: int, dim1: int) -> TensorLike: | ||
fwd = transpose(a, dim0, dim1) | ||
g = get_grad(fwd) | ||
a_grad = transpose(g, dim0, dim1) | ||
put_grad(a, a_grad) | ||
return fwd | ||
|
||
|
||
register_grad(transpose, _transpose_grad) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rel: #1487
needed to avoid prims.permute
Signed-off-by: Masaki Kozuki <[email protected]>
Signed-off-by: Masaki Kozuki <[email protected]>
for more information, see https://pre-commit.ci
@@ -269,3 +266,5 @@ def test_torchao_float8_linear(executor, device, _): | |||
|
|||
jitted = executor.make_callable(fp8_model) | |||
actual = jitted(x) | |||
|
|||
torch.testing.assert_close(actual, expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Masaki Kozuki <[email protected]>
for more information, see https://pre-commit.ci
06ee30e
into
crpa/subclass-torchao_float8tensor
Signed-off-by: Masaki Kozuki <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
What does this PR do?
In #1415 and #1394, tensor subclasses and their
__torch_dispatch__
are unrolled before forward-backward split.It turned out that we want to postpone it in the split as the unrolling seems to be harmful to backward generation.
TODO
note: pytorch/ao#1339 is used