Skip to main content

search_compiler

An implementation of a quantum gate synthesis algorithm based on A* and numerical optimization. It relies on NumPy and SciPy. It can export code for Qiskit and OpenQASM.

This is an implementation of the algorithm described in the paper Heuristics for Quantum Compiling with a Continuous Gate Set.

Installation

This is a python package which can be installed using pip. You will need a Python version of at least 3.6. The search compiler currently only runs on macOS, Linux, and the Windows Subsystem for Linux. You can install it from PyPi using:

pip3 install search_compiler 

You can also install from a downloaded copy of the repository:

git clone git@github.com:WolfLink/search_compiler.git
pip3 install ./search_compiler

If you make changes to your local copy, you can reinstall the package:

pip3 install --upgrade ./search_compiler

Once installed, you can import the library like any other python package:

import search_compiler as sc

Native Gateset

There is a gateset that is implemented in native code to be faster. See the wiki for installation instructions.

Getting Started: search_compiler Projects

The simplest way to use the search_compiler library is by using a Project. When you create a project, you provide a path where a directory will be created to contain the project's files.

import search_compiler as sc
myproject = sc.Project("desired/path/to/project/directory")

You can then add unitaries to compile, and set compiler properties. Unitary matrices should be provided as numpy ndarrays using dtype="complex128".

myproject.add_compilation("gate_name", gate_unitary)
myproject["compiler_option"] = value

Once your project is configured, you can start your project by calling run(). The compiler uses an automatic checkpoint system, so if it is killed while in-progress, it can be resumed by calling run() again.

myproject.run()

Once your project is finished, you can get openqasm output:

myproject.assemble("gate_name") # This will write the qasm to stdout
myproject.assemble("gate_name", write_location="path/to/output/file") # This will write the qasm to the specified path.

See the wiki for details on compiler properties and other Project features.

Compiling Without Projects

If you would like to avoid working with Projects, you can use the SearchCompiler class directly.

import search_compiler as sc
compiler = sc.SearchCompiler()
circuit, vector = compiler.compile(target_unitary)

The SearchCompiler class and the compile function can take extra arguments to further configure the compiler. The return values are, in order, the unitary that represents the implemented circuit, the sc.QuantumStep representation of the circuit structure, and the vector of parameters for the circuit structure.

To export openqasm code, use the assemble function from assembler.py.

myqasm = sc.assembler.assemble(circuit, vector, sc.assembler.ASSEMBLY_IBMOPENQASM) # to get output as a string
sc.assembler.assemble(circuit, vector, sc.assembler.ASSEMBLY_IBMOPENQASM, write_location="myqasm.txt") # to write the output to a file

See the wiki for details on compiler properties.

A Note On Endianness

We use the physics convention of using big endian when naming our qubits. Some quantum programs, including IBM's Qiskit, use little endian. This means you will need to reverse the endianness of a unitary designed for Qiskit in order to work with our code, or visa versa. We provide a function that performs endian reversal on numpy matrices:

little_endian = sc.utils.endian_reverse(big_endian) # you can use the same function to convert in the other direction as well

Find information on customizing the compiler in the wiki.

Metadata

Release files for search-compiler 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for search-compiler 1.2.1
File Size Uploaded Provenance
search_compiler-1.2.1.tar.gz 27.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for search-compiler 1.2.1
File Interpreter ABI Platform
search_compiler-1.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 57.9 kB

Release files / search_compiler-1.2.1.tar.gz

Download URL search_compiler-1.2.1.tar.gz
Size 27.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bb8b96b3520a5b689d70d9e7204a5f61c82452604a48b8a923ed008b33cf87af
BLAKE2b-256 checksum
How to use checksums
546ec55542951923eb0a3c1677dc660966d05378090c0272bf5ab70aaaa88989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.7

Release files / search_compiler-1.2.1-py2.py3-none-any.whl

Download URL search_compiler-1.2.1-py2.py3-none-any.whl
Size 30.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e396b7744c5f1998a58ffa3f3b7d0f6ffc5d7c8938d3c65aa359b45e562d9f33
BLAKE2b-256 checksum
How to use checksums
c6882a5bd647e163a1893844b8257764aa5103f97a9d85c75e5ff27cebea0613
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.7

Security for search-compiler 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page