Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Add safeguard barriers in AE and MLAE #842

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SPHINXOPTS =

.PHONY: lint style test test_ci spell copyright html coverage coverage_erase

all_check: spell style lint copyright html
all_check: spell style lint html

lint:
pylint -rn --ignore=gauopen qiskit/aqua qiskit/chemistry qiskit/finance qiskit/ml qiskit/optimization test tools
Expand Down
3 changes: 3 additions & 0 deletions qiskit/aqua/algorithms/amplitude_estimators/mlae.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def construct_circuits(self, measurement: bool = False) -> List[QuantumCircuit]:
self.q_factory.build_power(qc_k, q, k, q_aux)

if measurement:
# real hardware can currently not handle operations after measurements, which might
# happen if the circuit gets transpiled, hence we're adding a safeguard-barrier
qc_k.barrier()
qc_k.measure(q[self.i_objective], c[0])

self._circuits += [qc_k]
Expand Down
7 changes: 5 additions & 2 deletions qiskit/aqua/circuits/phase_estimation_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2019.
# (C) Copyright IBM 2018, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -29,6 +29,7 @@ class PhaseEstimationCircuit:
"""
Quantum Phase Estimation Circuit.
"""

def __init__(
self,
operator=None,
Expand Down Expand Up @@ -213,7 +214,9 @@ def construct_circuit(
if measurement:
c_ancilla = ClassicalRegister(self._num_ancillae, name='ca')
qc.add_register(c_ancilla)
# qc.barrier(a)
# real hardware can currently not handle operations after measurements, which might
# happen if the circuit gets transpiled, hence we're adding a safeguard-barrier
qc.barrier()
qc.measure(a, c_ancilla)

self._circuit = qc
Expand Down