QuPRS 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. quprs-0.3.0/.github/workflows/docker-build.yml +90 -0
  2. {quprs-0.2.0 → quprs-0.3.0}/.github/workflows/pytest.yml +3 -1
  3. {quprs-0.2.0 → quprs-0.3.0}/.github/workflows/python-publish.yml +1 -1
  4. quprs-0.3.0/Dockerfile +49 -0
  5. {quprs-0.2.0 → quprs-0.3.0}/PKG-INFO +3 -1
  6. {quprs-0.2.0 → quprs-0.3.0}/pyproject.toml +2 -0
  7. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/_version.py +2 -2
  8. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/interface/load_qiskit.py +5 -3
  9. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/interface/ps2wmc.py +1 -1
  10. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/utils/util.py +5 -1
  11. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS.egg-info/PKG-INFO +3 -1
  12. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS.egg-info/SOURCES.txt +2 -0
  13. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS.egg-info/requires.txt +2 -0
  14. {quprs-0.2.0 → quprs-0.3.0}/.gitignore +0 -0
  15. {quprs-0.2.0 → quprs-0.3.0}/LICENSE.md +0 -0
  16. {quprs-0.2.0 → quprs-0.3.0}/MANIFEST.in +0 -0
  17. {quprs-0.2.0 → quprs-0.3.0}/NOTICE.md +0 -0
  18. {quprs-0.2.0 → quprs-0.3.0}/README.md +0 -0
  19. {quprs-0.2.0 → quprs-0.3.0}/setup.cfg +0 -0
  20. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/__init__.py +0 -0
  21. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/cache_manager/__init__.py +0 -0
  22. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/cache_manager/cache_decorator.py +0 -0
  23. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/cache_manager/global_cache_manager.py +0 -0
  24. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/config.py +0 -0
  25. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/interface/__init__.py +0 -0
  26. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/interface/gate_library.py +0 -0
  27. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/interface/qasm2qc.py +0 -0
  28. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/pathsum.py +0 -0
  29. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/utils/Qiskit_Circuit_Utils.py +0 -0
  30. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/utils/__init__.py +0 -0
  31. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/utils/gpmc +0 -0
  32. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/utils/reduction.py +0 -0
  33. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS/utils/strategy.py +0 -0
  34. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS.egg-info/dependency_links.txt +0 -0
  35. {quprs-0.2.0 → quprs-0.3.0}/src/QuPRS.egg-info/top_level.txt +0 -0
@@ -0,0 +1,90 @@
1
+ name: Build and Push Docker Image to Multiple Registries
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ tags:
7
+ - 'v*'
8
+ pull_request:
9
+ branches: [ "main" ]
10
+
11
+ jobs:
12
+ build-and-push:
13
+ runs-on: ubuntu-latest
14
+
15
+ # Permissions: write access to packages is required for GHCR
16
+ permissions:
17
+ contents: read
18
+ packages: write
19
+
20
+ steps:
21
+ # Checkout the repository source code
22
+ - name: Checkout repository
23
+ uses: actions/checkout@v4
24
+
25
+ # Set lowercase repository and image names for Docker
26
+ - name: Set lowercase repo name
27
+ run: |
28
+ # Convert repository name to lowercase for Docker image naming
29
+ echo "LOWERCASE_REPO=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
30
+ # Extract and lowercase the repository name for Docker Hub
31
+ echo "DOCKERHUB_REPO=$(basename '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
32
+
33
+ # Extract Docker metadata (tags, labels, etc.)
34
+ - name: Extract Docker metadata
35
+ id: meta
36
+ uses: docker/metadata-action@v5
37
+ with:
38
+ images: |
39
+ # Image for GitHub Container Registry (GHCR)
40
+ ghcr.io/${{ env.LOWERCASE_REPO }}
41
+ # Image for Docker Hub
42
+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}
43
+ tags: |
44
+ # Tag with semantic version if a Git tag is present (e.g., 1.2.3)
45
+ type=semver,pattern={{version}}
46
+ # Tag with short commit SHA
47
+ type=sha,format=short
48
+ # Tag as 'latest' only on the default branch
49
+ type=raw,value=latest,enable={{is_default_branch}}
50
+
51
+ # Log in to GitHub Container Registry (GHCR)
52
+ - name: Log in to GHCR
53
+ if: github.event_name != 'pull_request'
54
+ uses: docker/login-action@v3
55
+ with:
56
+ registry: ghcr.io
57
+ username: ${{ github.actor }}
58
+ password: ${{ secrets.GITHUB_TOKEN }}
59
+
60
+ # Log in to Docker Hub
61
+ - name: Log in to Docker Hub
62
+ if: github.event_name != 'pull_request'
63
+ uses: docker/login-action@v3
64
+ with:
65
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
66
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
67
+
68
+ # Set up QEMU for multi-architecture builds (recommended best practice)
69
+ - name: Set up QEMU
70
+ uses: docker/setup-qemu-action@v3
71
+
72
+ # Set up Docker Buildx (required for advanced build features)
73
+ - name: Set up Docker Buildx
74
+ uses: docker/setup-buildx-action@v3
75
+
76
+ # Build, test, and push the Docker image to both registries (only for push events)
77
+ - name: Build, Test and Push
78
+ uses: docker/build-push-action@v5
79
+ with:
80
+ context: .
81
+ # Use the 'tester' target for PRs; otherwise, build the default target
82
+ target: ${{ github.event_name == 'pull_request' && 'tester' || '' }}
83
+ # Only push images if the event is not a pull request
84
+ push: ${{ github.event_name != 'pull_request' }}
85
+ # Use tags and labels generated by the metadata action
86
+ tags: ${{ steps.meta.outputs.tags }}
87
+ labels: ${{ steps.meta.outputs.labels }}
88
+ # Enable build cache to speed up subsequent builds
89
+ cache-from: type=gha
90
+ cache-to: type=gha,mode=max
@@ -37,12 +37,14 @@ jobs:
37
37
  run: |
38
38
  python -m pip install --upgrade pip
39
39
  pip install pytest
40
+ pip install pytest-xdist
41
+ pip install pytest-cov
40
42
  pip install .
41
43
 
42
44
  # Step 4: Run pytest
43
45
  - name: Run tests with pytest
44
46
  run: |
45
- pytest --junitxml=pytest-results.xml
47
+ pytest -n auto -v --junitxml=pytest-results.xml
46
48
 
47
49
  # Step 5: Upload pytest results as artifact
48
50
  - name: Upload pytest results
@@ -52,5 +52,5 @@ jobs:
52
52
  body: |
53
53
  ## 🚀 Release Notes
54
54
  * **📦 Version:** `${{ github.ref_name }}`
55
- * **🔗 PyPI Link:** https://pypi.org/project/${{ github.repository_owner }}/${{ github.event.repository.name }}/${{ github.ref_name }}
55
+ * **🔗 PyPI Link:** https://pypi.org/project/${{ github.event.repository.name }}/${{ github.ref_name }}
56
56
  * 🛠️ This release was automatically generated by GitHub Actions.
quprs-0.3.0/Dockerfile ADDED
@@ -0,0 +1,49 @@
1
+ # Copyright 2025 Wei-Jia Huang
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ # Use the official Miniconda3 image as the base image
6
+ FROM continuumio/miniconda3
7
+
8
+ # Set the working directory inside the container
9
+ WORKDIR /app
10
+ COPY . .
11
+
12
+ # 1. Update Conda and upgrade Python in the base environment to version 3.12
13
+ # Combine conda update, Python upgrade, and pip installation in a single RUN command
14
+ # Clean up to reduce image size
15
+ RUN conda update -n base -c defaults conda --yes && \
16
+ conda install -n base -c defaults python=3.12 pip --yes && \
17
+ conda clean --all -f -y
18
+
19
+ # 2. Install required system libraries
20
+ RUN apt update && \
21
+ apt install -y --no-install-recommends \
22
+ libgmpxx4ldbl \
23
+ libmpfr6 \
24
+ libatomic1 && \
25
+ rm -rf /var/lib/apt/lists/*
26
+
27
+ # 3. Install Python packages in the base environment
28
+ RUN pip install .[dev] && \
29
+ # Remove pip cache to reduce image size
30
+ rm -rf ~/.cache/pip && \
31
+ rm -rf ./dist
32
+
33
+ # 4. Copy benchmark, test, and documentation files into the container
34
+ COPY ./benchmarks/Feymann /app/benchmarks/Feymann
35
+ COPY ./benchmarks/MQTBench /app/benchmarks/MQTBench
36
+ COPY ./test /app/test
37
+ COPY README.md /app/README.md
38
+ COPY LICENSE.md /app/LICENSE.md
39
+ COPY NOTICE.md /app/NOTICE.md
40
+
41
+ RUN conda run -n base pytest -n auto
42
+
43
+ # 5. Set license information as a container label
44
+ LABEL org.opencontainers.image.licenses="MIT"
45
+
46
+
47
+
48
+ # 6. Set the default command to run when the container starts
49
+ CMD ["/bin/bash"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QuPRS
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: QuPRS: Quantum Path-sum Reduction and Solver
5
5
  Author-email: Wei-Jia Huang <wei.jia.huang.physics@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/PhysicsQoo/QuPRS
@@ -28,6 +28,8 @@ Provides-Extra: dev
28
28
  Requires-Dist: ipykernel; extra == "dev"
29
29
  Requires-Dist: build; extra == "dev"
30
30
  Requires-Dist: pytest; extra == "dev"
31
+ Requires-Dist: pytest-xdist; extra == "dev"
32
+ Requires-Dist: pytest-cov; extra == "dev"
31
33
  Requires-Dist: pandas; extra == "dev"
32
34
  Requires-Dist: tqdm; extra == "dev"
33
35
  Dynamic: license-file
@@ -36,6 +36,8 @@ dev = [
36
36
  "ipykernel",
37
37
  "build",
38
38
  "pytest",
39
+ "pytest-xdist",
40
+ "pytest-cov",
39
41
  "pandas",
40
42
  "tqdm"
41
43
  ]
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.2.0'
21
- __version_tuple__ = version_tuple = (0, 2, 0)
20
+ __version__ = version = '0.3.0'
21
+ __version_tuple__ = version_tuple = (0, 3, 0)
@@ -164,7 +164,7 @@ def qasm_eq_check(circuit1: str|QuantumCircuit, circuit2:str|QuantumCircuit, str
164
164
  output_dict["equivalent"] = 'unknown'
165
165
  return output_dict, pathsum_circuit
166
166
 
167
- def qasm_eq_check_with_wmc(circuit1: str|QuantumCircuit, circuit2:str|QuantumCircuit, strategy ='Difference' , Benchmark_Name=None, timeout= 600):
167
+ def qasm_eq_check_with_wmc(circuit1: str|QuantumCircuit, circuit2:str|QuantumCircuit, strategy ='Difference' , Benchmark_Name=None, cnf_filename = None, timeout= 600):
168
168
  tolerance = config.TOLERANCE
169
169
 
170
170
  output_dict, circuit = qasm_eq_check(circuit1=circuit1, circuit2=circuit2, strategy =strategy , Benchmark_Name=Benchmark_Name, timeout= timeout)
@@ -181,7 +181,9 @@ def qasm_eq_check_with_wmc(circuit1: str|QuantumCircuit, circuit2:str|QuantumCir
181
181
  signal.alarm(timeout)
182
182
  start_time = time.time()
183
183
  try:
184
- to_DIMACS(circuit)
184
+ if cnf_filename is None:
185
+ cnf_filename = 'wmc.cnf'
186
+ to_DIMACS(circuit, cnf_filename)
185
187
  to_DIMACS_time = round(time.time() - start_time, 3)
186
188
  except TimeoutError:
187
189
  to_DIMACS_time = f'>{timeout}'
@@ -192,7 +194,7 @@ def qasm_eq_check_with_wmc(circuit1: str|QuantumCircuit, circuit2:str|QuantumCir
192
194
  signal.alarm(timeout)
193
195
  start_time = time.time()
194
196
  try:
195
- complex_number = run_wmc()
197
+ complex_number = run_wmc(cnf_filename)
196
198
  wmc_time = round(time.time() - start_time, 3)
197
199
  abs_num = np.sqrt(complex_number[0]**2 + complex_number[1]**2)
198
200
  log_wmc = round(np.log2(abs_num), 3)
@@ -217,7 +217,7 @@ def run_wmc(file='wmc.cnf'):
217
217
  real_part = 0
218
218
  imag_part = float(match.group(1))
219
219
  return real_part, imag_part
220
- return None
220
+ assert False, "WMC output format error, result: {}".format(result.stdout)
221
221
 
222
222
  if __name__ == "__main__":
223
223
  # from pathsum.pathsum import PathSum, F, Register
@@ -1,6 +1,7 @@
1
1
  import symengine as se
2
2
  import sympy as sp
3
3
  import numpy as np
4
+ import uuid
4
5
  from itertools import combinations, count
5
6
  from qiskit.circuit import Parameter, ParameterExpression
6
7
  from qiskit.circuit.tools.pi_check import pi_check
@@ -181,4 +182,7 @@ def find_new_variables(pathvar: set|frozenset, num_vars_needed = 1) -> list[se.S
181
182
  candidate_var = se.Symbol(f'y_{i}')
182
183
  if candidate_var not in pathvar:
183
184
  new_vars.append(candidate_var)
184
- return new_vars
185
+ return new_vars
186
+ def generate_unique_key():
187
+ unique_key = str(uuid.uuid4())
188
+ return unique_key
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QuPRS
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: QuPRS: Quantum Path-sum Reduction and Solver
5
5
  Author-email: Wei-Jia Huang <wei.jia.huang.physics@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/PhysicsQoo/QuPRS
@@ -28,6 +28,8 @@ Provides-Extra: dev
28
28
  Requires-Dist: ipykernel; extra == "dev"
29
29
  Requires-Dist: build; extra == "dev"
30
30
  Requires-Dist: pytest; extra == "dev"
31
+ Requires-Dist: pytest-xdist; extra == "dev"
32
+ Requires-Dist: pytest-cov; extra == "dev"
31
33
  Requires-Dist: pandas; extra == "dev"
32
34
  Requires-Dist: tqdm; extra == "dev"
33
35
  Dynamic: license-file
@@ -1,9 +1,11 @@
1
1
  .gitignore
2
+ Dockerfile
2
3
  LICENSE.md
3
4
  MANIFEST.in
4
5
  NOTICE.md
5
6
  README.md
6
7
  pyproject.toml
8
+ .github/workflows/docker-build.yml
7
9
  .github/workflows/pytest.yml
8
10
  .github/workflows/python-publish.yml
9
11
  src/QuPRS/__init__.py
@@ -8,5 +8,7 @@ qiskit-qasm3-import>=0.5.1
8
8
  ipykernel
9
9
  build
10
10
  pytest
11
+ pytest-xdist
12
+ pytest-cov
11
13
  pandas
12
14
  tqdm
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes