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.2.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.2-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.2-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.2-cp313-cp313-macosx_15_0_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

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

Uploaded CPython 3.13macOS 14.0+ ARM64

quprs-0.12.2-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.2-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.2-cp312-cp312-macosx_15_0_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

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

Uploaded CPython 3.12macOS 14.0+ ARM64

quprs-0.12.2-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.2-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.2-cp311-cp311-macosx_15_0_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

quprs-0.12.2-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.2.tar.gz.

File metadata

  • Download URL: quprs-0.12.2.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.2.tar.gz
Algorithm Hash digest
SHA256 eb6fd4f7046338383abc3f223414c0bc11eb0cd3b8aabc9dc8ffa8e4c543ddc0
MD5 f06a205245f1549a16095478211c19a7
BLAKE2b-256 4fe2aaead00161dfd4561d518516e643dafdeafe825e908ccc7c730ed54c4b28

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2.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.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4551f31ae616c10f4094fe1877f4690b6560d70ba0ad137caa17560660ceea6f
MD5 54d823ee6ff2ce5bef41ada052db2421
BLAKE2b-256 7f1cc8da5dac17a4764895192b606797582fb17f9959a33f632ed47281b1da4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2-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.2-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 75eea9895511d52200c4ef3b7b9b8154a36eded99a713f3e439fe864c82a0d48
MD5 866f8a2e2a3169200ef155999302ac51
BLAKE2b-256 6a9a8af2103b7a8d04182bab8fe5ccce3d2d447a51773cca80a051a27ffde67b

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2-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.2-cp313-cp313-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 985e4adef31ff822326404cf456ddb0b753daaba84d9fafb513356e8e79830bc
MD5 1943d232f82d9c4d92a357d0ccb691c7
BLAKE2b-256 f191a4d3cbca51ae261ae506d82d18d064df1c58af43a4ca6533f2952763994b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for quprs-0.12.2-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 24ff824a2c9c2145174355ba6a41895b741225eca62defe933b7cbebdd437e34
MD5 609594f160906cd359079e330a0d4bc9
BLAKE2b-256 7c42441e3644ab1e1df5fd84e4bd083efb15d0ba713488b0d68bed37fd00c0d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2-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.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 df36c487a5d41731ef72df21927a33cfdd329373d4e8e81823d3c91f3ad34859
MD5 a55ad8ce066a2e45e166d9e9a0472ccf
BLAKE2b-256 b85b588b8eecb26928eda452cd1c0593ff1df53e8e8965456a51b028a795bc0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2-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.2-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4a1c9391ed0b941fb0ef8bf599cbb276b06532df88fb8346ed935c96793955e0
MD5 0c5e86871943416932d3e5d3e75af6b3
BLAKE2b-256 b6a30476ffbf38962b60aad93197817615556854758dc1e97a2dc87e809ef7f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2-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.2-cp312-cp312-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 0f21bd3b4e0eb59625083351b6009ff999f722417460aac2e0957dcc98a68733
MD5 c5f95018cdcc1931ab4a493efde51cf4
BLAKE2b-256 98c3fc1cbd87c107950ddab914ade1721195e147e14794c41adaf2f1291292b9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for quprs-0.12.2-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6b4586b347204179fe94a9986b094bf49fd8985c48edb23eb51b816acb442838
MD5 2b236a54919b9def4c79f20d8ef1ddff
BLAKE2b-256 97ae491ad87ce461860987cdb06ade36cd5555a29d2e2d8bc2abbf9cdc321463

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2-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.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80169f8f4098503859db8fac91189af686682068d3f93fff9ede2cb30c3da4f6
MD5 ff393ed7c2fe23b18047b1a68230ccd0
BLAKE2b-256 a1a80cdf6293be17db095baafd3fecc73141bf44ed0a7fdc2d390bbf7e1f85a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2-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.2-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d4c9882f80524937eebbe736c8bbc3232f1a8b84a7af4e89b308414a397b1966
MD5 7e80cab0b30c6dcd4c358c3a81552995
BLAKE2b-256 7846f88d02d24d439b54e6a5bfb896ce089ce89a0662696f32b4ef55fc485a00

See more details on using hashes here.

Provenance

The following attestation bundles were made for quprs-0.12.2-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.2-cp311-cp311-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for quprs-0.12.2-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 138883994f94bf309b6e2bfdd27ba1e9fc916d9199a902e16291cb2c6b303f79
MD5 b89288f5a3a8ee88e5ddd288e3c3f014
BLAKE2b-256 6965b670303c34a29147b52b57772566a5795aedd1e4750644e54ef675d85423

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for quprs-0.12.2-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d6d9f2805e97b6235e6a1bebd32cdcf099e42521c49db17f72008480eff75c73
MD5 35799162cab006e69798798e742731c3
BLAKE2b-256 32aa0c3b460249614261f9fd78529a3262c4de763a57dd9f6db86408eff7be88

See more details on using hashes here.

Provenance

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