From f62d37273f83b8ff18e8482b9ba4af897640ea58 Mon Sep 17 00:00:00 2001 From: Austin Nguyen Date: Mon, 18 Nov 2024 03:09:31 -0800 Subject: [PATCH 1/3] set quantum device batch size --- examples/clifford_qnn/mnist_clifford_qnn.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/clifford_qnn/mnist_clifford_qnn.py b/examples/clifford_qnn/mnist_clifford_qnn.py index 2b7f0a95..445ff2ca 100644 --- a/examples/clifford_qnn/mnist_clifford_qnn.py +++ b/examples/clifford_qnn/mnist_clifford_qnn.py @@ -60,6 +60,7 @@ def forward(self, x, use_qiskit=False): self.q_device, self.encoder, self.q_layer, self.measure, x ) else: + self.q_device = tq.QuantumDevice(n_wires=self.n_wires, bsz=bsz) self.encoder(self.q_device, x) self.q_layer(self.q_device) x = self.measure(self.q_device) From d05420864a0f580a19417eb1551c34999c67e40c Mon Sep 17 00:00:00 2001 From: Austin Nguyen Date: Mon, 18 Nov 2024 03:15:03 -0800 Subject: [PATCH 2/3] import CliffordQuantizer --- torchquantum/operator/op_types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/torchquantum/operator/op_types.py b/torchquantum/operator/op_types.py index bdf35337..98f21c6e 100644 --- a/torchquantum/operator/op_types.py +++ b/torchquantum/operator/op_types.py @@ -7,6 +7,7 @@ from ..macro import C_DTYPE, F_DTYPE from typing import Iterable, Union, List from enum import IntEnum +from torchquantum.util.quantization.clifford_quantization import CliffordQuantizer __all__ = [ "Operator", From 3f7657078e091baee144866364a468fcdacaf019 Mon Sep 17 00:00:00 2001 From: Austin Nguyen Date: Mon, 18 Nov 2024 19:07:45 -0800 Subject: [PATCH 3/3] make import lazy --- torchquantum/operator/op_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchquantum/operator/op_types.py b/torchquantum/operator/op_types.py index 98f21c6e..e005af6d 100644 --- a/torchquantum/operator/op_types.py +++ b/torchquantum/operator/op_types.py @@ -7,7 +7,6 @@ from ..macro import C_DTYPE, F_DTYPE from typing import Iterable, Union, List from enum import IntEnum -from torchquantum.util.quantization.clifford_quantization import CliffordQuantizer __all__ = [ "Operator", @@ -246,6 +245,7 @@ def forward( params = self.params if self.clifford_quantization: + from torchquantum.util.quantization.clifford_quantization import CliffordQuantizer params = CliffordQuantizer.quantize_sse(params) if self.n_wires is None: self.func(q_device, self.wires, params=params, inverse=self.inverse)