Skip to content

Commit

Permalink
Fix ReduceBarriers to be applied before truncation (Qiskit#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseclectic committed Apr 20, 2020
1 parent d76c146 commit 16174eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/controllers/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "framework/results/experiment_data.hpp"
#include "noise/noise_model.hpp"
#include "transpile/circuitopt.hpp"
#include "transpile/basic_opts.hpp"
#include "transpile/truncate_qubits.hpp"


Expand Down Expand Up @@ -628,16 +629,23 @@ ExperimentResult Controller::execute_circuit(Circuit &circ,
// Execute in try block so we can catch errors and return the error message
// for individual circuit failures.
try {

// Remove barriers from circuit
Transpile::ReduceBarrier barrier_pass;
barrier_pass.optimize_circuit(circ, noise, circ.opset(), data);

// Truncate unused qubits from circuit and noise model
if (truncate_qubits_) {
Transpile::TruncateQubits truncate_pass;
truncate_pass.set_config(config);
truncate_pass.optimize_circuit(circ, noise, Operations::OpSet(), data);
truncate_pass.optimize_circuit(circ, noise, circ.opset(), data);
}

// set parallelization for this circuit
if (!explicit_parallelization_) {
set_parallelization_circuit(circ, noise);
}

// Single shot thread execution
if (parallel_shots_ <= 1) {
auto tmp_data = run_circuit(circ, noise, config, circ.shots, circ.seed);
Expand Down
2 changes: 0 additions & 2 deletions src/controllers/qasm_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "simulators/stabilizer/stabilizer_state.hpp"
#include "simulators/statevector/statevector_state.hpp"
#include "simulators/superoperator/superoperator_state.hpp"
#include "transpile/basic_opts.hpp"
#include "transpile/delay_measure.hpp"
#include "transpile/fusion.hpp"

Expand Down Expand Up @@ -274,7 +273,6 @@ class QasmController : public Base::Controller {
// Constructor
//-------------------------------------------------------------------------
QasmController::QasmController() {
add_circuit_optimization(Transpile::ReduceBarrier());
add_circuit_optimization(Transpile::DelayMeasure());
add_circuit_optimization(Transpile::Fusion());
}
Expand Down

0 comments on commit 16174eb

Please sign in to comment.