Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
This commit fixes the merge conflicts from backporting Qiskit#6391 to
stable/0.17. The tests added in Qiskit#6391 are just removed because they
can't actually run without Qiskit#6286 which isn't backportable.
  • Loading branch information
mtreinish committed May 14, 2021
1 parent 080ad6e commit 48d2918
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 110 deletions.
49 changes: 0 additions & 49 deletions qiskit/utils/run_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,6 @@ def run_circuits(circuits: Union[QuantumCircuit, List[QuantumCircuit]],
run_config = run_config or {}
with_autorecover = not is_simulator_backend(backend)

<<<<<<< HEAD
job, job_id = _safe_submit_circuits(circuits,
backend,
qjob_config=qjob_config,
backend_options=backend_options,
noise_config=noise_config,
run_config=run_config)
result = None
=======
if MAX_CIRCUITS_PER_JOB is not None:
max_circuits_per_job = int(MAX_CIRCUITS_PER_JOB)
else:
Expand Down Expand Up @@ -467,7 +458,6 @@ def run_circuits(circuits: Union[QuantumCircuit, List[QuantumCircuit]],
job_ids = [job_id]
split_circuits = [circuits]
results = []
>>>>>>> 9d4bb91b8... Respect max_experiments in QuantumInstance BackendV1 path (#6391)
if with_autorecover:
logger.info("Backend status: %s", backend.status())
logger.info("There are %s jobs are submitted.", len(jobs))
Expand Down Expand Up @@ -496,19 +486,7 @@ def run_circuits(circuits: Union[QuantumCircuit, List[QuantumCircuit]],
logger.info("Job id: %s, status: %s", job_id, job_status)
if job_callback is not None:
job_callback(job_id, job_status, queue_position, job)
<<<<<<< HEAD
break
if job_status == JobStatus.QUEUED and hasattr(job, queue_position):
queue_position = job.queue_position()
logger.info("Job id: %s is queued at position %s", job_id, queue_position)
else:
logger.info("Job id: %s, status: %s", job_id, job_status)
if job_callback is not None:
job_callback(job_id, job_status, queue_position, job)
time.sleep(qjob_config['wait'])
=======
time.sleep(qjob_config["wait"])
>>>>>>> 9d4bb91b8... Respect max_experiments in QuantumInstance BackendV1 path (#6391)

# get result after the status is DONE
if job_status == JobStatus.DONE:
Expand All @@ -519,32 +497,6 @@ def run_circuits(circuits: Union[QuantumCircuit, List[QuantumCircuit]],
logger.info("COMPLETED the %s-th job, job id: %s", idx, job_id)
break

<<<<<<< HEAD
logger.warning("FAILURE: Job id: %s", job_id)
logger.warning("Job (%s) is completed anyway, retrieve result "
"from backend again.", job_id)
job = backend.retrieve_job(job_id)
break
# for other cases, resubmit the circuit until the result is available.
# since if there is no result returned, there is no way algorithm can do any process
if job_status == JobStatus.CANCELLED:
logger.warning("FAILURE: Job id: %s is cancelled. Re-submit the circuits.",
job_id)
elif job_status == JobStatus.ERROR:
logger.warning("FAILURE: Job id: %s encounters the error. "
"Error is : %s. Re-submit the circuits.",
job_id, job.error_message())
else:
logging.warning("FAILURE: Job id: %s. Unknown status: %s. "
"Re-submit the circuits.", job_id, job_status)

job, job_id = _safe_submit_circuits(circuits,
backend,
qjob_config=qjob_config,
backend_options=backend_options,
noise_config=noise_config,
run_config=run_config)
=======
logger.warning("FAILURE: Job id: %s", job_id)
logger.warning(
"Job (%s) is completed anyway, retrieve result " "from backend again.",
Expand Down Expand Up @@ -580,7 +532,6 @@ def run_circuits(circuits: Union[QuantumCircuit, List[QuantumCircuit]],
noise_config=noise_config,
run_config=run_config,
)
>>>>>>> 9d4bb91b8... Respect max_experiments in QuantumInstance BackendV1 path (#6391)
else:
results = []
for job in jobs:
Expand Down
61 changes: 0 additions & 61 deletions test/python/algorithms/test_backendv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,66 +66,5 @@ def test_vqe_qasm(self):
self.assertAlmostEqual(result.eigenvalue.real, -1.86, delta=0.05)


<<<<<<< HEAD
if __name__ == '__main__':
=======
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:
from qiskit.ignis.mitigation.measurement import CompleteMeasFitter
from qiskit.providers.aer import noise
except ImportError as ex:
self.skipTest("Package doesn't appear to be installed. Error: '{}'".format(str(ex)))
return

algorithm_globals.random_seed = 0

# build noise model
noise_model = noise.NoiseModel()
read_err = noise.errors.readout_error.ReadoutError([[0.9, 0.1], [0.25, 0.75]])
noise_model.add_all_qubit_readout_error(read_err)

backend = self._qasm

quantum_instance = QuantumInstance(
backend=backend,
seed_simulator=167,
seed_transpiler=167,
noise_model=noise_model,
measurement_error_mitigation_cls=CompleteMeasFitter,
)

h2_hamiltonian = (
-1.052373245772859 * (I ^ I)
+ 0.39793742484318045 * (I ^ Z)
- 0.39793742484318045 * (Z ^ I)
- 0.01128010425623538 * (Z ^ Z)
+ 0.18093119978423156 * (X ^ X)
)
optimizer = SPSA(maxiter=200)
ansatz = EfficientSU2(2, reps=1)

vqe = VQE(ansatz=ansatz, optimizer=optimizer, quantum_instance=quantum_instance)
result = vqe.compute_minimum_eigenvalue(operator=h2_hamiltonian)
self.assertGreater(quantum_instance.time_taken, 0.0)
quantum_instance.reset_execution_results()
self.assertAlmostEqual(result.eigenvalue.real, -1.86, delta=0.05)


if __name__ == "__main__":
>>>>>>> 9d4bb91b8... Respect max_experiments in QuantumInstance BackendV1 path (#6391)
unittest.main()

0 comments on commit 48d2918

Please sign in to comment.