Skip to content

The internal torchao tensor subclasses cause errors with torch.compile #1463

Open
@JohnnyRacer

Description

@JohnnyRacer

When I use torch.compile with certain models that cause the following error:

BackendCompilerFailed: backend='inductor' raised:
AssertionError: torch.compile is currently being used with tensor subclass inputs:
<class 'torch._subclasses.fake_tensor.FakeTensor'>,<class 'torch._subclasses.fake_tensor.FakeTensor'>,<class 'torchao.quantization.linear_activation_quantized_tensor.LinearActivationQuantizedTensor'>,<class 'torch._subclasses.fake_tensor.FakeTensor'>,<class 'torchao.quantization.linear_activation_quantized_tensor.LinearActivationQuantizedTensor'>,<class 'torch._subclasses.fake_tensor.FakeTensor'>,<class 'torch._subclasses.fake_tensor.FakeTensor'>,<class 'torch._subclasses.fake_tensor.FakeTensor'>,<class 'torch._subclasses.fake_tensor.FakeTensor'>,<class 'torch._subclasses.fake_tensor.FakeTensor'>,<class 'torch._subclasses.fake_tensor.FakeTensor'>. We are attempting to a compile a graph with two graph outputs
that alias one another, which is currently unsupported in the subclass use case. If you run into this,
please file a github issue

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information

LinearActivationQuantizedTensor and FakeTensor which are tensor subclasses are not supported by torch.compile which raises the errors.

The model compiles correct if the errors are suppressed with the following:

import torch._dynamo
torch._dynamo.config.suppress_errors = True

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions