Skip to main content

QuPRS: Quantum Path-sum Reduction and Solver

Project description

License PyPI version PyPI Downloads Docker Pulls GitHub last commit PyPI - Python Version DOI 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
    

    or install QuPRS latest commit:

    pip install git+https://github.com/PhysicsQoo/QuPRS.git
    

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.1.tar.gz (54.9 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.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

quprs-0.12.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (28.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.13macOS 15.0+ x86-64

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

Uploaded CPython 3.13macOS 14.0+ ARM64

quprs-0.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

quprs-0.12.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (28.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ x86-64

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

Uploaded CPython 3.12macOS 14.0+ ARM64

quprs-0.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (29.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

quprs-0.12.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (28.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ x86-64

quprs-0.12.1-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.1.tar.gz.

File metadata

  • Download URL: quprs-0.12.1.tar.gz
  • Upload date:
  • Size: 54.9 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.1.tar.gz
Algorithm Hash digest
SHA256 6352fb7e1921b86d0d0329ab117d988078bb848c9d1f6f3b8d965121b0083670
MD5 2ae221178cfeba725fad72d275c9d5c8
BLAKE2b-256 194a08e8e5710ef6d0d0388e5d5a8efea015b8f8a97d886254146028562a19cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1.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.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3b08f46196e03077efdf61404cd0c1361307e04b9ee9fd1b32ac6dbf84fa9152
MD5 8bfd81dd1674249083d577409db9d9e7
BLAKE2b-256 1325c6bd5e0053b8d9df111bdc2bfcc0692e4ebfcba6d47e7c104e4b6739b820

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_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.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ebe120b90fce2d32882f7319c5dc11888465f3e65079c7f6a78b1b4e36bf2057
MD5 73c443054eecb25cd75b06719bfba6f1
BLAKE2b-256 917f54ac629e4f1f8d62f3899cd8230122d3314699160a20f2822cd80e2de098

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_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.1-cp313-cp313-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 c89853ef0d80196a34f5f8b67d0fbfb4148efe541d37906ebb60642e7b6a79fe
MD5 496c4cdc1feac1100c64c5097f596446
BLAKE2b-256 009b44aa26497d6cc830dcc001e880c57de8b0a3135ef191b4f714f2ea1cdbb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-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.1-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 65ae98f399b52cb691df674ce1e06a67a772f99fd8a5705f1b12e5aa9ed8d621
MD5 c20a1c5ceff4239c82f6c8677ffc7c96
BLAKE2b-256 929c50179daca0e38bea45b9d6ea50a8b04640a51070885a6e5fa06facd6ee56

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-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.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c16a47b7eba53a416dad163eea320b4e69f6ea343b9a2263eacda588aa6a97dc
MD5 555dacfde47cfeea7fc5aac0aae04518
BLAKE2b-256 10822fd8ee345f0c731bacdcf4b33c0569662b5227c67865c07f725a2ca33db3

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_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.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d2456023a4c2d4d3b4f339e01d423155086c80e545fe3496aeaa73b46c1d7336
MD5 b78077ec642e06874356a436e3b585b1
BLAKE2b-256 3c5954a40e15838db3ebfb60acac93704e8b92a37e68a4bcf80d06f8e6a22c05

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_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.1-cp312-cp312-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 80737bf4ca530cb987829c70369d8165a2bb46017be86f7ba41e2208fe1293d7
MD5 08802781de0fe5e2b19528d84be65eda
BLAKE2b-256 899264c3aca6a4cbaaaa998fb5fd20e4caff23c545c7a67bb4ce1bfde6c4b9b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-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.1-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 760f34cffced815db5d26f7ea987827e36fe38a313dd8e26696ac4e50a45e8df
MD5 d3219a73bfbf0331ff948255e917f942
BLAKE2b-256 73f46f6e804e5b376e142fd1330d0374cebce6026f7f42c20e51caab13bacc52

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-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.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4405b0f7bc829e4c7716228bfa786c78c6035236de59199a491d0a01f8465502
MD5 78064572d92d9850146d2367fea34703
BLAKE2b-256 8141410ac8c8732ab2cc6b9fe69aaaae9ad3cc9c5bd22d3d786be357cd78f1fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_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.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f7465bc2b9892ac63eb81b053e5451168d1ab45138fa55247126a8fb6ec94b1b
MD5 ba2cbbd0802701c2d8967f7e0e300cea
BLAKE2b-256 9a4438ebcf1b36a097fbd3f218fc6e89867fa09649321ce48eeca4d3105c2574

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_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.1-cp311-cp311-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 0b50a32b186dcdd75596cbc706a71111d56850245e6d6dfe76b2bde7e0330a94
MD5 ef2be28874227e779652dbe2dee9be2e
BLAKE2b-256 92da96138179ee452f76abc5dc439569f03fe9a0e3321c6669ddbecc92e22a27

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-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.1-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for quprs-0.12.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 47b066f26e92033416f2cd3e8139dca09245c5db91e653f6e45103d73218b20b
MD5 1b07708fec78e0ff195550378468ba7b
BLAKE2b-256 cebb56c78f2ee2532b2aae1944093da34902c313b4c3647f7b095d8b6458c3cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.1-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