Skip to content

Commit 8afff81

Browse files
authored
Merge pull request #287 from SoftwareQuTech/release4.0.0-new_sdk
Release4.1
2 parents 98ec7d7 + d697397 commit 8afff81

254 files changed

Lines changed: 15387 additions & 5819 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bumpversion.cfg

Lines changed: 0 additions & 8 deletions
This file was deleted.

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text=auto eol=lf
2+
*.png binary
3+
*.jpg binary
4+
*.gif binary

.github/workflows/actions.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- uses: actions/checkout@master
1111
- uses: actions/setup-python@master
1212
with:
13-
python-version: 3.8
13+
python-version: "3.12"
1414
- run: |
1515
make install
1616
make lint
@@ -22,9 +22,10 @@ jobs:
2222
- uses: actions/checkout@master
2323
- uses: actions/setup-python@master
2424
with:
25-
python-version: 3.8
25+
python-version: "3.12"
2626
- run: |
2727
make install
28+
make test-deps
2829
make tests
2930
3031
examples:
@@ -34,7 +35,7 @@ jobs:
3435
- uses: actions/checkout@master
3536
- uses: actions/setup-python@master
3637
with:
37-
python-version: 3.8
38+
python-version: "3.12"
3839
- run: |
3940
make install
4041
make examples

.github/workflows/docs.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build docs
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Build Docs
8+
runs-on: ubuntu-latest
9+
# We only execute this step if the commit is tagged, i.e., this is a release
10+
if: startsWith(github.ref, 'refs/tags')
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@master
14+
- name: Build docs
15+
uses: actions/setup-python@master
16+
with:
17+
python-version: "3.12"
18+
# We *need* to install projectq to generate documentation
19+
# This is needed because sphinx analyzes SimulaQron's code to generate the HTML;
20+
# this implies that the modules are imported (but not executed), which therefore
21+
# imports projectq classes.
22+
- name: Install simulaqron and build docs
23+
run: |
24+
make install-optional
25+
cd docs
26+
make install-deps
27+
make build
28+
- name: Upload static files as artifact
29+
id: deployment
30+
uses: actions/upload-pages-artifact@v4
31+
with:
32+
path: docs/build/html/
33+
34+
deploy:
35+
name: Deploy docs
36+
needs: build
37+
runs-on: ubuntu-latest
38+
# We only execute this step if the commit is tagged, i.e., this is a release
39+
if: startsWith(github.ref, 'refs/tags')
40+
environment:
41+
name: github-pages
42+
url: ${{ steps.deployment.outputs.page_url }}
43+
steps:
44+
- name: Deploy to GitHub Pages
45+
id: deployment
46+
uses: actions/deploy-pages@v4

.github/workflows/netqasm.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/publish.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish Python distributions to PyPI
2+
3+
on: push
4+
jobs:
5+
build-n-publish:
6+
name: Build and publish Python distributions to PyPI
7+
runs-on: ubuntu-latest
8+
# We only execute this step if the commit is tagged, i.e., this is a release
9+
if: startsWith(github.ref, 'refs/tags')
10+
# Use the following for PyPI deployments
11+
environment:
12+
name: pypi
13+
url: https://pypi.org/p/simulaqron
14+
# Use the following for TestPyPI deployments
15+
# environment:
16+
# name: testpypi
17+
# url: https://test.pypi.org/p/simulaqron
18+
permissions:
19+
id-token: write
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@master
23+
- name: Set up Python 3.12
24+
uses: actions/setup-python@master
25+
with:
26+
python-version: "3.12"
27+
- name: Install pypa/build
28+
run: >-
29+
python3.12 -m
30+
pip install
31+
build
32+
--user
33+
- name: Build a binary wheel and a source tarball
34+
run: >-
35+
python3.12 -m
36+
build
37+
--sdist
38+
--wheel
39+
--outdir dist/
40+
.
41+
# - name: Publish distribution to Test PyPI
42+
# uses: pypa/gh-action-pypi-publish@release/v1.14
43+
# with:
44+
# repository_url: https://test.pypi.org/legacy/
45+
- name: Publish distribution to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1.14

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.pyc
22
.*.sw?
33
*.DS_Store
4+
*.whl
45
/docs/build/*
56
/build/*
67
/dist/*
@@ -9,6 +10,9 @@
910

1011
.idea/*
1112
.vscode/*
13+
.claude/*
1214

1315
cqc/backend/logFile*
1416
examples/**/log/*
17+
18+
*.out.txt

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ For more details refer to the [documentation](https://softwarequtech.github.io/S
55

66
Upcoming
77
--------
8+
2026-03-13 (v4.0.1)
9+
-------------------
10+
- Migrated project specification to use modern TOML approach.
11+
- Tested working with Python versions 3.10, 3.11 and 3.12.
12+
- Added new SDK for easily creating SimulaQron applications. This new SDK allows to also create
13+
client-server applications using event-based programming paradigm.
14+
- Updated the SimulaQron network configuration file format. This is done to align the network
15+
configuration file with the data required by SimulaQron "native" mode and the "NetQASM" mode.
16+
- Updated documentation of most of the undocumented functions and to match the new developments.
817

918
2021-11-18 (v4.0.0)
1019
-------------------

CLAUDE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SimulaQron Development Conventions
2+
3+
## Hard Requirements
4+
5+
### Examples
6+
- Examples MUST always use separate files per node (e.g. `nodeTest-client.py`, `nodeTest-server.py`), never single-file programs. Students must be able to run each node on a separate machine.
7+
- Follow the `new-sdk/template-client-server` structure: two node scripts + `run.sh` + `terminate.sh` + config JSONs.
8+
- All nodes should print their own output (not rely on return values visible only to the test harness).
9+
10+
### Connection Pattern
11+
- Prefer creating a `NetQASMConnection` once and reusing it with `flush()` for multi-round quantum programs, rather than opening/closing with `with` each round.
12+
- `conn.flush()` is the sync point that makes measurement results readable via `int(m)`.
13+
14+
### Backends
15+
- Use `stabilizer` backend by default in examples and tests unless non-Clifford gates are needed.
16+
- `projectq` is deprecated / hard to install. Prefer `qutip` when full state simulation is needed.
17+
18+
## File Conventions
19+
- **Examples:** `examples/new-sdk/` — all new examples use the new SDK
20+
- **Tests:** `tests/slow/sdk/` — SDK-level integration tests
21+
- **Core code:** `simulaqron/` — simulator source
22+
- **Docs:** `docs/` — Sphinx documentation (currently outdated, being rewritten)
23+
24+
## Git / Commit Policy
25+
- **Always run `make ci` before committing.** All linting, tests, and examples must pass before any commit is created.
26+
- Never commit or push without explicit user approval.
27+
28+
## Virtual Environment
29+
- The project venv is at `.venv/` — activate with `source .venv/bin/activate`
30+
- Install with `pip install -e .` (skip `[test]` if projectq build fails)

Dockerfile

Lines changed: 88 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,88 @@
1-
## Dockerfile
2-
# This container provides a complete run-time environment for SimulaQron.
3-
#
4-
## Build:
5-
# From inside the top-level SimulaQron directory run
6-
#
7-
# docker build -t <image_name> .
8-
#
9-
# where you should replace <image_name> with the name you want to give to the
10-
# docker image.
11-
#
12-
## Run:
13-
# To start the container and enter the shell prompt inside, run
14-
#
15-
# docker run -it <image_name>
16-
#
17-
# This will start a docker container with SimulaQron inside the
18-
# /workspace/SimulaQron directory (this default can be changed, by changing the
19-
# WORKSPACE variable in this file). Note that this is only a COPY of the
20-
# SimulaQron directory that was made during the build step so if you make any
21-
# changes on the host system, they will not be reflected in the container until
22-
# you rebuild the image.
23-
#
24-
# However, if you wish, you can mount the host's SimulaQron directory into the
25-
# container rather than using a copy made during the build step, you need to
26-
# explicitly mount it when starting the container, e.g.
27-
#
28-
# docker run -it -v /path/to/SimulaQron:/workspace/SimulaQron <image_name>
29-
#
30-
# This will mount /path/to/SimulaQron inside the container in
31-
# /workspace/SimulaQron. Note that on Linux systems with SELinux present, the
32-
# mount option has to be `-v /path/to/SimulaQron:/workspace/SimulaQron:z`.
33-
#
34-
## Multiple shells:
35-
# To attach to a running container with a new shell run
36-
#
37-
# docker exec -it <container_name> bash
38-
#
39-
# where <container_name> is the name of the running container (this is in
40-
# general not the same as the image name). To find what name your container
41-
# has, run `docker ps`.
42-
43-
FROM ubuntu:18.04
44-
LABEL author="Wojciech Kozlowski <w.kozlowski@tudelft.nl>"
45-
46-
# Update docker image
47-
ENV DEBIAN_FRONTEND=noninteractive
48-
RUN apt-get update && apt-get upgrade -y
49-
50-
# Install Python 3
51-
RUN apt-get install -y python3 python3-pip python3-tk
52-
53-
# Set a UTF-8 locale - this is needed for some python packages to play nice
54-
RUN apt-get -y install language-pack-en
55-
ENV LANG="en_US.UTF-8"
56-
57-
RUN pip3 install simulaqron
1+
# If you need a slim version, use "alpine" base instead of trixie (Debian)
2+
#FROM python:3.12-alpine AS base-image
3+
FROM ubuntu:24.04 AS base-image
4+
5+
# Install packages
6+
7+
#RUN apk add --no-cache bash vim nano libstdc++ libgomp
8+
RUN apt-get update
9+
RUN apt-get dist-upgrade -y
10+
RUN apt-get install -y bash vim nano libgomp1 adduser git openssl make software-properties-common
11+
12+
RUN add-apt-repository ppa:deadsnakes/ppa
13+
RUN apt-get update
14+
15+
# Install Python 3.12
16+
RUN apt-get install -y python3.12-full python3.12-dev
17+
18+
# Switch to Bash
19+
SHELL ["/bin/bash", "-c"]
20+
21+
# Delete the build-in user - not needed in alpine images
22+
RUN userdel -r ubuntu
23+
24+
# Create student user
25+
ARG GNAME=student
26+
ARG GID=1000
27+
ARG UNAME=student
28+
ARG UID=1000
29+
ARG UHOME=/home/student
30+
ENV HOME=${UHOME}
31+
RUN set -o errexit -o nounset
32+
RUN addgroup --gid ${GID} "${GNAME}"
33+
RUN adduser --home "${UHOME}" --disabled-password --uid ${UID} --ingroup "${GNAME}" "${UNAME}"
34+
WORKDIR ${UHOME}
35+
36+
# Remove unnecessary software
37+
RUN apt-get purge -y adduser software-properties-common
38+
RUN apt-get autoremove -y
39+
40+
FROM base-image AS venv-image
41+
42+
# Install build essentials, to correctly build python deps
43+
# We install it only for this stage, so we create a lighter docker image for executing
44+
#RUN apk add --no-cache alpine-sdk
45+
RUN apt-get update
46+
RUN apt-get install -y build-essential cmake linux-headers-generic
47+
48+
# Create python virtual environment
49+
WORKDIR ${UHOME}
50+
RUN python3.12 -m venv simulaqron-venv
51+
# We have to "manually" activate the virtual environment
52+
ENV PATH="${UHOME}/simulaqron-venv/bin:$PATH"
53+
54+
# Install SimulaQron
55+
# Option 1: Install from the wheel file
56+
# Copy the simulaqron wheel into the container
57+
COPY dist/*.whl ${UHOME}
58+
RUN pip install *.whl
59+
RUN rm *.whl
60+
61+
# Install extra packages that need build-essential
62+
RUN pip install "qutip<5.0.0"
63+
RUN pip install "setuptools<81" pybind11
64+
RUN pip install "git+https://github.com/ProjectQ-Framework/ProjectQ.git@v0.8.0" --no-build-isolation
65+
66+
# Option 2: (Recommended for release) Install from PyPI
67+
#RUN pip install "simulaqron[opt]>=4.0.1"
68+
69+
FROM base-image AS run-image
70+
71+
# Copy installed python packages from previous image
72+
COPY --from=venv-image --chown=${UNAME} ${UHOME}/simulaqron-venv "${UHOME}/.local"
73+
# Since these files come from a python virtual environment
74+
# we need to fix some absolute paths
75+
WORKDIR ${UHOME}/.local/bin
76+
RUN sed -i "s|${UHOME}/simulaqron-venv/|${UHOME}/.local/|g" *
77+
# Activate the "virtual environment" we just copied
78+
ENV PATH="${UHOME}/.local/bin:${UHOME}/.local:$PATH"
79+
80+
# Configure libgomp to use a single thread to avoid deadlocks in simulaqron
81+
ENV OMP_NUM_THREADS=1
82+
83+
# Switch to user student
84+
USER student
85+
WORKDIR ${UHOME}
86+
RUN echo 'export PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "' >> ~/.bashrc
87+
88+
CMD bash

0 commit comments

Comments
 (0)