Package: quantum-isl
Incremental Structure Learning (ISL)An open-source implementation of ISL [1], a circuit recompilation algorithm that finds an approximate representation of
any circuit acting on the |0>|0>...|0> state. Created for the IBM Quantum Awards: Open Sciece Prize 2021. More details of ISL and its use in the Quantum Awards can be found by downloading the submissionhere.[1] B Jaderberg, A Agarwal, K Leonhardt, M Kiffner, D Jaksch, 2020 Quantum Sci. Technol. 5 034015Installing ISLThe best way of installing ISL is throughpip:pip install quantum-islUsing ISLMinimal exampleA circuit can be recompiled and the result accessed with only 3 lines if using the
default settings.fromisl.recompilersimportISLRecompilerfromqiskitimportQuantumCircuit# Setup the circuitqc=QuantumCircuit(3)qc.rx(1.23,0)qc.cx(0,1)qc.ry(2.5,1)qc.rx(-1.6,2)qc.ccx(2,1,0)# Recompilerecompiler=ISLRecompiler(qc)result=recompiler.recompile()recompiled_circuit=result['circuit']# See the recompiled outputprint(recompiled_circuit)Specifying additional configurationThe default settings can be changed by specifying arguments when
buildingISLRecompiler(). Many of the configuration options are bundled into theISLConfigclass.fromisl.recompilersimportISLRecompiler,ISLConfigfromqiskit.circuit.randomimportrandom_circuitqc=random_circuit(5,5,seed=2)# Recompileconfig=ISLConfig(sufficient_cost=1e-3,max_2q_gates=25)recompiler=ISLRecompiler(qc,entanglement_measure='EM_TOMOGRAPHY_CONCURRENCE',isl_config=config)result=recompiler.recompile()recompiled_circuit=result['circuit']# See the original circuitprint(qc)# See the recompiled solutionprint(recompiled_circuit)Here we have specified a number of thingssufficient_cost=1e-3: The state produced by the recompiled solution will have an overlap of at least 99.9% with respect to the state produced by the original circuit.max_2q_gates=25: If our solution contains more than 25 CNOT gates, return early. Setting this to the number of 2-qubit gates in the original circuit provides a useful upper limit.entanglement_measure: This argument on the recompiler itself specifies the type of entanglement measure used when deciding which qubits to add the next layer to.More configuration options can be explored in the documentation ofISLConfigandISLRecompiler.Comparing quantum resourcesTaking the above example, lets compare the number of gates and circuit depth before and after recompilation.fromqiskitimporttranspile# Transpile the original circuits to the common basis setqc_in_basis_gates=transpile(qc,basis_gates=['u1','u2','u3','cx'],optimization_level=3)print(qc_in_basis_gates.count_ops())print(qc_in_basis_gates.depth())# Compare with recompiled circuitprint(recompiled_circuit.count_ops())print(recompiled_circuit.depth())In the above example, the original circuit contains 25 CNOT gates and
32 single-qubit gates with a depth of 33. By comparison, the recompiled solution
prepares the same state to 99.9% overlap with on average 6 CNOT gates and
8 two-qubit gates with a depth of 9 (average tested over 10 runs).TroubleshootingNote: ISL depends onqiskit-ignis, which was deprecated in Qiskit 0.37.0. Until migration to Qiskit Experiments is completed, you may see the following error:ModuleNotFoundError: No module named 'qiskit.ignis'To fix this, simply downagrade your version of Qiskit to < 0.37.0.Citing usageWe respectfully ask any publication, project or whitepaper using ISL to cite the original literature:B Jaderberg, A Agarwal, K Leonhardt, M Kiffner, D Jaksch, 2020 Quantum Sci. Technol. 5 034015.https://doi.org/10.1088/2058-9565/ab972b