Skip to main content

A package for implementing the Incremental Structure Learning (ISL) algorithm for approximate circuit recompilation

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

quantum_isl-1.0.1-py3-none-any.whl (57.4 kB view details)

Uploaded Python 3

File details

Details for the file quantum_isl-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: quantum_isl-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 57.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.5

File hashes

Hashes for quantum_isl-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 de87d9920e943a7c32aaa279e68a8ad56a32e96b03085b81f49dc8746ef0678d
MD5 72bed9d4ac9e036314a1df4b7d927cec
BLAKE2b-256 cbe5e9bb1212fab0ee9a15acd86e9378d4fce5da623727d4533f76c4d33ac4f2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page