"""Transformation passes alter the DAG and then return a DAG. They can use properties that have been written to the property set. """ def __init__(self, properties): self.properties = properties def run(self, dag): dag_depth = self.property_set['my depth'] gates = self.properties.gates return dag """ To test your passes you can use the fake backend classes. Your solutions will be tested against Yorktown, Ourense and Melbourne, as well as some internal backends. """ backend = FakeMelbourne() properties = backend.properties() coupling_map = backend.configuration().coupling_map """ You must submit a pass manager which uses at least one pass you have written. Examples of creating more complex pass managers can be seen in qiskit.transpiler.preset_passmanagers""" pass_manager = PassManager() pass_manager.append(TrivialLayout(coupling_map)) pass_manager.append(MyBasicAnalysisPass()) pass_manager.append(MyBasicTransformationPass(properties)) """ This allows us to simulate the noise a real device has, so that you don't have to wait for jobs to complete on the actual backends.""" noise_model = basic_device_noise_model(properties) simulator = Aer.get_backend('qasm_simulator') """ This is the circuit we are going to look at""" qc = QuantumCircuit(2, 2) qc.h(1) qc.measure(0, 0)
#circuit.cu1(pi/8, qreg_q[3], qreg_q[0]) #circuit.cu1(pi/4, qreg_q[3], qreg_q[1]) #circuit.cu1(pi/2, qreg_q[3], qreg_q[2]) #circuit.h(qreg_q[3]) #circuit.draw(output='text') mapping = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ,13] #layout = Layout({qr[i]: mapping[i] for i in range(14)}) list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10] #de=circuit.decompose(); circuit.draw(output='mpl',filename='crosstalkqft.jpg') circuit.qasm(filename='qaoa_10.qasm') print(circuit.depth()) new_circ = transpile(circuit, backend=backend, initial_layout=mapping, routing_method='sabre') #new_circ.draw(output='mpl',filename='crosstalkbase.jpg') new_circ.qasm(filename='crosstalkqft10.qasm') print(new_circ.depth()) dag = circuit_to_dag(new_circ) print(crosstalk_prop) pass_ = CrosstalkAdaptiveSchedule(backend.properties(), crosstalk_prop) print(list) scheduled_dag = pass_.run(dag) scheduled_circuit = dag_to_circuit(scheduled_dag) print(scheduled_circuit.depth()) scheduled_circuit.draw(output='mpl',filename='crosstalkqft.jpg')