Skip to main content

CI License Version

Сompiler of classical algorithms into oracles for quantum computing

Achievements:

  • CRC32 hash function (4 byte input) - 318 qubits.

Architecture:

  1. Building expression.
  2. Optimizing expression.
  3. Constructing list of logical gates (logical expressions) for each bit of optimized expression.
  4. Logical gates optimization (minimizing unique logic operations and qubit allocations).
  5. Generation of a quantum circuit from a DAG of logical gates.

Authors:

  • Alexander Averyanov - author
  • Evgeny Kiktenko - mentor
  • Dmitry Ershov - helped with the optimizer design

Example:

import quantpiler

x_len = 4
x = quantpiler.argument("x", x_len)

a = 6
# N = 2**4

prod = 1
for i in range(x_len):
    prod = ((x >> i) & 1).ternary(prod * a**(2**i), prod) & 0b1111

circ = prod.compile()
qc = quantpiler.circuit_to_qiskit(circ)

qc.draw("mpl")

Resulting circuit

# returning ancillas and arguments to their original state
rqc = quantpiler.circuit_to_qiskit(circ, rev=True)

rqc.draw("mpl")

Resulting reversed circuit

User guide

Installation

pip install quantpiler

Binary releases on PyPI only available for Windows (x86, x86_64) and GNU/Linux (x86_64).

Now you can import library in Python:

import quantpiler

Creating input variables

a = quantpiler.argument("a", 2)
b = quantpiler.argument("b", 4)

This will create argument "a" with length of 2 qubits and "b" with length of 4 qubits. You can't use arguments with same name but with different lengths.

Expressions

Any argument variable, constant, or combination thereof is an expression. Expressions are actually lists of logic gates representing each bit. For example, a ^ b is effectively [[a[0] ^ b[0], [a[1] ^ b[1], b[2], b[3]].

Output expression lengths

Let's a -- length of first operand, b -- length (value for bitshifts) of second operand.

Name Notation Length
Binary invert ~ a
Bitwise XOR ^ max(a, b)
Bitwise OR | max(a, b)
Bitwise AND & min(a, b)
Sum + max(a, b) + 1
Product * a + b
Right bitshift >> a - b
Left bitshift << a + b

Length is the maximum possible length of result. Actual length depends on optimizer decitions: for example, the length of a ^ a will be 0 (no qubits, empty expression).

Estimating length of expression:

# you can use builtin python's len to get estimated expression's length
length = len(a ^ b + 1)

Please note that this is an estimated length as actual length may vary depending optimizer solutions.

Debugging expression:

print(str(a ^ b + 1))

or, for jupyter:

a ^ b + 1

This will print (^ "a(2)" (+ 1 "4(2)")) for a of length 2 and b of length 4.

Bitwise binary operations

r = ~a
r = a ^ b
r = a | b
r = a & b

You can also do this with constants:

r = 0b101 ^ a
b |= 1
r = b & 0b11

Bit shifting

r = a << 2
r = b >> 3

Please note that only constant distance shifting is supported at this time.

Arithmetic operations

r = a + b
r = 2 * a * b

Ternary operations

If you want to emulate if statements, i.e.

if cond:
    r = a + b
else:
    r = b & 0b11

you can use ternary operators:

r = cond.ternary(a + b, b & 0b11)

Note that cond must be an expression exactly 1 qubit long. You can achieve this by using bitwise and with 1.

Compiling

Let's compile something:

r = a ^ b + 3

# internal circuit representation
circ = r.compile()

# QuantumCircuit from qiskit
qc = quantpiler.circuit_to_qiskit(circ)

# let's draw our circuit
qc.draw("mpl")

Compiled a ^ b + 1

Release files for quantpiler 0.3.5

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

Source distribution (sdist)

Source distribution for quantpiler 0.3.5
File Size Uploaded
quantpiler-0.3.5.tar.gz 116.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for quantpiler 0.3.5
File
quantpiler-0.3.5-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl PyPy 3.10 PyPy 3.10 7.3 Linux glibc 2.28+ x86-64 Details
quantpiler-0.3.5-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl PyPy 3.9 PyPy 3.9 7.3 Linux glibc 2.28+ x86-64 Details
quantpiler-0.3.5-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl PyPy 3.8 PyPy 3.8 7.3 Linux glibc 2.28+ x86-64 Details
quantpiler-0.3.5-cp312-none-win_amd64.whl CPython 3.12 none Windows x86-64 Details
quantpiler-0.3.5-cp312-none-win32.whl CPython 3.12 none Windows x86-32 Details
quantpiler-0.3.5-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
quantpiler-0.3.5-cp311-none-win_amd64.whl CPython 3.11 none Windows x86-64 Details
quantpiler-0.3.5-cp311-none-win32.whl CPython 3.11 none Windows x86-32 Details
quantpiler-0.3.5-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
quantpiler-0.3.5-cp310-none-win_amd64.whl CPython 3.10 none Windows x86-64 Details
quantpiler-0.3.5-cp310-none-win32.whl CPython 3.10 none Windows x86-32 Details
quantpiler-0.3.5-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
quantpiler-0.3.5-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details
quantpiler-0.3.5-cp39-none-win32.whl CPython 3.9 none Windows x86-32 Details
quantpiler-0.3.5-cp39-cp39-manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64 Details
quantpiler-0.3.5-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
quantpiler-0.3.5-cp38-none-win32.whl CPython 3.8 none Windows x86-32 Details
quantpiler-0.3.5-cp38-cp38-manylinux_2_28_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.28+ x86-64 Details

Total release size: 13.9 MB

Release files / quantpiler-0.3.5.tar.gz

Download URL quantpiler-0.3.5.tar.gz
Size 116.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ec91eb86061310c5c96143e3a2169fc5afb1a4ecefea8629e467e12efb2bf752
BLAKE2b-256 checksum
How to use checksums
359e5431bc679b612802daf4cba52766327ece0624c5bb5014816343056ffef8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl

Download URL quantpiler-0.3.5-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.10 PyPy 3.10 7.3
SHA-256 checksum
How to use checksums
661b72d1fcaddd376af8f0f02d91792cfef13c0646c1b6b7bea52e0c0458a021
BLAKE2b-256 checksum
How to use checksums
37fa32eb2a4983b0278617d644215fb4767dee87f35d32416e6401190ba6710a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl

Download URL quantpiler-0.3.5-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.9 PyPy 3.9 7.3
SHA-256 checksum
How to use checksums
fa4c3ff0a8c2e017690b50531ed129f4688e6f80cfdf7de55142069558bfed8c
BLAKE2b-256 checksum
How to use checksums
7d09033b6ccb6650b9c89f1c6e5ef08f85b1a5194722f42b1f0320875bcd32e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl

Download URL quantpiler-0.3.5-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags Linux glibc 2.28+ x86-64 PyPy 3.8 PyPy 3.8 7.3
SHA-256 checksum
How to use checksums
cc0ac3779b4fb5c5f36279d2182f035f8457e6ae80829b149c74d9464e7537c8
BLAKE2b-256 checksum
How to use checksums
9f005d9e0bcf5b2fb5b6401987a5d41720b437ed188af19f4012eb0de3865a18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp312-none-win_amd64.whl

Download URL quantpiler-0.3.5-cp312-none-win_amd64.whl
Size 521.1 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
13cc96d33b503d4df44402bfef87bf283b48ee696fa081109692ab327e4c2e44
BLAKE2b-256 checksum
How to use checksums
423eff632fdaf068b808c708539da0948b62244d5cc53d7b206aa595dd143c1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp312-none-win32.whl

Download URL quantpiler-0.3.5-cp312-none-win32.whl
Size 465.0 kB
Tags CPython 3.12 Windows x86-32
SHA-256 checksum
How to use checksums
526a3a6517482ac4570fdff72a1456dd257a17dce2878fa708240f1c8c35f8d8
BLAKE2b-256 checksum
How to use checksums
5706b524ca12a254816004eb0781df796bebed89cfc180bec6718ccd789e7770
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL quantpiler-0.3.5-cp312-cp312-manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
856774670ce5c4f303498db961e3d28f6c1f0cd37d01d6b856a058f129f742e9
BLAKE2b-256 checksum
How to use checksums
7331b86a60cb51dd6f521c7ed05d9de44bb39d0efd649cb1080bb5e30212e02f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp311-none-win_amd64.whl

Download URL quantpiler-0.3.5-cp311-none-win_amd64.whl
Size 516.5 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
24e6f2a56da1284d03c53f7c7e21a10243f6806de0bf3125a35072b252f8ee06
BLAKE2b-256 checksum
How to use checksums
c0cfc3c784b8c198c683918ded03ac651ec465366d09e3edea69667bc58e2abf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp311-none-win32.whl

Download URL quantpiler-0.3.5-cp311-none-win32.whl
Size 466.8 kB
Tags CPython 3.11 Windows x86-32
SHA-256 checksum
How to use checksums
509d17f0a49f7f3fa551c1b8e9b6ce79537d00b1898671d98f2951224518d083
BLAKE2b-256 checksum
How to use checksums
c9e10fae8350dfa4e4f8487a91629125a82705af1643a99f1dcfe531db777f4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL quantpiler-0.3.5-cp311-cp311-manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
01f6fd8f4152da243f9b540e63eeebf37355ec66d1c4f38cefdb552f299fc1f3
BLAKE2b-256 checksum
How to use checksums
97aa5e340750cf9f45903a062fc3cd1808db1bf9eba7ecd4156611824eb2edbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp310-none-win_amd64.whl

Download URL quantpiler-0.3.5-cp310-none-win_amd64.whl
Size 516.6 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
609f23537d48800f4dfcbe1a4b17f8f9f5e3bca588b00ad0bc2069f045451dc0
BLAKE2b-256 checksum
How to use checksums
e04fe96c1c93ff9af30a5ca40ea515f1311033d75df16b5908f5f7bb548239c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp310-none-win32.whl

Download URL quantpiler-0.3.5-cp310-none-win32.whl
Size 466.9 kB
Tags CPython 3.10 Windows x86-32
SHA-256 checksum
How to use checksums
e662671ab7e011b5a8a308e9b5ed4b9a8bca3147925ae207da0a56e9af831751
BLAKE2b-256 checksum
How to use checksums
2e8673e6feff03dd9026db70154760d24843b30b4e2ff07758b686a51a9c1a39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL quantpiler-0.3.5-cp310-cp310-manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b6721ff8b19047af2046fa134ad69b1fb1360ca1715ce6d933c344a8369fb4c9
BLAKE2b-256 checksum
How to use checksums
517a00eba2ee3b8dfbceace2de757a8b295e48b991fac01b2b8f1e9f80f30b4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp39-none-win_amd64.whl

Download URL quantpiler-0.3.5-cp39-none-win_amd64.whl
Size 517.2 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
c57b3219a234386db2bcc55bbc3ec0a3f40828a61ed3bd0f44764f12f3e71200
BLAKE2b-256 checksum
How to use checksums
8837b128a1098ab63a8721bf525ff44da1d69e1fd398770a09f99745f6674f99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp39-none-win32.whl

Download URL quantpiler-0.3.5-cp39-none-win32.whl
Size 466.8 kB
Tags CPython 3.9 Windows x86-32
SHA-256 checksum
How to use checksums
f25627729fa4b7b9c1f1ffab76f50c974f90ccfedab0586b510da656359f632e
BLAKE2b-256 checksum
How to use checksums
eaf1272858ff3cc43a81d8a86f5cf80c4915ad1284531d6238ad0636cbbf3f1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp39-cp39-manylinux_2_28_x86_64.whl

Download URL quantpiler-0.3.5-cp39-cp39-manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
fd12909d3172a81ba6b3c880fdd51b9422dd35618569f69b6c74af32ab53dd6b
BLAKE2b-256 checksum
How to use checksums
24b6c6a026f285a58b335b5dfb8cac50e2989da51981fa1e829763e852da183d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp38-none-win_amd64.whl

Download URL quantpiler-0.3.5-cp38-none-win_amd64.whl
Size 516.4 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
bd7e696eae8982106949fddb327d37cc4f0bafba0fef755f12afe3682c28fcc6
BLAKE2b-256 checksum
How to use checksums
60e88e4a7331a1fd0c216980750f57301b672a5d1c05af2476aefa5d60e2181e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp38-none-win32.whl

Download URL quantpiler-0.3.5-cp38-none-win32.whl
Size 467.4 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
da71dd6dc59489640a5140d01b1602ae3578097219eb79219f22c33a27d74610
BLAKE2b-256 checksum
How to use checksums
1e04bc3d09682551a9b0eb615bd7197b77934f98c7861831301ba224291c5dbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release files / quantpiler-0.3.5-cp38-cp38-manylinux_2_28_x86_64.whl

Download URL quantpiler-0.3.5-cp38-cp38-manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags CPython 3.8 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
73ba24f431e47b4827654d9d6d3c083f4194fcc8d379287b8202ee51f304f427
BLAKE2b-256 checksum
How to use checksums
d2d98b6412e135ff391bad3378cd6719b0ad1ccdd6a8e6c217c712387b78bcd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.4.0

Release history Release notifications | RSS feed

This release

0.3.5 This release

19 release files

0.3.4

19 release files

0.3.3

19 release files

0.3.2

19 release files

0.3.1

19 release files

0.3.0

1 release file

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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