aten._has_compatible_shallow_copy_type', overload='default' dispatcher failed for LinearActivationQuantizedTensor in inference mode
Describe the bug: Reproducer:
import copy
import torch
import torch.nn as nn
from torchao.quantization import quantize_
from transformers import (
AutoConfig,
AutoModelForCausalLM,
AutoTokenizer,
GenerationConfig,
)
from torchao.quantization import quantize_, Int8DynamicActivationInt8WeightConfig
from transformers import TorchAoConfig
qconfig = TorchAoConfig(Int8DynamicActivationInt8WeightConfig())
model_id = "meta-llama/Llama-3.1-8B-Instruct"
load_dtype = torch.bfloat16
device = "cuda"
config = AutoConfig.from_pretrained(model_id, trust_remote_code=False)
with torch.inference_mode():
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=load_dtype,
config=config,
low_cpu_mem_usage=True,
trust_remote_code=False,
device_map=device,
quantization_config=qconfig,
attn_implementation="sdpa",
)
Error Information:
File "/ao/torchao/utils.py", line 684, in _dispatch__torch_dispatch__
raise NotImplementedError(
NotImplementedError: LinearActivationQuantizedTensor dispatch: attempting to run unimplemented operator/function: func=<OpOverload(op='aten._has_compatible_shallow_copy_type', overload='default')>, types=(<class 'torchao.quantization.linear_activation_quantized_tensor.LinearActivationQuantizedTensor'>,), arg_types=(<class 'torchao.quantization.linear_activation_quantized_tensor.LinearActivationQuantizedTensor'>, <class 'torchao.quantization.linear_activation_quantized_tensor.LinearActivationQuantizedTensor'>), kwarg_types={}
Versions:
Collecting environment information...
PyTorch version: 2.10.0+cu130
Is debug build: False
CUDA used to build PyTorch: 13.0
ROCM used to build PyTorch: N/A
OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.35
Python version: 3.10.19 | packaged by conda-forge | (main, Oct 22 2025, 22:29:10) [GCC 14.3.0] (64-bit runtime)
Python platform: Linux-5.15.0-164-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to:
GPU models and configuration:
GPU 0: NVIDIA GeForce RTX 5090 D
GPU 1: NVIDIA GeForce RTX 5090 D
Nvidia driver version: 580.105.08
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A
fixed https://github.com/pytorch/ao/pull/4098
Hey! I may be able to help with this bug.
I build custom fixes for Python projects and automation systems.
If you'd like help resolving this issue quickly feel free to reach out.
Happy to take a look 👍
can you try using Int8DynamicActivationInt8WeightConfig(version=2) to see if it works
@jerryzh168 Thank you for your reply. The default version is version 1 in TorchAO, so we both support the two version. It can execute normally when provided with Int8DynamicActivationInt8WeightConfig(version=2).