Skip to content

Commit

Permalink
Merge branch 'develop' into daisyrainsmith/commutation2
Browse files Browse the repository at this point in the history
  • Loading branch information
Takishima authored Apr 2, 2024
2 parents acf7bb0 + dad48c5 commit 4242d98
Show file tree
Hide file tree
Showing 23 changed files with 88 additions and 60 deletions.
55 changes: 37 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name: CI

on:
workflow_dispatch:
merge_group:
pull_request:
push:
branches:
Expand Down Expand Up @@ -112,12 +113,20 @@ jobs:
env:
CC: clang
CXX: clang++
PROJECTQ_CLEANUP_COMPILER_FLAGS: ${{ (matrix.clang < 10) && 1 || 0 }}
PROJECTQ_CLEANUP_COMPILER_FLAGS: ${{ (matrix.clang <= 10) && 1 || 0 }}

name: "Python 3 • Clang ${{ matrix.clang }} • x64"
container: "silkeh/clang:${{ matrix.clang }}"

steps:
- name: Install Git
run: |
apt-get update && apt-get install -y git --no-install-recommends
# Work-around for https://github.com/actions/runner-images/issues/6775
- name: Change Owner of Container Working Directory
run: chown root:root .

- uses: actions/checkout@v3

- name: Get history and tags for SCM versioning to work
Expand All @@ -130,27 +139,27 @@ jobs:
run: >
apt-get update && apt-get install -y python3-dev python3-pip python3-setuptools python3-wheel
python3-numpy python3-scipy python3-matplotlib python3-requests python3-networkx
python3-pytest python3-pytest-cov python3-flaky
libomp-dev
python3-pytest python3-pytest-cov python3-flaky python3-venv
--no-install-recommends
- name: Prepare Python env
run: |
python3 -m pip install -U pip setuptools wheel
python3 setup.py gen_reqfile --include-extras=test,azure-quantum,braket
python3 -m venv venv
./venv/bin/python3 -m pip install -U pip setuptools wheel
./venv/bin/python3 setup.py gen_reqfile --include-extras=test,azure-quantum,braket
cat requirements.txt
python3 -m pip install -r requirements.txt --prefer-binary
./venv/bin/python3 -m pip install -r requirements.txt --prefer-binary
- name: Upgrade pybind11 and flaky
run: python3 -m pip install --upgrade pybind11 flaky --prefer-binary
run: ./venv/bin/python3 -m pip install --upgrade pybind11 flaky --prefer-binary

- name: Build and install package
run: python3 -m pip install -ve .[azure-quantum,braket,test]
run: ./venv/bin/python3 -m pip install -ve .[azure-quantum,braket,test]

- name: Pytest
run: |
echo 'backend: Agg' > matplotlibrc
python3 -m pytest -p no:warnings
./venv/bin/python3 -m pytest -p no:warnings
gcc:
Expand All @@ -168,6 +177,10 @@ jobs:
steps:
- uses: actions/checkout@v3

# Work-around for https://github.com/actions/runner-images/issues/6775
- name: Change Owner of Container Working Directory
run: chown root:root .

- name: Get history and tags for SCM versioning to work
if: ${{ !env.ACT }}
run: |
Expand All @@ -178,26 +191,27 @@ jobs:
run: >
apt-get update && apt-get install -y python3-dev python3-pip python3-setuptools python3-wheel
python3-numpy python3-scipy python3-matplotlib python3-requests python3-networkx
python3-pytest python3-pytest-cov python3-flaky
python3-pytest python3-pytest-cov python3-flaky python3-venv
--no-install-recommends
- name: Prepare Python env
run: |
python3 -m pip install -U pip setuptools wheel
python3 setup.py gen_reqfile --include-extras=test,azure-quantum,braket
python3 -m venv venv
./venv/bin/python3 -m pip install -U pip setuptools wheel
./venv/bin/python3 setup.py gen_reqfile --include-extras=test,azure-quantum,braket
cat requirements.txt
python3 -m pip install -r requirements.txt --prefer-binary
./venv/bin/python3 -m pip install -r requirements.txt --prefer-binary
- name: Upgrade pybind11 and flaky
run: python3 -m pip install --upgrade pybind11 flaky --prefer-binary
run: ./venv/bin/python3 -m pip install --upgrade pybind11 flaky --prefer-binary

- name: Build and install package
run: python3 -m pip install -ve .[azure-quantum,braket,test]
run: ./venv/bin/python3 -m pip install -ve .[azure-quantum,braket,test]

- name: Pytest
run: |
echo 'backend: Agg' > matplotlibrc
python3 -m pytest -p no:warnings
./venv/bin/python3 -m pytest -p no:warnings
# Testing on CentOS (manylinux uses a centos base, and this is an easy way
Expand Down Expand Up @@ -257,6 +271,10 @@ jobs:
yum install -y git
git config --global --add safe.directory /__w/ProjectQ/ProjectQ
# Work-around for https://github.com/actions/runner-images/issues/6775
- name: Change Owner of Container Working Directory
run: chown root:root .

- uses: actions/checkout@v3

- name: Get history and tags for SCM versioning to work
Expand Down Expand Up @@ -320,5 +338,6 @@ jobs:
- name: Build docs
run: python3 -m sphinx -b html docs docs/.build

- name: Make SDist
run: python3 setup.py sdist
# NB: disabling until setup.py is updated to remove any mention of distutils
# - name: Make SDist
# run: python3 setup.py sdist
2 changes: 1 addition & 1 deletion .github/workflows/draft_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

# yamllint disable rule:line-length
- name: Create pull request
uses: thomaseizinger/create-pull-request@1.2.2
uses: thomaseizinger/create-pull-request@1.3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name: Format

on:
workflow_dispatch:
merge_group:
pull_request:
push:
branches:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
steps:
- name: Set up QEMU
if: matrix.cibw_archs == 'aarch64'
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

Expand Down Expand Up @@ -266,7 +266,7 @@ jobs:
- upload_to_pypi
steps:
- name: Merge master into develop branch
uses: thomaseizinger/create-pull-request@1.2.2
uses: thomaseizinger/create-pull-request@1.3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

name: PR
on:
merge_group:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]

Expand Down
28 changes: 14 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -40,65 +40,65 @@ repos:

# Changes tabs to spaces
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.3.1
rev: v1.5.4
hooks:
- id: remove-tabs

- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
rev: 6.3.0
hooks:
- id: pydocstyle
exclude: (_test.*\.py)$
additional_dependencies: [toml]

- repo: https://github.com/PyCQA/doc8/
rev: v1.0.0
rev: v1.1.1
hooks:
- id: doc8
require_serial: false
additional_dependencies: [tomli]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.6
hooks:
- id: codespell
require_serial: false
files: .*\.(py|txt|cmake|md|rst|sh|ps1|hpp|tpp|cpp|cc)$
args: [-S, '.git,third_party', -I, .codespell.allow]

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
rev: v1.33.0
hooks:
- id: yamllint
require_serial: false

- repo: https://github.com/asottile/pyupgrade
rev: v3.1.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py37-plus, --keep-mock]

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.13.2
hooks:
- id: isort
name: isort (python)

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.12.1
hooks:
- id: black
language_version: python3

- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
rev: 1.16.0
hooks:
- id: blacken-docs
args: [-S, -l, '120']
additional_dependencies: [black==22.10.0]

- repo: https://gitlab.com/PyCQA/flake8
rev: 3.9.2
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
name: flake8-strict
Expand All @@ -116,11 +116,11 @@ repos:
rev: 'v3.0.0a5'
hooks:
- id: pylint
args: ['--score=n']
args: ['--score=n', '--disable=no-member']
additional_dependencies: [pybind11>=2.6, numpy, requests, matplotlib, networkx]

- repo: https://github.com/mgedmin/check-manifest
rev: '0.48'
rev: '0.49'
hooks:
- id: check-manifest
additional_dependencies: ['setuptools-scm', 'pybind11>=2.6']
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Python context manager `with flushing(MainEngine()) as eng:`

### Fixed

- Fixed some typos (thanks to @eltociear, @Darkdragon84)

### Repository

- Update GitHub workflow action versions: `actions/cache@v3`, `actions/checkout@v3`, `actions/setup-python@v4`
- Update GitHub workflows to work with merge queues
- Update GitHub workflow action versions: `actions/cache@v3`, `actions/checkout@v3`, `actions/setup-python@v4`, `thomaseizinger/create-pull-request`
- Fix failing GitHub workflows (Clang-10)
- Introduce pre-commit CI
- Update to clang-tidy 14 in GitHub workflow
- Update pre-commit hook versions
- Added new pre-commit hooks: `codespell`, `doc8`, `pydocstyle` and `yamllint`
- Keep `flake8` hook to version 5.0.4 until plugins support Flake8 6.X
- Disable `no-member` warning for Pylint on pre-commit CI
- Update pre-commit hook versions


## [v0.8.0] - 2022-10-18

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ linear chain and the architecture supports any single-qubit gate as well as the
from projectq import MainEngine
from projectq.backends import ResourceCounter
from projectq.ops import QFT
from projectq.ops import QFT, CNOT, Swap
from projectq.setups import linear
compiler_engines = linear.get_engine_list(num_qubits=16, one_qubit_gates='any', two_qubit_gates=(CNOT, Swap))
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Detailed instructions and OS-specific hints
sudo port install py37-pip
Next, we can install ProjectQ with the high performance simulator written in C++. First, we will need to install a
suitable compiler with support for **C++11**, OpenMP, and instrinsics. The best option is to install clang 9.0 also
suitable compiler with support for **C++11**, OpenMP, and intrinsics. The best option is to install clang 9.0 also
using macports (note: gcc installed via macports does not work).

.. code-block:: bash
Expand Down
4 changes: 2 additions & 2 deletions examples/compiler_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Please have a look at the documention of the [restrictedgateset](http://projectq.readthedocs.io/en/latest/projectq.setups.html#module-projectq.setups.restrictedgateset) for details. The above compiler compiles the circuit to gates consisting of any single qubit gate, the `CNOT` and `Toffoli` gate. The gate specifications can either be a gate class, e.g., `Rz` or a specific instance `Rz(math.pi)`. A smaller but still universal gate set would be for example `CNOT` and `Rz, Ry`:"
"Please have a look at the documentation of the [restrictedgateset](http://projectq.readthedocs.io/en/latest/projectq.setups.html#module-projectq.setups.restrictedgateset) for details. The above compiler compiles the circuit to gates consisting of any single qubit gate, the `CNOT` and `Toffoli` gate. The gate specifications can either be a gate class, e.g., `Rz` or a specific instance `Rz(math.pi)`. A smaller but still universal gate set would be for example `CNOT` and `Rz, Ry`:"
]
},
{
Expand Down Expand Up @@ -292,7 +292,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As mentioned in the documention of [this setup](http://projectq.readthedocs.io/en/latest/projectq.setups.html#module-projectq.setups.restrictedgateset), one cannot (yet) choose an arbitrary gate set but there is a limited choice. If it doesn't work for a specified gate set, the compiler will either raises a `NoGateDecompositionError` or a `RuntimeError: maximum recursion depth exceeded...` which means that for this particular choice of gate set, one would be required to write more [decomposition rules](https://github.com/ProjectQ-Framework/ProjectQ/tree/develop/projectq/setups/decompositions) to make it work. Also for some choice of gate set there might be compiler engines producing more optimal code."
"As mentioned in the documentation of [this setup](http://projectq.readthedocs.io/en/latest/projectq.setups.html#module-projectq.setups.restrictedgateset), one cannot (yet) choose an arbitrary gate set but there is a limited choice. If it doesn't work for a specified gate set, the compiler will either raises a `NoGateDecompositionError` or a `RuntimeError: maximum recursion depth exceeded...` which means that for this particular choice of gate set, one would be required to write more [decomposition rules](https://github.com/ProjectQ-Framework/ProjectQ/tree/develop/projectq/setups/decompositions) to make it work. Also for some choice of gate set there might be compiler engines producing more optimal code."
]
},
{
Expand Down
1 change: 0 additions & 1 deletion projectq/backends/_aqt/_aqt_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def _handle_sigint_during_get_result(*_): # pragma: no cover
signal.signal(signal.SIGINT, _handle_sigint_during_get_result)

for retries in range(num_retries):

argument = {'id': execution_id, 'access_token': self.token}
req = super().put(urljoin(_API_URL, self.backends[device]['url']), data=argument)
req.raise_for_status()
Expand Down
2 changes: 0 additions & 2 deletions projectq/backends/_awsbraket/_awsbraket_boto3_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def test_send_too_many_qubits(mocker, send_too_many_setup):
],
)
def test_send_real_device_online_verbose(mocker, var_status, var_result, real_device_online_setup):

(
qtarntask,
creds,
Expand Down Expand Up @@ -285,7 +284,6 @@ def test_send_that_errors_are_caught(mocker, var_error, send_that_error_setup):
@has_boto3
@pytest.mark.parametrize("var_error", [('ResourceNotFoundException')])
def test_retrieve_error_arn_not_exist(mocker, var_error, arntask, creds):

mock_boto3_client = mocker.MagicMock(spec=['get_quantum_task'])
mock_boto3_client.get_quantum_task.side_effect = botocore.exceptions.ClientError(
{"Error": {"Code": var_error, "Message": f"Msg error for {var_error}"}},
Expand Down
3 changes: 2 additions & 1 deletion projectq/backends/_azure/_azure_quantum_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from projectq.ops import CX, All, Command, H, Measure
from projectq.types import WeakQubitRef

_has_azure_quantum = True
# NB: temporary workaround until Azure Quantum backend is fixed
_has_azure_quantum = False
try:
from azure.quantum import Workspace

Expand Down
1 change: 0 additions & 1 deletion projectq/backends/_ibm/_ibm_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ def _handle_sigint_during_get_result(*_): # pragma: no cover
try:
signal.signal(signal.SIGINT, _handle_sigint_during_get_result)
for retries in range(num_retries):

# STEP5: WAIT FOR THE JOB TO BE RUN
json_step5 = {'allow_redirects': True, 'timeout': (self.timeout, None)}
request = super().get(urljoin(_API_URL, job_status_url), **json_step5)
Expand Down
1 change: 0 additions & 1 deletion projectq/backends/_ionq/_ionq.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ def _store(self, cmd):
targets = [qb.id for qureg in cmd.qubits for qb in qureg]
controls = [qb.id for qb in cmd.control_qubits]
if len(self._measured_ids) > 0:

# Check any qubits we are trying to operate on.
gate_qubits = set(targets) | set(controls)

Expand Down
Loading

0 comments on commit 4242d98

Please sign in to comment.