Add the pytest function for MPS in cuquantum.
This commit is contained in:
@@ -2,14 +2,15 @@ import cupy as cp
|
||||
import numpy as np
|
||||
|
||||
from cuquantum import cutensornet as cutn
|
||||
from QiboCircuitConvertor import QiboCircuitToEinsum
|
||||
from MPSUtils import get_initial_mps, apply_gate
|
||||
from qibotn.QiboCircuitConvertor import QiboCircuitToEinsum
|
||||
from qibotn.MPSUtils import get_initial_mps, apply_gate
|
||||
|
||||
|
||||
class QiboCircuitToMPS:
|
||||
def __init__(self,circ_qibo, gate_algo, dtype = 'complex128',rand_seed=0,):
|
||||
def __init__(self, circ_qibo, gate_algo, dtype='complex128', rand_seed=0,):
|
||||
np.random.seed(rand_seed)
|
||||
cp.random.seed(rand_seed)
|
||||
|
||||
|
||||
self.num_qubits = circ_qibo.nqubits
|
||||
self.handle = cutn.create()
|
||||
self.options = {'handle': self.handle}
|
||||
@@ -20,7 +21,8 @@ class QiboCircuitToMPS:
|
||||
for (gate, qubits) in circuitconvertor.gate_tensors:
|
||||
# mapping from qubits to qubit indices
|
||||
# apply the gate in-place
|
||||
apply_gate(self.mps_tensors, gate, qubits, algorithm=gate_algo, options=self.options)
|
||||
apply_gate(self.mps_tensors, gate, qubits,
|
||||
algorithm=gate_algo, options=self.options)
|
||||
|
||||
def __del__(self):
|
||||
cutn.destroy(self.handle)
|
||||
|
||||
Reference in New Issue
Block a user