Git Product home page Git Product logo

osc21_isl's Introduction

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 submission here.

[1] B Jaderberg, A Agarwal, K Leonhardt, M Kiffner, D Jaksch, 2020 Quantum Sci. Technol. 5 034015

Installing ISL

The best way of installing ISL is through pip:

pip install quantum-isl

Using ISL

Minimal example

A circuit can be recompiled and the result accessed with only 3 lines if using the default settings.

from isl.recompilers import ISLRecompiler
from qiskit import QuantumCircuit

# Setup the circuit
qc = 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)

# Recompile
recompiler = ISLRecompiler(qc)
result = recompiler.recompile()
recompiled_circuit = result['circuit']

# See the recompiled output
print(recompiled_circuit)

Specifying additional configuration

The default settings can be changed by specifying arguments when building ISLRecompiler(). Many of the configuration options are bundled into the ISLConfig class.

from isl.recompilers import ISLRecompiler, ISLConfig
from qiskit.circuit.random import random_circuit

qc = random_circuit(5, 5, seed=2)

# Recompile
config = 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 circuit
print(qc)

# See the recompiled solution
print(recompiled_circuit)

Here we have specified a number of things

  • sufficient_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 of ISLConfig and ISLRecompiler.

Comparing quantum resources

Taking the above example, lets compare the number of gates and circuit depth before and after recompilation.

from qiskit import transpile

# Transpile the original circuits to the common basis set
qc_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 circuit
print(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).

Troubleshooting

Note: ISL depends on qiskit-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 usage

We 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

osc21_isl's People

Contributors

abhishekagarwalnpl avatar bjader avatar abhishekagarwal2301 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.