Skip to content

Commit

Permalink
Merge remote-tracking branch 'ibm/main' into dag_dep_apply
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelishman committed Jun 28, 2024
2 parents 31b2535 + ea5a54b commit 8f0823c
Show file tree
Hide file tree
Showing 742 changed files with 24,551 additions and 8,133 deletions.
2 changes: 1 addition & 1 deletion .azure/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ parameters:
jobs:
- job: "MacOS_Tests_Python${{ replace(parameters.pythonVersion, '.', '') }}"
displayName: "Test macOS Python ${{ parameters.pythonVersion }}"
pool: {vmImage: 'macOS-11'}
pool: {vmImage: 'macOS-13'}

variables:
QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y
Expand Down
2 changes: 1 addition & 1 deletion .binder/postBuild
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# - pylatexenc: for MPL drawer
# - pillow: for image comparison
# - appmode: jupyter extension for executing the notebook
# - seaborn: visualisation pacakge required for some graphs
# - seaborn: visualization pacakge required for some graphs
pip install matplotlib pylatexenc pillow appmode seaborn
pip install .

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Backport metadata

# Mergify manages the opening of the backport PR, this workflow is just to extend its behaviour to
# Mergify manages the opening of the backport PR, this workflow is just to extend its behavior to
# do useful things like copying across the tagged labels and milestone from the base PR.

on:
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/miri.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Miri
on:
push:
pull_request:
concurrency:
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}
# Only cancel in PR mode. In push mode, don't cancel so we don't see spurious test "failures",
# and we get coverage reports on Coveralls for every push.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
miri:
if: github.repository_owner == 'Qiskit'
name: Miri
runs-on: ubuntu-latest
env:
RUSTUP_TOOLCHAIN: nightly-2024-05-24

steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-05-24
components: miri

- name: Prepare Miri
run: |
set -e
# Some of our dependencies aren't Miri-safe with their current release versions. These
# need overriding with known-good versions to run against until the Miri-safe versions are
# released and updated in our Cargo.lock.
cat >>Cargo.toml <<EOF
[patch.crates-io]
crossbeam-epoch = { git = "https://github.com/crossbeam-rs/crossbeam", rev = "9e859610" }
EOF
cargo miri setup
- name: Run Miri
run: cargo miri test
env:
# - `tree-borrows` is required for crossbeam components.
# - `symbolic-alignment-check` is extra checking.
# - `strict-provenance` is extra checking.
MIRIFLAGS: '-Zmiri-tree-borrows -Zmiri-symbolic-alignment-check -Zmiri-strict-provenance'
54 changes: 54 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: Tests
on:
push:
branches: [ main, 'stable/*' ]
pull_request:
branches: [ main, 'stable/*' ]
merge_group:

concurrency:
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
tests:
if: github.repository_owner == 'Qiskit'
name: macOS-arm64-tests-Python-${{ matrix.python-version }}
runs-on: macOS-14
strategy:
fail-fast: false
matrix:
# Normally we test min and max version but we can't run python 3.8 or
# 3.9 on arm64 until actions/setup-python#808 is resolved
python-version: ["3.10", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/[email protected]
if: matrix.python-version == '3.10'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: arm64
- name: 'Install dependencies'
run: |
python -m pip install -U -r requirements.txt -c constraints.txt
python -m pip install -U -r requirements-dev.txt -c constraints.txt
python -m pip install -c constraints.txt -e .
if: matrix.python-version == '3.10'
env:
QISKIT_NO_CACHE_GATES: 1
- name: 'Install dependencies'
run: |
python -m pip install -U -r requirements.txt -c constraints.txt
python -m pip install -U -r requirements-dev.txt -c constraints.txt
python -m pip install -c constraints.txt -e .
if: matrix.python-version == '3.12'
- name: 'Install optionals'
run: |
python -m pip install -r requirements-optional.txt -c constraints.txt
python tools/report_numpy_state.py
if: matrix.python-version == '3.10'
- name: 'Run tests'
run: stestr run
55 changes: 32 additions & 23 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,25 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11, windows-latest]
os: [ubuntu-latest, macos-11, windows-latest, macos-14]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
if: matrix.os != 'macos-14'
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
architecture: arm64
if: matrix.os == 'macos-14'
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0
uses: pypa/cibuildwheel@v2.19.1
env:
CIBW_BEFORE_BUILD: 'bash ./tools/build_pgo.sh /tmp/pgo-data/merged.profdata'
CIBW_BEFORE_BUILD_WINDOWS: 'bash ./tools/build_pgo.sh /tmp/pgo-data/merged.profdata && cp /tmp/pgo-data/merged.profdata ~/.'
Expand All @@ -34,13 +41,13 @@ jobs:
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}
build_wheels_32bit:
name: Build wheels 32bit
build_wheels_macos_arm_py38:
name: Build wheels on macOS arm
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
os: [macos-11]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -51,47 +58,49 @@ jobs:
with:
components: llvm-tools-preview
- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0
uses: pypa/cibuildwheel@v2.19.1
env:
CIBW_SKIP: 'pp* cp36-* cp37-* *musllinux* *amd64 *x86_64'
CIBW_BEFORE_ALL: rustup target add aarch64-apple-darwin
CIBW_BUILD: cp38-macosx_universal2 cp38-macosx_arm64
CIBW_ARCHS_MACOS: arm64 universal2
CIBW_ENVIRONMENT: >-
CARGO_BUILD_TARGET="aarch64-apple-darwin"
PYO3_CROSS_LIB_DIR="/Library/Frameworks/Python.framework/Versions/$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')/lib/python$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')"
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}-32
build_wheels_macos_arm:
name: Build wheels on macOS arm
name: wheels-${{ matrix.os }}-arm
build_wheels_32bit:
name: Build wheels 32bit
runs-on: ${{ matrix.os }}
environment: release
strategy:
fail-fast: false
matrix:
os: [macos-11]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0
uses: pypa/cibuildwheel@v2.19.1
env:
CIBW_BEFORE_ALL: rustup target add aarch64-apple-darwin
CIBW_ARCHS_MACOS: arm64 universal2
CIBW_ENVIRONMENT: >-
CARGO_BUILD_TARGET="aarch64-apple-darwin"
PYO3_CROSS_LIB_DIR="/Library/Frameworks/Python.framework/Versions/$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')/lib/python$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')"
CIBW_SKIP: 'pp* cp36-* cp37-* *musllinux* *amd64 *x86_64'
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}-arm
name: wheels-${{ matrix.os }}-32
upload_shared_wheels:
name: Upload shared build wheels
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
needs: ["build_wheels", "build_wheels_macos_arm", "build_wheels_32bit"]
needs: ["build_wheels", "build_wheels_32bit", "build_wheels_macos_arm_py38"]
steps:
- uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -124,7 +133,7 @@ jobs:
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0
uses: pypa/cibuildwheel@v2.19.1
env:
CIBW_ARCHS_LINUX: s390x
CIBW_TEST_SKIP: "cp*"
Expand Down Expand Up @@ -158,7 +167,7 @@ jobs:
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0
uses: pypa/cibuildwheel@v2.19.1
env:
CIBW_ARCHS_LINUX: ppc64le
CIBW_TEST_SKIP: "cp*"
Expand Down Expand Up @@ -192,7 +201,7 @@ jobs:
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0
uses: pypa/cibuildwheel@v2.19.1
env:
CIBW_ARCHS_LINUX: aarch64
- uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pull_request_rules:
actions:
backport:
branches:
- stable/1.0
- stable/1.1
13 changes: 8 additions & 5 deletions CITATION.bib
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@misc{Qiskit,
author = {{Qiskit contributors}},
title = {Qiskit: An Open-source Framework for Quantum Computing},
year = {2023},
doi = {10.5281/zenodo.2573505}
@misc{qiskit2024,
title={Quantum computing with {Q}iskit},
author={Javadi-Abhari, Ali and Treinish, Matthew and Krsulich, Kevin and Wood, Christopher J. and Lishman, Jake and Gacon, Julien and Martiel, Simon and Nation, Paul D. and Bishop, Lev S. and Cross, Andrew W. and Johnson, Blake R. and Gambetta, Jay M.},
year={2024},
doi={10.48550/arXiv.2405.08810},
eprint={2405.08810},
archivePrefix={arXiv},
primaryClass={quant-ph}
}
72 changes: 68 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ Note that in order to run `python setup.py ...` commands you need have build
dependency packages installed in your environment, which are listed in the
`pyproject.toml` file under the `[build-system]` section.

### Compile time options

When building qiskit from source there are options available to control how
Qiskit is built. Right now the only option is if you set the environment
variable `QISKIT_NO_CACHE_GATES=1` this will disable runtime caching of
Python gate objects when accessing them from a `QuantumCircuit` or `DAGCircuit`.
This makes a tradeoff between runtime performance for Python access and memory
overhead. Caching gates will result in better runtime for users of Python at
the cost of increased memory consumption. If you're working with any custom
transpiler passes written in python or are otherwise using a workflow that
repeatedly accesses the `operation` attribute of a `CircuitInstruction` or `op`
attribute of `DAGOpNode` enabling caching is recommended.

## Issues and pull requests

Expand Down Expand Up @@ -183,8 +195,8 @@ please ensure that:
If your pull request is adding a new class, function, or module that is
intended to be user facing ensure that you've also added those to a
documentation `autosummary` index to include it in the api documentation.
3. If it makes sense for your change that you have added new tests that
cover the changes.
3. If you are of the opinion that the modifications you made warrant additional tests,
feel free to include them
4. Ensure that if your change has an end user facing impact (new feature,
deprecation, removal etc) that you have added a reno release note for that
change and that the PR is tagged for the changelog.
Expand Down Expand Up @@ -520,7 +532,7 @@ we used in our CI systems more closely.

### Snapshot Testing for Visualizations

If you are working on code that makes changes to any matplotlib visualisations
If you are working on code that makes changes to any matplotlib visualizations
you will need to check that your changes don't break any snapshot tests, and add
new tests where necessary. You can do this as follows:

Expand All @@ -531,7 +543,7 @@ the snapshot tests (note this may take some time to finish loading).
3. Each test result provides a set of 3 images (left: reference image, middle: your test result, right: differences). In the list of tests the passed tests are collapsed and failed tests are expanded. If a test fails, you will see a situation like this:

<img width="995" alt="Screenshot_2021-03-26_at_14 13 54" src="https://user-images.githubusercontent.com/23662430/112663508-d363e800-8e50-11eb-9478-6d665d0ff086.png">
4. Fix any broken tests. Working on code for one aspect of the visualisations
4. Fix any broken tests. Working on code for one aspect of the visualizations
can sometimes result in minor changes elsewhere to spacing etc. In these cases
you just need to update the reference images as follows:
- download the mismatched images (link at top of Jupyter Notebook output)
Expand All @@ -556,6 +568,58 @@ you just need to update the reference images as follows:

Note: If you have run `test/ipynb/mpl_tester.ipynb` locally it is possible some file metadata has changed, **please do not commit and push changes to this file unless they were intentional**.


### Testing Rust components

Rust-accelerated functions are generally tested from Python space, but in cases
where there is Rust-specific internal details to be tested, `#[test]` functions
can be included inline. Typically it's most convenient to place these in a
separate inline module that is only conditionally compiled in, such as

```rust
#[cfg(test)]
mod tests {
#[test]
fn my_first_test() {
assert_eq!(2, 1 + 1);
}
}
```

To run the Rust-space tests, do

```bash
cargo test --no-default-features
```

Our Rust-space components are configured such that setting the
``-no-default-features`` flag will compile the test runner, but not attempt to
build a linked CPython extension module, which would cause linker failures.

### Unsafe code and Miri

Any `unsafe` code added to the Rust logic should be exercised by Rust-space
tests, in addition to the more complete Python test suite. In CI, we run the
Rust test suite under [Miri](https://github.com/rust-lang/miri) as an
undefined-behavior sanitizer.

Miri is currently only available on `nightly` Rust channels, so to run it
locally you will need to ensure you have that channel available, such as by
```bash
rustup install nightly --components miri
```

After this, you can run the Miri test suite with
```bash
MIRIFLAGS="<flags go here>" cargo +nightly miri test
```

For the current set of `MIRIFLAGS` used by Qiskit's CI, see the
[`miri.yml`](https://github.com/Qiskit/qiskit/blob/main/.github/workflows/miri.yml)
GitHub Action file. This same file may also include patches to dependencies to
make them compatible with Miri, which you would need to temporarily apply as
well.

## Style and lint

Qiskit uses three tools for verify code formatting and lint checking. The
Expand Down
Loading

0 comments on commit 8f0823c

Please sign in to comment.