Skip to content

Commit

Permalink
Respect max_experiments in QuantumInstance BackendV1 path (Qiskit#6391)
Browse files Browse the repository at this point in the history
* Respect max_experiments in QuantumInstance BackendV1 path

In Qiskit#6299 support was fixed for strict BackendV1 backends that only take
QuantumCircuit objects (instead of qobj) for the input. That was fixed
by adding a parallel path when running with a new backend. However that
parallel path wasn't identical and was missing the support the qobj path
had for splitting an algorithm run into multiple jobs if the backend if
the number of circuits was greater than the max_experiments set in the
backend. This would result on some providers' backends, such as ionq and
aqt, both of which have max_experiments set to 1. This commit fixes this
issue by splitting the circuits list into smaller sublists when the
len(circuits) > max_experiments (or the old env var, which we should
change the name of at some point).

* Fix issues with results and split circuits path

* Fix copy paste issue

* Update qiskit/utils/run_circuits.py

* Add release notes

* Fix whitespace

Co-authored-by: Kevin Krsulich <[email protected]>
Co-authored-by: Manoel Marques <[email protected]>
  • Loading branch information
3 people authored May 14, 2021
1 parent 4c79ef3 commit 9cbe14b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/python/algorithms/test_backendv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ def test_run_circuit_oracle(self):
result = grover.amplify(problem)
self.assertIn(result.top_measurement, ["11"])

def test_run_circuit_oracle_single_experiment_backend(self):
"""Test execution with a quantum circuit oracle"""
oracle = QuantumCircuit(2)
oracle.cz(0, 1)
problem = AmplificationProblem(oracle, is_good_state=["11"])
backend = self._provider.get_backend("fake_yorktown")
backend._configuration.max_experiments = 1
qi = QuantumInstance(
self._provider.get_backend("fake_yorktown"), seed_simulator=12, seed_transpiler=32
)
grover = Grover(quantum_instance=qi)
result = grover.amplify(problem)
self.assertIn(result.top_measurement, ["11"])

def test_measurement_error_mitigation_with_vqe(self):
"""measurement error mitigation test with vqe"""
try:
Expand Down

0 comments on commit 9cbe14b

Please sign in to comment.