Skip to content

Commit

Permalink
Adding Rust (#51)
Browse files Browse the repository at this point in the history
* Added .sim_name to QOps. Added angle info to QOp.angle

* Added code to identify Clifford gates from more general gates

* Added conversion to Clifford support for RZ , RZZ, and R1XY

* Tweaking generic machine to clear state

* Add test of operation type before running qsims.

* Initial SLR files

* adding back "maturin" branch + recent updates

* Adding physical gates needed to build up circuits.

* Shifting it back from pypecos/ to python/ for now.

* Adding more crate stubs

* Moving Cython/Cpp out to own dirs

* ruff/black reformatting

* rs cointoss sim + workspace tweak

* pyproject cleanup

* Initial Cython compilation.

* Rust linting + linting reqs

* reformatting/liniting

* Moved sim code to sim.rs for pyo3pecos

* switched from pecos-pyo3 to pyo3pecos

* Fix pyo3pecos import issue.

* Preventing ruff issue with using local import for pyo3pecos

* restructure cpp/ and remove unneeded .gitignores

* pecos-cli stub

* getting cysparsesim to compile with cpp seperated

* Adding general Instr type and list types

* Adding slr code

* Updated linting/formatting

* Updating lint/formatting

* Add some Makefiles

* fix github workflow requirements

* fix github workflow python installation directory

* fix github workflow fix python test directory

* bump python action from v4 to v5

* Cleaning up cython and improving makefile clean

* Got cypecos to install correctly.

* Moving slr down to reduce nesting

* Black update

* Move cysparsesim to cypecos.cysparsesim

* Fixing linting/formating

* Moving linting/formatting settings to root

* Cleaning up makefiles, pyroject files, etc.

* Moving ruff settings to fix mac issue

* Simplifying black settings

* Simplifying ruff settings

* Simplifying ruff settings for cython

* Removing tool.ruff

* attempting full ruff root simplification again

* Updating ruff pre-commit

* ruff fix for WIndows & Mac

* Fix weird ruff formatting

* First attempt at building cpp sparsesim with Rust

* Improve makefile build and test + added __version__ to __all__

* fix slr __version__

* Creating a slr.std folder to hold common extension to core to the DSL

* Updating makefile to make cleaning less drastic

* Fix slr import issue.

* maturin workflow

* Including build requirement

* Moving building wheels before pytest

* Simplier maturin workflow

* Adding py 3.11 and 3.12 to workflow.

* Adding pre-commit checks to the workflow

* Adding running pytest to linux workflow

* Setting up a venv for maturin in linux workflow

* Making the venv persistent in linux workflow

* Isolating the venv for testing.

* Reusing built wheel for test purposes.

* Have venv install wheel of the correct python version.

* Run pytest according to maturin

* Using the original linux workflow from maturin

* Adding debug info to check linux pytest workflow

* For pip to not look in pypi

* fix pip typo

* Force specific wheel to install

* Forcing install of wheel for other linux versions

* Refining workflow for linux aarch64

* Adding additional build requirements for ppc64le

* Refinements of using prebuilt packages for linux workflow

* Simplifying workflow

* opening up available archs

* Restricting Linux version to most common systems.

* fixing action typo

* Add pytest to Windows workflow

* Attempting to use prebuilt binaries for Windows pytest workflow

* Adding pytest for macos workflow

* Adding optional_dependency tests for linux workflow

* Adding pytest optional_dependency to other OS workflows

* Adding py3.11, py3.12 and running pre-commits for Linux workflow.

* Reverses different python version for Linux

* Adding different python version to linux workflow again

* Adding pypi submission workflow job

* Fixing std import

* Adding in duration for MOps in PyPMIR

* Polishing makefile to work with Windows

* Comment out rust+cpp build for now

---------

Co-authored-by: Ciaran Ryan-Anderson <[email protected]>
  • Loading branch information
ciaranra and ciaranra authored Feb 29, 2024
1 parent b3c456d commit bab60fa
Show file tree
Hide file tree
Showing 453 changed files with 7,104 additions and 4,186 deletions.
231 changes: 201 additions & 30 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,215 @@ name: Python application

on:
push:
branches: [ "master", "development" ]
branches:
- master
- development
tags:
- "*"
pull_request:
branches: [ "master", "development" ]
branches:
- master
- development

permissions:
contents: read

jobs:
build:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
target: [x86_64, x86, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup pre-commit
run: |
python -m pip install pre-commit
pre-commit install
- name: Run pre-commit on all files
run: pre-commit run --all-files
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path ./python/Cargo.toml
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
- name: pytest
if: ${{ startsWith(matrix.target, 'x86_64') }}
shell: bash
run: |
pip install --upgrade pip setuptools
pip install pytest-cov
set -e
PYTHON_VER=$(python -c "import sys; print(''.join(map(str, sys.version_info[:2])))")
WHEEL_FILE=$(ls dist/quantum_pecos-*-cp${PYTHON_VER}-*.whl)
pip install "${WHEEL_FILE}" --force-reinstall
pip install pytest
cd ./python && pytest --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
cd ..
pip install "${WHEEL_FILE}"[all] --force-reinstall
cd ./python && pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
- name: pytest aarch64
if: ${{ !startsWith(matrix.target, 'x86') && !startsWith(matrix.target, 'ppc64')}}
uses: uraimo/[email protected]
with:
arch: ${{ matrix.target }}
distro: ubuntu22.04
githubToken: ${{ github.token }}
install: |
apt-get update
apt-get install -y --no-install-recommends build-essential python3 python3-pip cmake
pip3 install -U pip pytest setuptools
run: |
pip3 install --upgrade pip setuptools
pip3 install pytest-cov
set -e
PYTHON_VER=$(python3 -c "import sys; print(''.join(map(str, sys.version_info[:2])))")
WHEEL_FILE=$(ls dist/quantum_pecos-*-cp${PYTHON_VER}-*.whl)
pip3 install "${WHEEL_FILE}" --force-reinstall --only-binary :all:
cd ./python && python3 -m pytest --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
cd ..
pip install "${WHEEL_FILE}"[all] --force-reinstall
cd ./python && python3 -m pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
windows:
runs-on: windows-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
target: [x64,
# x86
]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.target }}
- name: Setup pre-commit
run: |
python -m pip install pre-commit
pre-commit install
- name: Run pre-commit on all files
run: pre-commit run --all-files
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path ./python/Cargo.toml
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
- name: pytest
if: ${{ !startsWith(matrix.target, 'aarch64') }}
shell: bash
run: |
pip install --upgrade pip setuptools
pip install pytest-cov
set -e
PYTHON_VER=$(python -c "import sys; print(''.join(map(str, sys.version_info[:2])))")
WHEEL_FILE=$(ls dist/quantum_pecos-*-cp${PYTHON_VER}-*.whl)
pip install "${WHEEL_FILE}" --force-reinstall
pip install pytest
cd ./python && pytest --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
cd ..
pip install "${WHEEL_FILE}"[all] --force-reinstall
cd ./python && pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
runs-on: ${{ matrix.os }}
macos:
runs-on: macos-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ["3.10", "3.11", "3.12"]
python-version: ['3.10', '3.11', '3.12']
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup pre-commit
run: |
python -m pip install pre-commit
pre-commit install
- name: Run pre-commit on all files
run: pre-commit run --all-files
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path ./python/Cargo.toml
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
- name: pytest
if: ${{ !startsWith(matrix.target, 'aarch64') }}
shell: bash
run: |
pip install --upgrade pip setuptools
pip install pytest-cov
set -e
PYTHON_VER=$(python -c "import sys; print(''.join(map(str, sys.version_info[:2])))")
WHEEL_FILE=$(ls dist/quantum_pecos-*-cp${PYTHON_VER}-*.whl)
pip install "${WHEEL_FILE}" --force-reinstall
pip install pytest
cd ./python && pytest --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
cd ..
pip install "${WHEEL_FILE}"[all] --force-reinstall
cd ./python && pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Setup pre-commit
run: |
python -m pip install pre-commit
pre-commit install
- name: Run pre-commit on all files
run: pre-commit run --all-files
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path ./python/Cargo.toml
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
- name: Pre-commit checks
run: |
python -m pip install pre-commit
pre-commit run --all-files
- name: Test with pytest
run: |
pip install pytest-cov
pip install .
pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
- name: Test optional dependencies with pytest
run: |
pip install pytest-cov
pip install .[all]
pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing *
12 changes: 7 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ repos:
- id: debug-statements

- repo: https://github.com/crate-ci/typos
rev: v1.16.18
rev: v1.18.2
hooks:
- id: typos
args: []

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
additional_dependencies:
- ruff==0.2.2

- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.2.0
hooks:
- id: black
exclude: |
Expand All @@ -36,8 +38,8 @@ repos:
)$
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies:
- black==23.9.1
- black==24.2.0
Loading

0 comments on commit bab60fa

Please sign in to comment.