Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust code #77

Draft
wants to merge 95 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
04b80b5
Adding Rust code
ciaranra Sep 16, 2024
8269e08
Appeasing linting
ciaranra Sep 16, 2024
cc3eabd
Adding Cargo workspace toml
ciaranra Sep 16, 2024
33fcd70
Refactor file tree
ciaranra Sep 16, 2024
3201397
Update python workflow
ciaranra Sep 16, 2024
a72d339
Refactored to canonical Python structure
ciaranra Sep 16, 2024
95f63e9
Fixing pytest ini and workflow
ciaranra Sep 16, 2024
e1a0199
fixing linting settings
ciaranra Sep 18, 2024
276e9e1
fixing linting settings
ciaranra Sep 18, 2024
43b20c7
Merge remote-tracking branch 'origin/feat-rust' into feat-rust
ciaranra Sep 18, 2024
afeb74f
Fixed linting
ciaranra Sep 18, 2024
51fa119
Merge remote-tracking branch 'origin/development' into feat-rust
ciaranra Sep 24, 2024
d470f9d
Add Rust workflow + some linting.
ciaranra Sep 24, 2024
125831d
Fix Rust workflow format
ciaranra Sep 24, 2024
c8c686b
fix debuginfo?
ciaranra Sep 24, 2024
e659235
More yml reformatting...
ciaranra Sep 25, 2024
25fd2d3
Updating Rust workflow to remove deprecated actions
ciaranra Sep 25, 2024
c38b134
Modifying Python workflow to build, install, and test pecos-rslib
ciaranra Sep 25, 2024
1da6663
Simplify pecos-rslib workflow
ciaranra Sep 25, 2024
68e64f9
Python test workflow, adding venv setup and other improvements
ciaranra Sep 25, 2024
aa99884
Fixing link to requirements
ciaranra Sep 25, 2024
366e928
Getting rid of the working-directory defaults
ciaranra Sep 25, 2024
51863df
Fix/debug venv issue...
ciaranra Sep 25, 2024
9b3d35d
fixing pip install typo
ciaranra Sep 25, 2024
80de3c6
refactoring python tests location + removing old cuquantum
ciaranra Sep 25, 2024
8428d26
Simplifying python requirements
ciaranra Sep 25, 2024
4ddc85d
Adding Clippy to workflow + lint fixes
ciaranra Sep 25, 2024
9b85eca
Fix fmt
ciaranra Sep 25, 2024
f3a61e7
polish rust workflow
ciaranra Sep 25, 2024
f08e446
Refactored general crates into pecos-core
ciaranra Sep 25, 2024
8eb968a
Updated Rust PECOS's various dependencies.
ciaranra Sep 25, 2024
c49ff3a
Refactor python/pecos to python/quantum-pecos
ciaranra Sep 26, 2024
201d593
Adding pecos_rslib import to Python PECOS and integration test
ciaranra Sep 27, 2024
ae90ad3
Better import of rslib and fixing multiprocessing warning
ciaranra Sep 28, 2024
2071eb1
updating makefile and pre-commit
ciaranra Sep 28, 2024
2176e5f
More cleanup of pre-commit/makefile/etc.
ciaranra Sep 28, 2024
b013190
Improved makefile for root
ciaranra Sep 29, 2024
068c1cf
Updating workflow to temporarily remove pecos-rslib from requirements
ciaranra Sep 29, 2024
1606c75
Reverting to requiring numpy <2 + makefile polishing
ciaranra Sep 29, 2024
6091327
Fixing pre-commit linting
ciaranra Sep 29, 2024
c7a58de
Removing Makefile from python/ for now.
ciaranra Sep 29, 2024
6959abf
Rename crates/pecos-pyo3 to crates/pecos-python to be clearer on purpose
ciaranra Sep 29, 2024
df7e152
Add initial Rust to Python wrapper of Rust stabilizer sim
ciaranra Sep 29, 2024
0a5c9f6
Added Rust stabilizer sim to Python tests
ciaranra Sep 30, 2024
0ee6c7d
Removing Rust hello
ciaranra Sep 30, 2024
fabad5e
Fix subtle Rust test issue
ciaranra Sep 30, 2024
63b83c8
Got random circuit test working for Rust stab sim
ciaranra Sep 30, 2024
d5e1046
Updated READMEs and related.
ciaranra Sep 30, 2024
f8a3f2a
Test resetting file to link later.
ciaranra Sep 30, 2024
af14e3c
Adding symlink back in.
ciaranra Sep 30, 2024
05554bb
removing files to re-symlink
ciaranra Sep 30, 2024
fa932d0
adding symlinks back in
ciaranra Sep 30, 2024
633b981
Adding workflow to generate releases/distributions for Python
ciaranra Oct 1, 2024
0f77e1e
Triggering on push/pr for development branch for now...
ciaranra Oct 1, 2024
aa8c80e
fixing trigger...
ciaranra Oct 1, 2024
5691eb9
hopefully fixing build/release workflow for python
ciaranra Oct 1, 2024
c2f6abb
get release workflow working?
ciaranra Oct 1, 2024
5a77749
readme issue + pecos-rslib version
ciaranra Oct 1, 2024
96eda2b
delete workflow line oops
ciaranra Oct 1, 2024
6d7074c
Adding README back in.
ciaranra Oct 1, 2024
ca07ff6
Adding pecos-rslib workflow to build wheels. fingers crossed!!!
ciaranra Oct 1, 2024
2fd8abd
Fixing maturin using another Python version...
ciaranra Oct 1, 2024
1e345f4
Adding quantum-pecos sdist build
ciaranra Oct 1, 2024
1a99f29
Adding building quantum-pecos wheels
ciaranra Oct 1, 2024
eeecdf1
Fixing workflow indention
ciaranra Oct 1, 2024
e9e4568
bumping precommit
ciaranra Oct 1, 2024
6ca8f3b
Merge branch 'development' into feat-rust
ciaranra Oct 1, 2024
7ed76d8
Adding version consistency check + removing inits from tests
ciaranra Oct 2, 2024
e17e916
Asymmetrically bump Python version to trigger workflow error
ciaranra Oct 2, 2024
1cb73e7
Update python version to be consistent
ciaranra Oct 2, 2024
d28d9df
fixing pecos-rslib requirement + regression tests
ciaranra Oct 2, 2024
6f742d3
Adding Rust version consistency checks
ciaranra Oct 2, 2024
f4c28e5
update crates version checks
ciaranra Oct 2, 2024
f08b7b6
update crates version ckecks #2
ciaranra Oct 2, 2024
fe1016b
Causing inconsistent Rust crate version
ciaranra Oct 2, 2024
e6af889
fixing versioning
ciaranra Oct 2, 2024
96b6a32
Moving rust clifford gates to be supplied by default
ciaranra Oct 2, 2024
7f5b63c
More Rust stab sim tests
ciaranra Oct 3, 2024
fa1421e
Adding more tests for Rust stab sim
ciaranra Oct 4, 2024
fdc9c18
Add RSSparseSim to pecos.simulators
ciaranra Oct 4, 2024
f90d576
Refactored pySparseSim to SparseSimPy, RSSparseSim to SparseSimRs, an…
ciaranra Oct 4, 2024
062cf0d
Cleanup for examples and make clean
ciaranra Oct 6, 2024
4be3ed3
Replacing readme image with svg
ciaranra Oct 6, 2024
0249692
Linting updates. Moving clippy settings to workspace
ciaranra Oct 6, 2024
fcbded1
appeasing pedantic and cargo clippy
ciaranra Oct 7, 2024
8415a8c
Updating to pyo3 0.22
ciaranra Oct 7, 2024
054b0d5
updating make clean and removing rssparsesim apply_gate
ciaranra Oct 7, 2024
26d077e
Refactoring pecos-python to separate out sparse_sim
ciaranra Oct 7, 2024
854b79a
Updating README for the mixed Rust/Python project
ciaranra Oct 11, 2024
ac0d413
Fixing typo and updating requirements
ciaranra Oct 11, 2024
c70f3cb
Additional README polishing
ciaranra Oct 11, 2024
834dd2f
Further README polishing
ciaranra Oct 12, 2024
1a84ef0
Update README.md
ciaranra Oct 12, 2024
86980c9
Fixing readme spacing
ciaranra Oct 12, 2024
0483534
Update bibtex/citations
ciaranra Oct 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
45 changes: 0 additions & 45 deletions .github/workflows/python-app.yml

This file was deleted.

236 changes: 236 additions & 0 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
name: Python Release

on:
workflow_dispatch:
inputs:
sha:
description: Commit SHA
type: string
dry_run:
description: 'Dry run (build but not publish)'
type: boolean
default: true

pull_request:
branches:
- development
push:
branches:
- development

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
PYTHON_VERSION: '3.10'

defaults:
run:
shell: bash

jobs:
build_sdist_pecos_rslib:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

# maturin doesn't seem to like it when both pecos-python and pecos-rslib have READMEs
- name: Remove conflicting README.md
run: |
if [ -f crates/pecos-python/README.md ]; then
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
echo "Moved conflicting README.md to README.md.bak"
else
echo "No conflicting README.md found"
fi

- name: Build pecos-rslib SDist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: python/pecos-rslib

- name: Restore README.md
if: always()
run: |
if [ -f crates/pecos-python/README.md.bak ]; then
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
echo "Restored README.md from backup"
else
echo "No README.md backup found"
fi

- name: Test pecos-rslib SDist
run: |
pip install --force-reinstall --verbose python/pecos-rslib/dist/*.tar.gz
python -c 'import pecos_rslib; print(pecos_rslib.__version__)'

- name: Upload pecos-rslib SDist
uses: actions/upload-artifact@v4
with:
name: sdist-pecos-rslib
path: python/pecos-rslib/dist/*.tar.gz

build_wheels_pecos_rslib:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12']
architecture: [ x86_64, aarch64 ]
exclude:
- os: windows-latest
architecture: aarch64

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# maturin doesn't seem to like it when both pecos-python and pecos-rslib have READMEs
- name: Remove conflicting README.md
run: |
if [ -f crates/pecos-python/README.md ]; then
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
echo "Moved conflicting README.md to README.md.bak"
else
echo "No conflicting README.md found"
fi

- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
args: --release --out dist --interpreter python${{ matrix.python-version }}
working-directory: python/pecos-rslib
target: ${{ matrix.architecture == 'aarch64' && (matrix.os == 'macos-latest' && 'aarch64-apple-darwin' || 'aarch64-unknown-linux-gnu') || '' }}
manylinux: auto

- name: Restore README.md
if: always()
run: |
if [ -f crates/pecos-python/README.md.bak ]; then
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
echo "Restored README.md from backup"
else
echo "No README.md backup found"
fi

- name: Test wheel
if: matrix.architecture == 'x86_64'
run: |
pip install --force-reinstall --verbose python/pecos-rslib/dist/*.whl
python -c 'import pecos_rslib; print(pecos_rslib.__version__)'

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-pecos-rslib-${{ matrix.os }}-${{ matrix.architecture }}-py${{ matrix.python-version }}
path: python/pecos-rslib/dist/*.whl

build_sdist_quantum_pecos:
needs: [build_sdist_pecos_rslib, build_wheels_pecos_rslib]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Download pecos-rslib wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-ubuntu-latest-x86_64-py${{ env.PYTHON_VERSION }}
path: ./pecos-rslib-wheel

- name: Install pecos-rslib
run: pip install ./pecos-rslib-wheel/*.whl

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build

- name: Build quantum-pecos SDist
run: |
cd python/quantum-pecos
python -m build --sdist --outdir dist

- name: Test quantum-pecos SDist
run: |
pip install python/quantum-pecos/dist/*.tar.gz
# Note: Package name on PyPI is "quantum-pecos" but it imports as "pecos"
python -c 'import pecos; print(pecos.__version__)'

- name: Upload quantum-pecos SDist
uses: actions/upload-artifact@v4
with:
name: sdist-quantum-pecos
path: python/quantum-pecos/dist/*.tar.gz

build_wheels_quantum_pecos:
needs: [build_wheels_pecos_rslib, build_sdist_quantum_pecos]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Download pecos-rslib wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-ubuntu-latest-x86_64-py${{ matrix.python-version }}
path: ./pecos-rslib-wheel

- name: Install pecos-rslib
run: pip install ./pecos-rslib-wheel/*.whl

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build

- name: Build quantum-pecos wheel
run: |
cd python/quantum-pecos
python -m build --wheel --outdir dist

- name: Test quantum-pecos wheel
run: |
pip install python/quantum-pecos/dist/*.whl
# Note: Package name on PyPI is "quantum-pecos" but it imports as "pecos"
python -c 'import pecos; print(pecos.__version__)'

- name: Upload quantum-pecos wheel
uses: actions/upload-artifact@v4
with:
name: wheel-quantum-pecos-py${{ matrix.python-version }}
path: python/quantum-pecos/dist/*.whl
102 changes: 102 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Python test / linting

on:
push:
branches: [ "master", "development" ]
paths:
- 'python/**'
- '.github/workflows/python-test.yml'
- '.typos.toml'
- 'ruff.toml'
- '.pre-commit-config.yaml'
pull_request:
branches: [ "master", "development" ]
paths:
- 'python/**'
- '.github/workflows/python-test.yml'
- '.typos.toml'
- 'ruff.toml'
- '.pre-commit-config.yaml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


env:
RUSTFLAGS: -C debuginfo=0
RUST_BACKTRACE: 1
PYTHONUTF8: 1

defaults:
run:
shell: bash

jobs:
python-test:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Create and activate virtual environment
env:
BIN: ${{ matrix.os == 'windows-latest' && 'Scripts' || 'bin' }}
run: |
python -m venv .venv
source .venv/$BIN/activate
echo "$GITHUB_WORKSPACE/.venv/$BIN" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install maturin pytest pre-commit
echo "Temporarily removing pecos-rslib from requirements..."
grep -v "pecos-rslib" python/quantum-pecos/requirements.txt > temp_requirements.txt
echo "Installing project requirements (excluding pecos-rslib)..."
pip install -r temp_requirements.txt
echo "Cleaning up temporary files..."
rm temp_requirements.txt

- name: Set up Rust
run: rustup show

- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: python/pecos-rslib

- name: Install pecos-rslib with maturin develop
run: |
cd python/pecos-rslib
maturin develop

- name: Install pure Python PECOS
run: pip install ./python/quantum-pecos/

- name: Run pre-commit checks
run: |
pre-commit run --all-files --show-diff-on-failure

- name: Run standard tests
run: |
pip install pytest-cov
pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html

- name: Run tests with optional dependencies
run: |
pip install pytest-cov
pip install ./python/quantum-pecos/[all]
pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
Loading