From 38f5db0118811c4bfaaa5e43630bf60bd3a7fa1c Mon Sep 17 00:00:00 2001 From: Macpaul Lin Date: Thu, 8 Jan 2026 22:59:48 +0800 Subject: [PATCH] fix(quant_ops): implement torch.Tensor.copy_ in __torch_function__ for QuantizedTensor Signed-off-by: Macpaul Lin --- comfy/quant_ops.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/comfy/quant_ops.py b/comfy/quant_ops.py index 96fd211d5..b6bce4db1 100644 --- a/comfy/quant_ops.py +++ b/comfy/quant_ops.py @@ -128,6 +128,12 @@ except ImportError as e: dtype = kwargs.get("dtype", input_t.dtype) device = kwargs.get("device", input_t.device) return torch.empty(input_t.shape, dtype=dtype, device=device) + + if func is torch.Tensor.copy_: + dst, src = args[:2] + if isinstance(src, cls): + return dst.copy_(src.dequantize(), **kwargs) + return NotImplemented def __torch_dispatch__(self, func, types, args=(), kwargs=None):