Skip to main content

QuPRS: Quantum Path-sum Reduction and Solver

Project description

DOI PyPI version Python Version License

Docker Pulls PyPI Downloads GitHub last commit Ask DeepWiki

QuPRS: Quantum Path-sum Reduction and Solver

QuPRS("kyu-parse") is a tool for Quantum Circuit tool integrate Path-sum Reduction and Solver.

In quantum computing, verifying whether an optimized or compiled quantum circuit is functionally equivalent to the original circuit is a crucial task. QuPRS aims to solve this problem, and its features include:

  • Novel verification method: Based on pathsum, which is a circuit representation method different from traditional matrix products.
  • Multiple verification strategies:
    1. Hybrid mode (RR + WMC): Combines the efficiency of reduction rules and the completeness of weighted model counting.
    2. Reduction rules only (RR): Extremely fast, suitable for circuits that can be simplified by local rules.
    3. WMC only: A powerful SAT-based method for more complex circuit structures.
  • Seamless integration with Qiskit ecosystem: Circuits can be directly loaded from Qiskit QuantumCircuit objects or QASM files.

Contents

Installation

It is recommended to install QuPRS in a virtual environment.

  1. Create and activate a Conda virtual environment:

    conda create --name QuPRS python=3.12 # Or your preferred Python version
    conda activate QuPRS
    
  2. Install QuPRS using pip:

    pip install QuPRS
    

Platform Support

QuPRS provides pre-built wheels for the following operating systems and architectures:

OS Architecture Status Note
Linux x86_64 ✅ Supported Tested on Ubuntu
Linux ARM64 (aarch64) ✅ Supported Tested on Ubuntu
macOS Intel (x86_64) ✅ Supported macOS 15+
macOS Apple Silicon (M1/M2/M3) ✅ Supported macOS 14+
Windows x86_64 / ARM64 ⚠️ WSL2 Only Please use WSL2

Using QuPRS

This tool can build quantum circuit using path-sum formulation.

First, import the necessary components from the QuPRS library.

from QuPRS.pathsum import PathSum

Create pathsum Circuit

Create a pathsum Circuit You can create a PathSum.QuantumCircuit object directly:

qubit_num = 2
circuit = PathSum.QuantumCircuit(qubit_num)
circuit = circuit.h(0) # Apply Hadamard gate to qubit 0
circuit = circuit.h(0) # Apply Hadamard gate to qubit 0 again (H*H = I)
# Add more gates as needed
# e.g., circuit = circuit.cx(0, 1)

Import From qasm

pathsum supports importing circuits from QASM files or strings.

From a QASM file:

filename = "my_circuit.qasm"
# Ensure my_circuit.qasm exists and contains valid QASM code
# Example my_circuit.qasm:
# OPENQASM 2.0;
# include "qelib1.inc";
# qreg q[2];
# h q[0];
# cx q[0],q[1];

circuit = PathSum.load_from_qasm_file(filename)

Or

qasm_str = """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
h q[0];
cx q[0],q[1];
"""
circuit = PathSum.load_from_qasm_str(qasm_str)

Equivalence Checking

QuPRS provides tools for checking the equivalence of two quantum circuits, potentially imported from Qiskit or QASM files.

Importing Circuits for Equivalence Checking You can load circuits from QASM files or define them directly using Qiskit for comparison.

Circuit Prepare

  • Load from QASM files
    # Assuming circuit1.qasm and circuit2.qasm exist
    from QuPRS.interface.load_qiskit import load_circuit
    
    circuit1 = load_circuit("circuit1.qasm")
    circuit2 = load_circuit("circuit2.qasm")
    
  • Direct import from Qiskit QuantumCircuit objects:
    from qiskit import QuantumCircuit 
    
    # Define circuit1 using Qiskit
    circuit1 = QuantumCircuit(2)
    circuit1.h(1)
    circuit1.cx(0, 1)
    circuit1.h(1)
    
    # Define circuit2 using Qiskit
    circuit2 = QuantumCircuit(2)
    circuit2.cz(0, 1)
    

Run Equivalence Checking

  • Hybrid: Reduction Rules (RR) and Weighted Model Counting (WMC)

    This method combines RR with WMC for equivalence checking.

    from QuPRS import check_equivalence
    
    result = check_equivalence(circuit1, circuit2, method = "hybrid",)
    
  • Using Reduction Rules (RR)

    from QuPRS import check_equivalence
    
    result = check_equivalence(circuit1, circuit2, method = "reduction_rules",)
    
  • WMC only (without RR)

    To perform equivalence checking using only WMC, you need to disable the Reduction Rules switch.

    from QuPRS import check_equivalence
    
    result = check_equivalence(circuit1, circuit2, method = "wmc_only",)
    

Cite

If you use QuPRS in your research, please consider citing it.

This code is associated with a forthcoming publication. Please cite this repository for now, and check back for the full paper citation.

DOI

License Information

  • The original source code of this project is licensed under the MIT License.

  • This project utilizes and depends on several third-party components and libraries, which are governed by their own licenses. For detailed copyright notices and the full license texts of these components, please see the NOTICE.md file.

Acknowledgements

This project utilizes gpmc, a binary component developed by Kenji Hashimoto, for parts of its Weighted Model Counting functionality.

Project details


Download files

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

Source Distribution

quprs-0.12.2b0.tar.gz (55.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

quprs-0.12.2b0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (29.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

quprs-0.12.2b0-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (28.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

quprs-0.12.2b0-cp313-cp313-macosx_15_0_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

quprs-0.12.2b0-cp313-cp313-macosx_14_0_arm64.whl (7.2 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

quprs-0.12.2b0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (29.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

quprs-0.12.2b0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (28.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

quprs-0.12.2b0-cp312-cp312-macosx_15_0_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

quprs-0.12.2b0-cp312-cp312-macosx_14_0_arm64.whl (7.2 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

quprs-0.12.2b0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (29.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

quprs-0.12.2b0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (28.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

quprs-0.12.2b0-cp311-cp311-macosx_15_0_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

quprs-0.12.2b0-cp311-cp311-macosx_14_0_arm64.whl (7.2 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

File details

Details for the file quprs-0.12.2b0.tar.gz.

File metadata

  • Download URL: quprs-0.12.2b0.tar.gz
  • Upload date:
  • Size: 55.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quprs-0.12.2b0.tar.gz
Algorithm Hash digest
SHA256 a6f1e2ddef9854f180ca09ca69c7a9b56095c060e6bbda0ee50126d2aa89f747
MD5 1b7b856b67d1daf347e1b1f16ade0319
BLAKE2b-256 95bb473455df3993f015a8b082dc89913fd4b882a48e2d244d9f917178d95d80

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0.tar.gz:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a79170c1fea686997af58cbae3c4eacffdb01607ab4c355ec7e1dc790652f984
MD5 f8600415bd344035ec7a17d94e147860
BLAKE2b-256 04a3f28eb6c82fb4859d0aa4f79c03f9fa947f565d8822cc0d52160f28fac2dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f85debac2a63073fe4589bd6b766bc880fab4bb2895ff1b496770f41ed0639fb
MD5 b6714b928b49ead466d222548333e3ec
BLAKE2b-256 e9ae6171f93e8969c014184ab2d3167220453f4c078504055b4b33c1baa8c300

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp313-cp313-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 1a22b115a6e2f0b0ec6248fdc3c05f141b695dacf80ec4a9ae3713a25cb15fce
MD5 18bf7498c4bc5fbf4b923af6a6384e4d
BLAKE2b-256 60c195164e710d7973f88c8fa45ac1d0800bc88342479743f164ef3a2f94788c

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp313-cp313-macosx_15_0_x86_64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 de39d287b4ddeedcd95bcce9a294c06a95dbf20b6aa281501de052dc2ecb2936
MD5 cdf6841c7c74e808b80ab280c03542a0
BLAKE2b-256 503ee7491dc10599f10b1610e19c5af762f93b600c139860284a630db18450b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 17f264884b6a16716b1976f7db043291443c603bc3ddb9bbb25d9e587ddd4980
MD5 001e1bb22633834a212f356ebc400724
BLAKE2b-256 69cc6a524c82dff0b76b353229be661cdcb586b5eb56d094a9922653b1128010

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 08a92dedfb55b4ab1becd52e52c3c0d543f63753159c783a73aa65f52bf3e488
MD5 06c08be8f7f147ad13531faa7df7510c
BLAKE2b-256 0013183706ce0d14884f3265671ff7b0a65456fa607f6c8a6b5a9c9d6b4989fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp312-cp312-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 b58742c62d7a13ce907987659e9c7f17f2f73ac7a0a365b97f7fbf58897cf572
MD5 1da67160c5769b76f816bdfbfb9ccd56
BLAKE2b-256 1cc96edb34f80d10f2867de3c46219e78a675e8715b7811e1725e93773e039ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp312-cp312-macosx_15_0_x86_64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 35cb38bd636b34f0d482b7a2f865aab699c9dc8d0d9e9affbe444780d3a39616
MD5 c0565cba728c51397f43aab5ed494d83
BLAKE2b-256 08dee46d6227657c9ff19b82300c49e1c9b7139ce3726fc68bb907e321e4f1eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 738205aa832db39fe767d7a780b1fd534ca218e627048b60e065613c835f00e3
MD5 f8716077ea64b3c423226b55d5315c5d
BLAKE2b-256 b016c008053136b7aa8bfb95b98d85ed4fc51520c81e30a9eb61e232c5a13fb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 16651df52b3d2d4aac46cdfddc3138307e8670094fef55b67c70feca5ebf6ec8
MD5 597e2c7f2aba762272d09fe862c5a92c
BLAKE2b-256 dda44ee6d2c9b17522fe364f3967c43313ada78c9f76d36d0b82bba13ce1be95

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp311-cp311-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 0dde560a8a8e10382d43c9e774f032f480f8ca3db0e8bbe9a0833e95dcd98589
MD5 1d00ea87a41158e13313101d1364213a
BLAKE2b-256 f04b21a1c68c92eb86a277b4696821be5860c032baf1cdc015175075d94b4f89

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp311-cp311-macosx_15_0_x86_64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quprs-0.12.2b0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2b0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8c37352e46363ec8d21c78860aa39f94097de9564ea39b8b8ba3635f0dd45b47
MD5 613040e34934387791beb681c5d2c57b
BLAKE2b-256 959d57f1d5db640a69a3c3617703f27fcbcfa3546b5d9b9a7f0c074243cf249c

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2b0-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: python-publish.yml on PhysicsQoo/QuPRS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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