Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1684491
Add basic structure for OpenQASM processing
ekulos-code Jan 29, 2025
ffe94da
Merge branch 'develop' into circuit-processing
ekulos-code Jan 29, 2025
57e8ca0
Add execution and optimization solvers
ekulos-code Mar 10, 2025
b170c29
Merge branch 'develop' into circuit-processing
ekulos-code Mar 10, 2025
a7f335e
Merge dev, account for checkstyle errors
ekulos-code Mar 10, 2025
1d63db9
feat: Update python process runner to execute via venv
Elscrux Mar 13, 2025
4777948
feat: Restructure requirement files
Elscrux Mar 13, 2025
4657c1c
feat: Restructure application.properties and pass venv to python proc…
Elscrux Mar 13, 2025
7dad51f
chore: Update miniconda version
Elscrux Mar 18, 2025
f365a53
debug
Elscrux Mar 18, 2025
49db2e6
feat: Make api token setting required
Elscrux Mar 18, 2025
1194926
Merge pull request #134 from ProvideQ/feat/required-settings
koalamitice Mar 19, 2025
c8458e7
Implement suggestions
ekulos-code Mar 19, 2025
a765973
fix: changed cirq version because the defined one was not available o…
koalamitice Mar 25, 2025
7b9277c
fix: checkstyle issues
koalamitice Mar 25, 2025
383b9d6
fix: another checkstyle error
koalamitice Mar 25, 2025
be29e7c
fix: added command to Dockerfile to ensure that ganak binaries are ex…
koalamitice Apr 1, 2025
6a4fa5d
fix: testing new GAMS version
koalamitice Apr 2, 2025
771e17c
fix: removed chmod from dockerfile and applied it directly to solvers
koalamitice Apr 2, 2025
b5cd884
fix: improved error messages for testing / only print problem states …
koalamitice Apr 2, 2025
cf64b9a
fix: checkstyle issue
koalamitice Apr 3, 2025
56febe6
fix: mentioned qiskit version explicitly because qiskit 2.0 does not …
koalamitice Apr 3, 2025
5ee7eb6
fix: added networkx python dependency to gams setup, removed gams req…
koalamitice Apr 3, 2025
b5f70d1
fix: updated gams-maxcut cholesky transformation calls
koalamitice Apr 7, 2025
dc765c8
fix: trying some minor changes in maxcut gams script
koalamitice Apr 9, 2025
6e5940b
fix: added exit to script to enforce ci pipeline failure when venv se…
koalamitice Apr 9, 2025
c238a4d
add: caching for gradle and venv dependencies
koalamitice Apr 9, 2025
1e2a839
fix: fixed paths in caching jobs, removed unnecessary debug output
koalamitice Apr 9, 2025
ad3af91
fix: gradle path for caching
koalamitice Apr 9, 2025
5b6b878
fix: removed gradle caching for now
koalamitice Apr 9, 2025
89acbe9
feat: Make api token setting required
Elscrux Mar 18, 2025
3b6a049
chore: adjusted readme for new venv installation, added python instal…
koalamitice Apr 15, 2025
3c47662
fix: changed python version naming
koalamitice Apr 15, 2025
600ff25
fix: reverted ci pipeline change
koalamitice Apr 15, 2025
10fca2d
Merge pull request #137 from ProvideQ/feat/python-venvs
koalamitice Apr 15, 2025
ab60556
docs: Update path
Elscrux Apr 22, 2025
4873ec2
refactor: Use demonstrator specific application property names for cp…
Elscrux Apr 22, 2025
53aa6c8
updated release version
koalamitice May 7, 2025
7687633
Merge pull request #139 from ProvideQ/release/0.4.1
koalamitice May 7, 2025
e803a09
Merge pull request #140 from ProvideQ/main
koalamitice May 8, 2025
6f632d7
Add basic structure for OpenQASM processing
ekulos-code Jan 29, 2025
d36e66f
Add execution and optimization solvers
ekulos-code Mar 10, 2025
0cb9b38
Merge dev, account for checkstyle errors
ekulos-code Mar 10, 2025
347d7be
Implement suggestions
ekulos-code Mar 19, 2025
4b52ab3
Merge remote-tracking branch 'origin/circuit-processing' into circuit…
ekulos-code May 12, 2025
0ca1d22
Preliminary migration for circuit processing to venvs
ekulos-code May 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/ci-cd-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Set up GAMS
shell: bash # required for the source command
env:
Expand All @@ -27,19 +29,32 @@ jobs:
echo "/opt/conda/bin" >> "$GITHUB_PATH"
echo "$GAMS_PATH" >> "$GITHUB_PATH"
echo "GMSPYTHONLIB=/opt/conda/envs/gams/lib/libpython3.10.so" >> "$GITHUB_ENV"

- name: Cache Venv dependencies
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/venv
# update venv when setup script or any solver has changed:
key: venv-${{ runner.os }}-${{ hashFiles('scripts/ci-setup-solvers.sh', 'solvers/**') }}
restore-keys: |
venv-${{ runner.os }}-

- name: Install solver dependencies
run: ./scripts/ci-setup-solvers.sh

- name: Run checks
shell: bash # required for the source command
run: |
run: | # change to "./gradlew check --info" for more debugging output.
source /opt/conda/bin/activate gams
./gradlew check --info
./gradlew check

- name: Archive test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-report
path: build/reports/tests/test/

- name: Archive style reports
if: always()
uses: actions/upload-artifact@v4
Expand Down
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,12 @@ A web-based user interface can be found in our
1. Python-based Solvers (Qiskit, Cirq, Dwave, Qrisp)
1. Install Python
2. Install Python dependencies by running `python scripts/install-python-dependencies.py` <br>
Alternatively, run `pip install -r requirements.txt` on all requirement.txt files in the /solvers directory.
**Note:** Ensure that you execute the script from the root directory! Otherwise the created venv/ directory might be created at the wrong path.
2. Compiled Solvers (e.g. used for VRP and TSP)
1. Solvers implemented in compiled languages must be executed via binaries that are compiled for your operating system. For those types of solvers we usually include pre-compiled binaries for windows, mac (only arm), and unix.
* General Note: Solvers might be programmed in different languages. E.g., LKH-3 is implemented in C. Make sure that the solver-specific language is installed on your system.
2. In case the pre-compiled versions do not work on your machine: re-compile them:
* LKH-3:
1. Build LKH-3 using the offical guide: http://webhotel4.ruc.dk/~keld/research/LKH-3/
2. Put the build binary in `solvers/lkh/bin`, replace the binary that matches your OS.
* VRP-Pipeline (used for K-means, Two Phase Clustering, VRP to QUBO convertion):
1. Install Rust: https://www.rust-lang.org/tools/install
2. Install a specific Rust nightly build (needed cause the solver uses experimental features): `rustup install nightly-2023-07-01`
3. Check how the nightly build is called on your machine (this is shown when running the install command, on Mac it is called *nightly-2023-07-01-aarch64-apple-darwin*)
4. Set the nightly build as default: `rustup default nightly-2023-07-01(... specific version name on machine)`
5. Download source code of the VRP-Pipeline: https://github.com/ProvideQ/hybrid-vrp-solver
6. build the source code using `cargo build`
7. Put the build binary in `solvers/berger-vrp/bin`, replace the binary that matches your OS.
1. Solvers implemented in compiled languages must be executed via binaries that are compiled for your operating system.
For those types of solvers we usually include pre-compiled binaries for windows, mac (only arm), and unix.
2. In case the pre-compiled versions do not work on your machine: re-compile them.
Detailed compliation guides can be found in the *solvers/custom/[solver-name]* directory.
3. GAMS (multiple solvers are build on this):
1. Install a python env that works with GAMS (skip this step if you don't need GAMS)
2. Install GAMS. (https://www.gams.com/download/)
Expand All @@ -42,7 +32,7 @@ A web-based user interface can be found in our
`pip install gams[core,connect] --find-links <path-to-gams>/api/python/bdist`
* If you get an error building `psycopg2`, try to install these postgres packages:
`sudo apt-get install postgresql libpq-dev` and run the `pip install ...` command again
8. Install the python dependencies we use in our python packages: `pip install -r gams/requirements.txt`
8. Install the python dependencies we use in our python packages: `pip install -r ./solvers/gams/python/requirements.txt`
4. Run the server using `./gradlew bootRun`

## Deployment
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = 'edu.kit.provideq'
version = '0.4.0'
version = '0.4.1'
sourceCompatibility = '17'

repositories {
Expand Down
6 changes: 4 additions & 2 deletions demonstrators/cplex/mip-solver/mip-solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import sys
from io import StringIO

if len(sys.argv) != 4:
raise TypeError('This script expects exactly 3 arguments: max number of variables, step size, and number of repetitons')

arg_count = len(sys.argv) - 1
if arg_count != 3:
raise TypeError(f'This script expects exactly 3 arguments but got {arg_count}: max number of variables, step size, and number of repetitons')

maxNbVars = int(sys.argv[1])
stepSize = int(sys.argv[2])
Expand Down
40 changes: 30 additions & 10 deletions scripts/install-python-dependencies.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
import os
import subprocess
import platform

script_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = os.path.dirname(script_dir)
base_dirs = [
os.path.join(script_dir, '..', 'solvers'),
os.path.join(script_dir, '..', 'demonstrators')
os.path.join(root_dir, 'demonstrators'),
os.path.join(root_dir, 'solvers'),
]

exitCode = 0
for base_dir in base_dirs:
for root, dirs, files in os.walk(base_dir):
# Check if 'requirements.txt' is in the current directory
req_file = os.path.join(root, 'requirements.txt')
if os.path.exists(req_file):
print(f"Found requirements.txt in {root}, installing dependencies...")
try:
subprocess.run(['pip', 'install', '-r', req_file], check=True) # single thread to avoid dep. errors
except subprocess.CalledProcessError as e:
print(f"Error installing requirements for {root}: {e}")
# Iterate over framework directory (cirq, gams, qiskit, etc.)
for framework_name in dirs:
framework_dir = os.path.join(root, framework_name)

# Iterate over problem directory (knapsack, tsp, etc.)
for solver_name in os.listdir(framework_dir):
solver_dir = os.path.join(framework_dir, solver_name)
req_file = os.path.join(solver_dir, 'requirements.txt')
if os.path.exists(req_file):
venv_name = f"{os.path.basename(root)}_{framework_name}_{solver_name}"
print(f"Setting up virtual environment '{venv_name}' for {solver_dir}...")
try:
venv_path = os.path.join('venv', venv_name)
subprocess.run(['python3', '-m', 'venv', venv_path], check=True)
if platform.system() == 'Windows':
pip_executable = os.path.join(venv_path, 'Scripts', 'pip.exe')
else:
pip_executable = os.path.join(venv_path, 'bin', 'pip')
subprocess.run([pip_executable, 'install', '-r', req_file], check=True)
except subprocess.CalledProcessError as e:
print(f"Error setting up virtual environment for {solver_dir}: {e}")
exitCode = 1

# let pipeline fail if there was an error in the venv setup.
exit(exitCode)
7 changes: 4 additions & 3 deletions scripts/setup-gams.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apt-get install curl --yes
# iisaa/gams-docker (https://github.com/iiasa/gams-docker/blob/master/Dockerfile, GPL-3.0 licensed)

# Configure the GAMS version here
GAMS_VERSION_RELEASE_MAJOR=42.1
GAMS_VERSION_RELEASE_MAJOR=49.3
GAMS_VERSION_HOTFIX=0

# download the self-extracting archive to /opt/gams/gams.exe and run/extract it
Expand All @@ -46,9 +46,9 @@ cd "$GAMS_PATH" &&\

# === Install conda ===
# download installer, verify it and make it executable
curl --show-error --output /opt/conda-installer/install.sh --create-dirs "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.1.0-1-Linux-x86_64.sh"
curl --show-error --output /opt/conda-installer/install.sh --create-dirs "https://repo.anaconda.com/miniconda/Miniconda3-py310_25.1.1-1-Linux-x86_64.sh"
cd /opt/conda-installer
echo "32d73e1bc33fda089d7cd9ef4c1be542616bd8e437d1f77afeeaf7afdb019787 install.sh" | sha256sum --check
echo "585972959914f1f9be463284d477717eb10f7306bda63f2ec3c4c86047b9dd72 install.sh" | sha256sum --check
chmod +x ./install.sh

# Install python (with python -> python3 alias) and pip from miniconda
Expand All @@ -73,6 +73,7 @@ source /opt/conda/bin/activate gams

# install GAMS links for python
pip install gamsapi[core,connect] --find-links /opt/gams/gams${GAMS_VERSION_RELEASE_MAJOR}_linux_x64_64_sfx/api/python/bdist
pip install networkx

# make GAMS use our python version
echo "export GMSPYTHONLIB=/opt/conda/envs/gams/lib/libpython3.10.so" >> ~/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys
from pytket.qasm import circuit_from_qasm_str
from pytket.extensions.qiskit import AerBackend

from qiskit_aer.noise import NoiseModel
from qiskit_aer.noise.errors import depolarizing_error

input_path = sys.argv[1]
num_runs = sys.argv[2]

# read input from file
with open(input_path, 'r') as input_file:
text = input_file.read()

input_circuit = text
shots = num_runs

try:
circuit = circuit_from_qasm_str(input_circuit)
except Exception as e:
print("Was not able to convert to OpenQASM: ", e)
sys.exit(1)

# https://docs.quantinuum.com/tket/user-guide/manual/manual_noise.html
noise_model = NoiseModel()
noise_model.add_readout_error([[0.9, 0.1],[0.1, 0.9]], [0])
noise_model.add_readout_error([[0.95, 0.05],[0.05, 0.95]], [1])
noise_model.add_quantum_error(depolarizing_error(0.1, 2), ["cx"], [0, 1])

backend = AerBackend(noise_model)
c = backend.get_compiled_circuit(circuit)
handle = backend.process_circuit(c, n_shots=int(shots))
counts = backend.get_result(handle).get_counts()
print(counts)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys
from pytket.qasm import circuit_from_qasm_str
from pytket.extensions.qiskit import AerBackend

input_path = sys.argv[1]
num_runs = sys.argv[2]

# read input from file
with open(input_path, 'r') as input_file:
text = input_file.read()

input_circuit = text
shots = num_runs

try:
circuit = circuit_from_qasm_str(input_circuit)
except Exception as e:
print("Was not able to convert to OpenQASM: ", e)
sys.exit(1)

backend = AerBackend()
c = backend.get_compiled_circuit(circuit)
handle = backend.process_circuit(c, n_shots=shots)
counts = backend.get_result(handle).get_counts()
print(counts)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys
from pytket.qasm import circuit_from_qasm_str
from pytket.extensions.qulacs import QulacsBackend

input_path = sys.argv[1]
num_runs = sys.argv[2]

# read input from file
with open(input_path, 'r') as input_file:
text = input_file.read()

input_circuit = text
shots = num_runs

try:
circuit = circuit_from_qasm_str(input_circuit)
except Exception as e:
print("Was not able to convert to OpenQASM: ", e)
sys.exit(1)

backend = QulacsBackend()
c = backend.get_compiled_circuit(circuit)
handle = backend.process_circuit(c, n_shots=shots)
counts = backend.get_result(handle).get_counts()
print(counts)
3 changes: 3 additions & 0 deletions solvers/circuitprocessing/circuitexecution/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytket
pytket-qiskit
pytket-qulacs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys
from pytket.qasm import circuit_from_qasm_str, circuit_to_qasm_str
from pytket.predicates import CompilationUnit
from pytket.passes import DecomposeMultiQubitsCX

input_path = sys.argv[1]

# read input from file
with open(input_path, 'r') as input_file:
text = input_file.read()

input_circuit = text

try:
circuit = circuit_from_qasm_str(input_circuit)
except Exception as e:
print("Was not able to convert to OpenQASM: ", e)
sys.exit(1)

pass1 = DecomposeMultiQubitsCX()
cu = CompilationUnit(circuit)
pass1.apply(cu)

print(circuit_to_qasm_str(cu.circuit))

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys
from pytket.qasm import circuit_from_qasm_str, circuit_to_qasm_str
from pytket.predicates import CompilationUnit
from pytket.passes import RemoveRedundancies

input_path = sys.argv[1]

# read input from file
with open(input_path, 'r') as input_file:
text = input_file.read()

input_circuit = text

try:
circuit = circuit_from_qasm_str(input_circuit)
except Exception as e:
print("Was not able to convert to OpenQASM: ", e)
sys.exit(1)

pass1 = RemoveRedundancies()
cu = CompilationUnit(circuit)
pass1.apply(cu)

print(circuit_to_qasm_str(cu.circuit))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytket
8 changes: 8 additions & 0 deletions solvers/cirq/max-cut/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file describes the python package requirements for the Cirq MaxCut solver
matplotlib
cirq
networkx
pandas

sympy
numpy
3 changes: 0 additions & 3 deletions solvers/cirq/requirements.txt

This file was deleted.

8 changes: 8 additions & 0 deletions solvers/custom/berger-vrp/HOW_TO_BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Install Guide for the VRP-Pipeline (used for K-means, Two Phase Clustering, VRP to QUBO convertion):
1. Install Rust: https://www.rust-lang.org/tools/install
2. Install a specific Rust nightly build (needed cause the solver uses experimental features): `rustup install nightly-2023-07-01`
3. Check how the nightly build is called on your machine (this is shown when running the install command, on Mac it is called *nightly-2023-07-01-aarch64-apple-darwin*)
4. Set the nightly build as default: `rustup default nightly-2023-07-01(... specific version name on machine)`
5. Download source code of the VRP-Pipeline: https://github.com/ProvideQ/hybrid-vrp-solver
6. build the source code using `cargo build`
7. Put the build binary in `solvers/berger-vrp/bin`, replace the binary that matches your OS.
1 change: 0 additions & 1 deletion solvers/custom/hs-knapsack/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# This file describes the python package requirements for the knapsack problem solver

knapsack-pip == 0.2
5 changes: 5 additions & 0 deletions solvers/custom/lkh/HOW_TO_BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The following steps explain how build the binaries of the LKH-3 solvers that are placed in solvers/custom/lkh/bin.
The binaries are called via the vrp_lkh.py wrapper.

1. Build LKH-3 using the offical guide: http://webhotel4.ruc.dk/~keld/research/LKH-3/
2. Put the build binary in `solvers/lkh/bin`, replace the binary that matches your OS.
1 change: 1 addition & 0 deletions solvers/custom/sharp-sat-bruteforce/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file describes the python package requirements for the Sharp SAT solver
File renamed without changes.
2 changes: 2 additions & 0 deletions solvers/dwave/qubo/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file describes the python package requirements for the Dwave Qubo solver
dwave-ocean-sdk == 6.4.1
5 changes: 0 additions & 5 deletions solvers/dwave/requirements.txt

This file was deleted.

Loading