Skip to content

Commit

Permalink
Changed qiskit backend for tests to ibm_kyoto with single shot after …
Browse files Browse the repository at this point in the history
…removal of simulators
  • Loading branch information
KilianPoirier committed May 28, 2024
1 parent 488e7ec commit 755fa6e
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions src/openqaoa-qiskit/tests/test_qpu_qiskit.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_circuit_angle_assignment_qpu_backend(self):
weights = [1, 1, 1]
gammas = [0, 1 / 8 * np.pi]
betas = [1 / 2 * np.pi, 3 / 8 * np.pi]
shots = 10000
shots = 1

cost_hamil = Hamiltonian(
[PauliOp("ZZ", (0, 1)), PauliOp("ZZ", (1, 2)), PauliOp("ZZ", (0, 2))],
Expand All @@ -94,7 +94,7 @@ def test_circuit_angle_assignment_qpu_backend(self):
variate_params = QAOAVariationalStandardParams(qaoa_descriptor, betas, gammas)

qiskit_device = DeviceQiskit(
"ibmq_qasm_simulator", self.HUB, self.GROUP, self.PROJECT
"ibm_kyoto", self.HUB, self.GROUP, self.PROJECT
)

qiskit_backend = QAOAQiskitQPUBackend(
Expand Down Expand Up @@ -147,7 +147,7 @@ def test_circuit_angle_assignment_qpu_backend_w_hadamard(self):
weights = [1, 1, 1]
gammas = [0, 1 / 8 * np.pi]
betas = [1 / 2 * np.pi, 3 / 8 * np.pi]
shots = 10000
shots = 1

cost_hamil = Hamiltonian(
[PauliOp("ZZ", (0, 1)), PauliOp("ZZ", (1, 2)), PauliOp("ZZ", (0, 2))],
Expand All @@ -159,7 +159,7 @@ def test_circuit_angle_assignment_qpu_backend_w_hadamard(self):
variate_params = QAOAVariationalStandardParams(qaoa_descriptor, betas, gammas)

qiskit_device = DeviceQiskit(
"ibmq_qasm_simulator", self.HUB, self.GROUP, self.PROJECT
"ibm_kyoto", self.HUB, self.GROUP, self.PROJECT
)

qiskit_backend = QAOAQiskitQPUBackend(
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_prepend_circuit(self):
weights = [1, 1, 1]
gammas = [1 / 8 * np.pi]
betas = [1 / 8 * np.pi]
shots = 10000
shots = 1

# Prepended Circuit
prepend_circuit = QuantumCircuit(3)
Expand All @@ -229,7 +229,7 @@ def test_prepend_circuit(self):
variate_params = QAOAVariationalStandardParams(qaoa_descriptor, betas, gammas)

qiskit_device = DeviceQiskit(
"ibmq_qasm_simulator", self.HUB, self.GROUP, self.PROJECT
"ibm_kyoto", self.HUB, self.GROUP, self.PROJECT
)

qiskit_backend = QAOAQiskitQPUBackend(
Expand Down Expand Up @@ -273,7 +273,7 @@ def test_append_circuit(self):
weights = [1, 1, 1]
gammas = [1 / 8 * np.pi]
betas = [1 / 8 * np.pi]
shots = 10000
shots = 1

# Appended Circuit
append_circuit = QuantumCircuit(3)
Expand All @@ -289,7 +289,7 @@ def test_append_circuit(self):
variate_params = QAOAVariationalStandardParams(qaoa_descriptor, betas, gammas)

qiskit_device = DeviceQiskit(
"ibmq_qasm_simulator", self.HUB, self.GROUP, self.PROJECT
"ibm_kyoto", self.HUB, self.GROUP, self.PROJECT
)

qiskit_backend = QAOAQiskitQPUBackend(
Expand Down Expand Up @@ -450,26 +450,36 @@ def test_remote_qubit_overflow(self):

shots = 100

set_of_numbers = np.random.randint(1, 10, 8).tolist()
set_of_numbers = np.random.randint(1, 10, 129).tolist()
qubo = NumberPartition(set_of_numbers).qubo

mixer_hamil = X_mixer_hamiltonian(n_qubits=8)
mixer_hamil = X_mixer_hamiltonian(n_qubits=129)
qaoa_descriptor = QAOADescriptor(qubo.hamiltonian, mixer_hamil, p=1)

# Check the creation of the varitional parms
_ = create_qaoa_variational_params(qaoa_descriptor, "standard", "rand")

qiskit_device = DeviceQiskit("ibm_kyoto", self.HUB, self.GROUP, self.PROJECT)

try:
QAOAQiskitQPUBackend(
qaoa_descriptor, qiskit_device, shots, None, None, True
)
except Exception as e:
self.assertEqual(
str(e),
"There are lesser qubits on the device than the number of qubits required for the circuit.",
)
self.assertRaises(
Exception,
QAOAQiskitQPUBackend,
qaoa_descriptor,
qiskit_device,
shots,
None,
None,
True,
)
# try:
# QAOAQiskitQPUBackend(
# qaoa_descriptor, qiskit_device, shots, None, None, True
# )
# except Exception as e:
# self.assertEqual(
# str(e),
# "There are lesser qubits on the device than the number of qubits required for the circuit.",
# )

@pytest.mark.qpu
def test_integration_on_emulator(self):
Expand All @@ -483,7 +493,7 @@ def test_integration_on_emulator(self):
weights = [1, 1, 1]
gammas = [[1 / 8 * np.pi]]
betas = [[1 / 8 * np.pi]]
shots = 10000
shots = 1

cost_hamil = Hamiltonian(
[PauliOp("ZZ", (0, 1)), PauliOp("ZZ", (1, 2)), PauliOp("ZZ", (0, 2))],
Expand Down Expand Up @@ -520,7 +530,7 @@ def test_remote_integration_qpu_run(self):
weights = [1, 1, 1]
gammas = [[1 / 8 * np.pi]]
betas = [[1 / 8 * np.pi]]
shots = 10000
shots = 1

cost_hamil = Hamiltonian(
[PauliOp("ZZ", (0, 1)), PauliOp("ZZ", (1, 2)), PauliOp("ZZ", (0, 2))],
Expand Down

0 comments on commit 755fa6e

Please sign in to comment.