diff --git a/.azure/test-macos.yml b/.azure/test-macos.yml
index 1887a88655d..b167df3f1c8 100644
--- a/.azure/test-macos.yml
+++ b/.azure/test-macos.yml
@@ -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
diff --git a/.binder/postBuild b/.binder/postBuild
index 9517953258f..cb06527f280 100644
--- a/.binder/postBuild
+++ b/.binder/postBuild
@@ -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 .
diff --git a/.cargo/config b/.cargo/config.toml
similarity index 100%
rename from .cargo/config
rename to .cargo/config.toml
diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml
index bcc86d63fcf..88fd919e8ad 100644
--- a/.github/workflows/backport.yml
+++ b/.github/workflows/backport.yml
@@ -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:
diff --git a/.github/workflows/miri.yml b/.github/workflows/miri.yml
index bdceb20c300..b32a96c3b42 100644
--- a/.github/workflows/miri.yml
+++ b/.github/workflows/miri.yml
@@ -14,14 +14,15 @@ jobs:
name: Miri
runs-on: ubuntu-latest
env:
- RUSTUP_TOOLCHAIN: nightly
+ RUSTUP_TOOLCHAIN: nightly-2024-05-24
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
- uses: dtolnay/rust-toolchain@nightly
+ uses: dtolnay/rust-toolchain@master
with:
+ toolchain: nightly-2024-05-24
components: miri
- name: Prepare Miri
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 00000000000..20e40dec982
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -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/rust-toolchain@1.70
+ 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
diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml
index 67104433a3d..7c29f1376e4 100644
--- a/.github/workflows/wheels.yml
+++ b/.github/workflows/wheels.yml
@@ -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 ~/.'
@@ -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
@@ -51,21 +58,25 @@ 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
@@ -73,25 +84,23 @@ jobs:
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:
@@ -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*"
@@ -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*"
@@ -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
diff --git a/.mergify.yml b/.mergify.yml
index 87a3438930f..10b6d202225 100644
--- a/.mergify.yml
+++ b/.mergify.yml
@@ -6,4 +6,4 @@ pull_request_rules:
actions:
backport:
branches:
- - stable/1.0
+ - stable/1.1
diff --git a/CITATION.bib b/CITATION.bib
index a00798d9baa..deac2ef200e 100644
--- a/CITATION.bib
+++ b/CITATION.bib
@@ -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}
}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1ea3dc9f60f..7076c1571b1 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -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
@@ -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.
@@ -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:
@@ -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:
-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)
diff --git a/Cargo.lock b/Cargo.lock
index 6859c622967..6ce26b3baea 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,6 +2,17 @@
# It is not intended for manual editing.
version = 3
+[[package]]
+name = "ahash"
+version = "0.7.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9"
+dependencies = [
+ "getrandom",
+ "once_cell",
+ "version_check",
+]
+
[[package]]
name = "ahash"
version = "0.8.11"
@@ -106,7 +117,7 @@ checksum = "4da9a32f3fed317401fa3c862968128267c3106685286e15d5aaa3d7389c2f60"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.59",
+ "syn 2.0.60",
]
[[package]]
@@ -265,27 +276,27 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
- "syn 2.0.59",
+ "syn 2.0.60",
]
[[package]]
name = "equator"
-version = "0.1.10"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3b0a88aa91d0ad2b9684e4479aed31a17d3f9051bdbbc634bd2c01bc5a5eee8"
+checksum = "c35da53b5a021d2484a7cc49b2ac7f2d840f8236a286f84202369bd338d761ea"
dependencies = [
"equator-macro",
]
[[package]]
name = "equator-macro"
-version = "0.1.9"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "60d08acb9849f7fb4401564f251be5a526829183a3645a90197dea8e786cf3ae"
+checksum = "3bf679796c0322556351f287a51b49e48f7c4986e727b5dd78c972d30e2e16cc"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.59",
+ "syn 2.0.60",
]
[[package]]
@@ -296,9 +307,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "faer"
-version = "0.18.2"
+version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e547492d9b55c4ea882584e691ed092228981e337d0c800bc721301d7e61e40a"
+checksum = "41543c4de4bfb32efdffdd75cbcca5ef41b800e8a811ea4a41fb9393c6ef3bc0"
dependencies = [
"bytemuck",
"coe-rs",
@@ -310,6 +321,7 @@ dependencies = [
"libm",
"matrixcompare",
"matrixcompare-core",
+ "nano-gemm",
"npyz",
"num-complex",
"num-traits",
@@ -323,9 +335,9 @@ dependencies = [
[[package]]
name = "faer-entity"
-version = "0.18.0"
+version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22ea5c06233193392c614a46aa3bbe3de29c1404692c8053abd9c2765a1cd159"
+checksum = "ab968a02be27be95de0f1ad0af901b865fa0866b6a9b553a6cc9cf7f19c2ce71"
dependencies = [
"bytemuck",
"coe-rs",
@@ -338,9 +350,9 @@ dependencies = [
[[package]]
name = "faer-ext"
-version = "0.1.0"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f67e0c5be50b08c57b59f1cf78a1c8399f6816f4e1a2e0801470ff58dad23a3"
+checksum = "4cf30f6ae73f372c0e0cf7556c44e50f1eee0a714d71396091613d68c43625c9"
dependencies = [
"faer",
"ndarray",
@@ -355,9 +367,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "gemm"
-version = "0.17.1"
+version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ab24cc62135b40090e31a76a9b2766a501979f3070fa27f689c27ec04377d32"
+checksum = "e400f2ffd14e7548356236c35dc39cad6666d833a852cb8a8f3f28029359bb03"
dependencies = [
"dyn-stack",
"gemm-c32",
@@ -375,9 +387,9 @@ dependencies = [
[[package]]
name = "gemm-c32"
-version = "0.17.1"
+version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b9c030d0b983d1e34a546b86e08f600c11696fde16199f971cd46c12e67512c0"
+checksum = "10dc4a6176c8452d60eac1a155b454c91c668f794151a303bf3c75ea2874812d"
dependencies = [
"dyn-stack",
"gemm-common",
@@ -390,9 +402,9 @@ dependencies = [
[[package]]
name = "gemm-c64"
-version = "0.17.1"
+version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fbb5f2e79fefb9693d18e1066a557b4546cd334b226beadc68b11a8f9431852a"
+checksum = "cc2032ce2c0bb150da0256338759a6fb01ca056f6dfe28c4d14af32d7f878f6f"
dependencies = [
"dyn-stack",
"gemm-common",
@@ -405,9 +417,9 @@ dependencies = [
[[package]]
name = "gemm-common"
-version = "0.17.1"
+version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a2e7ea062c987abcd8db95db917b4ffb4ecdfd0668471d8dc54734fdff2354e8"
+checksum = "90fd234fc525939654f47b39325fd5f55e552ceceea9135f3aa8bdba61eabef6"
dependencies = [
"bytemuck",
"dyn-stack",
@@ -425,9 +437,9 @@ dependencies = [
[[package]]
name = "gemm-f16"
-version = "0.17.1"
+version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7ca4c06b9b11952071d317604acb332e924e817bd891bec8dfb494168c7cedd4"
+checksum = "3fc3652651f96a711d46b8833e1fac27a864be4bdfa81a374055f33ddd25c0c6"
dependencies = [
"dyn-stack",
"gemm-common",
@@ -443,9 +455,9 @@ dependencies = [
[[package]]
name = "gemm-f32"
-version = "0.17.1"
+version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e9a69f51aaefbd9cf12d18faf273d3e982d9d711f60775645ed5c8047b4ae113"
+checksum = "acbc51c44ae3defd207e6d9416afccb3c4af1e7cef5e4960e4c720ac4d6f998e"
dependencies = [
"dyn-stack",
"gemm-common",
@@ -458,9 +470,9 @@ dependencies = [
[[package]]
name = "gemm-f64"
-version = "0.17.1"
+version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa397a48544fadf0b81ec8741e5c0fba0043008113f71f2034def1935645d2b0"
+checksum = "3f37fc86e325c2415a4d0cab8324a0c5371ec06fc7d2f9cb1636fcfc9536a8d8"
dependencies = [
"dyn-stack",
"gemm-common",
@@ -509,14 +521,17 @@ name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+dependencies = [
+ "ahash 0.7.8",
+]
[[package]]
name = "hashbrown"
-version = "0.14.3"
+version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
+checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
- "ahash",
+ "ahash 0.8.11",
"allocator-api2",
"rayon",
]
@@ -533,16 +548,6 @@ version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
-[[package]]
-name = "indexmap"
-version = "1.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
-dependencies = [
- "autocfg",
- "hashbrown 0.12.3",
-]
-
[[package]]
name = "indexmap"
version = "2.2.6"
@@ -550,7 +555,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
- "hashbrown 0.14.3",
+ "hashbrown 0.14.5",
"rayon",
]
@@ -589,6 +594,15 @@ dependencies = [
"either",
]
+[[package]]
+name = "itertools"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
+dependencies = [
+ "either",
+]
+
[[package]]
name = "jod-thread"
version = "0.1.2"
@@ -597,9 +611,9 @@ checksum = "8b23360e99b8717f20aaa4598f5a6541efbe30630039fbc7706cf954a87947ae"
[[package]]
name = "libc"
-version = "0.2.153"
+version = "0.2.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
+checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
[[package]]
name = "libm"
@@ -609,9 +623,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "lock_api"
-version = "0.4.11"
+version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
+checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
dependencies = [
"autocfg",
"scopeguard",
@@ -673,6 +687,76 @@ dependencies = [
"windows-sys 0.42.0",
]
+[[package]]
+name = "nano-gemm"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f563548d38f390ef9893e4883ec38c1fb312f569e98d76bededdd91a3b41a043"
+dependencies = [
+ "equator",
+ "nano-gemm-c32",
+ "nano-gemm-c64",
+ "nano-gemm-codegen",
+ "nano-gemm-core",
+ "nano-gemm-f32",
+ "nano-gemm-f64",
+ "num-complex",
+]
+
+[[package]]
+name = "nano-gemm-c32"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a40449e57a5713464c3a1208c4c3301c8d29ee1344711822cf022bc91373a91b"
+dependencies = [
+ "nano-gemm-codegen",
+ "nano-gemm-core",
+ "num-complex",
+]
+
+[[package]]
+name = "nano-gemm-c64"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "743a6e6211358fba85d1009616751e4107da86f4c95b24e684ce85f25c25b3bf"
+dependencies = [
+ "nano-gemm-codegen",
+ "nano-gemm-core",
+ "num-complex",
+]
+
+[[package]]
+name = "nano-gemm-codegen"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "963bf7c7110d55430169dc74c67096375491ed580cd2ef84842550ac72e781fa"
+
+[[package]]
+name = "nano-gemm-core"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe3fc4f83ae8861bad79dc3c016bd6b0220da5f9de302e07d3112d16efc24aa6"
+
+[[package]]
+name = "nano-gemm-f32"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4e3681b7ce35658f79da94b7f62c60a005e29c373c7111ed070e3bf64546a8bb"
+dependencies = [
+ "nano-gemm-codegen",
+ "nano-gemm-core",
+]
+
+[[package]]
+name = "nano-gemm-f64"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc1e619ed04d801809e1f63e61b669d380c4119e8b0cdd6ed184c6b111f046d8"
+dependencies = [
+ "nano-gemm-codegen",
+ "nano-gemm-core",
+]
+
[[package]]
name = "ndarray"
version = "0.15.6"
@@ -701,23 +785,23 @@ dependencies = [
[[package]]
name = "num-bigint"
-version = "0.4.4"
+version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0"
+checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
dependencies = [
- "autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-complex"
-version = "0.4.5"
+version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6"
+checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
dependencies = [
"bytemuck",
"num-traits",
+ "rand",
]
[[package]]
@@ -731,9 +815,9 @@ dependencies = [
[[package]]
name = "num-traits"
-version = "0.2.18"
+version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
"libm",
@@ -762,9 +846,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "oq3_lexer"
-version = "0.0.7"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4e867d2797100b8068715e26566a5567c598424d7eddf7118c6b38bc3b15633"
+checksum = "0de2f0f9d48042c12f82b2550808378718627e108fc3f6adf63e02e5293541a3"
dependencies = [
"unicode-properties",
"unicode-xid",
@@ -772,9 +856,9 @@ dependencies = [
[[package]]
name = "oq3_parser"
-version = "0.0.7"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf260dea71b56b405d091d476748c1f9b0a4d22b4ec9af416e002e2df25613f9"
+checksum = "e69b215426a4a2a023fd62cca4436c633ba0ab39ee260aca875ac60321b3704b"
dependencies = [
"drop_bomb",
"oq3_lexer",
@@ -783,12 +867,12 @@ dependencies = [
[[package]]
name = "oq3_semantics"
-version = "0.0.7"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d5ba220b91ff849190d53b296711774f761b7e06744b16a9c8f19fc2fb37de47"
+checksum = "3e15e9cee54e92fb1b3aaa42556b0bd76c8c1c10912a7d6798f43dfc3afdcb0d"
dependencies = [
"boolenum",
- "hashbrown 0.14.3",
+ "hashbrown 0.12.3",
"oq3_source_file",
"oq3_syntax",
"rowan",
@@ -796,9 +880,9 @@ dependencies = [
[[package]]
name = "oq3_source_file"
-version = "0.0.7"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83a81fd0c1c100ad8d7a23711c897791d693c3f5b1f3d044cb8c5770766f819c"
+checksum = "4f65243cc4807c600c544a21db6c17544c53aa2bc034b3eccf388251cc6530e7"
dependencies = [
"ariadne",
"oq3_syntax",
@@ -806,13 +890,13 @@ dependencies = [
[[package]]
name = "oq3_syntax"
-version = "0.0.7"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c7da2ef9a591d77eee43e972e79fc95c218545e5e79b93738d20479d8d7627ec"
+checksum = "a8c3d637a7db9ddb3811719db8a466bd4960ea668df4b2d14043a1b0038465b0"
dependencies = [
"cov-mark",
"either",
- "indexmap 2.2.6",
+ "indexmap",
"itertools 0.10.5",
"once_cell",
"oq3_lexer",
@@ -820,6 +904,7 @@ dependencies = [
"ra_ap_stdx",
"rowan",
"rustc-hash",
+ "rustversion",
"smol_str",
"triomphe",
"xshell",
@@ -827,9 +912,9 @@ dependencies = [
[[package]]
name = "parking_lot"
-version = "0.12.1"
+version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
+checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb"
dependencies = [
"lock_api",
"parking_lot_core",
@@ -837,15 +922,15 @@ dependencies = [
[[package]]
name = "parking_lot_core"
-version = "0.9.9"
+version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
+checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
- "windows-targets 0.48.5",
+ "windows-targets 0.52.5",
]
[[package]]
@@ -856,9 +941,9 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]]
name = "pest"
-version = "2.7.9"
+version = "2.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95"
+checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8"
dependencies = [
"memchr",
"thiserror",
@@ -867,9 +952,9 @@ dependencies = [
[[package]]
name = "pest_derive"
-version = "2.7.9"
+version = "2.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c"
+checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459"
dependencies = [
"pest",
"pest_generator",
@@ -877,22 +962,22 @@ dependencies = [
[[package]]
name = "pest_generator"
-version = "2.7.9"
+version = "2.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd"
+checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687"
dependencies = [
"pest",
"pest_meta",
"proc-macro2",
"quote",
- "syn 2.0.59",
+ "syn 2.0.60",
]
[[package]]
name = "pest_meta"
-version = "2.7.9"
+version = "2.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca"
+checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd"
dependencies = [
"once_cell",
"pest",
@@ -901,12 +986,12 @@ dependencies = [
[[package]]
name = "petgraph"
-version = "0.6.4"
+version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
+checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db"
dependencies = [
"fixedbitset",
- "indexmap 2.2.6",
+ "indexmap",
]
[[package]]
@@ -923,12 +1008,13 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "priority-queue"
-version = "1.4.0"
+version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a0bda9164fe05bc9225752d54aae413343c36f684380005398a6a8fde95fe785"
+checksum = "70c501afe3a2e25c9bd219aa56ec1e04cdb3fcdd763055be268778c13fa82c1f"
dependencies = [
"autocfg",
- "indexmap 1.9.3",
+ "equivalent",
+ "indexmap",
]
[[package]]
@@ -966,9 +1052,9 @@ dependencies = [
[[package]]
name = "pulp"
-version = "0.18.10"
+version = "0.18.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e14989307e408d9f4245d4fda09a7b144a08114ba124e26cab60ab83dc98db10"
+checksum = "0ec8d02258294f59e4e223b41ad7e81c874aa6b15bc4ced9ba3965826da0eed5"
dependencies = [
"bytemuck",
"libm",
@@ -985,7 +1071,7 @@ checksum = "d315b3197b780e4873bc0e11251cb56a33f65a6032a3d39b8d1405c255513766"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.59",
+ "syn 2.0.60",
]
[[package]]
@@ -1008,8 +1094,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8"
dependencies = [
"cfg-if",
- "hashbrown 0.14.3",
- "indexmap 2.2.6",
+ "hashbrown 0.14.5",
+ "indexmap",
"indoc",
"libc",
"memoffset",
@@ -1053,7 +1139,7 @@ dependencies = [
"proc-macro2",
"pyo3-macros-backend",
"quote",
- "syn 2.0.59",
+ "syn 2.0.60",
]
[[package]]
@@ -1066,19 +1152,20 @@ dependencies = [
"proc-macro2",
"pyo3-build-config",
"quote",
- "syn 2.0.59",
+ "syn 2.0.60",
]
[[package]]
name = "qiskit-accelerate"
-version = "1.1.0"
+version = "1.2.0"
dependencies = [
- "ahash",
+ "ahash 0.8.11",
"approx",
"faer",
"faer-ext",
- "hashbrown 0.14.3",
- "indexmap 2.2.6",
+ "hashbrown 0.14.5",
+ "indexmap",
+ "itertools 0.13.0",
"ndarray",
"num-bigint",
"num-complex",
@@ -1093,19 +1180,25 @@ dependencies = [
"rayon",
"rustworkx-core",
"smallvec",
+ "thiserror",
]
[[package]]
name = "qiskit-circuit"
-version = "1.1.0"
+version = "1.2.0"
dependencies = [
- "hashbrown 0.14.3",
+ "hashbrown 0.14.5",
+ "ndarray",
+ "num-complex",
+ "numpy",
"pyo3",
+ "smallvec",
+ "thiserror",
]
[[package]]
name = "qiskit-pyext"
-version = "1.1.0"
+version = "1.2.0"
dependencies = [
"pyo3",
"qiskit-accelerate",
@@ -1116,19 +1209,19 @@ dependencies = [
[[package]]
name = "qiskit-qasm2"
-version = "1.1.0"
+version = "1.2.0"
dependencies = [
- "hashbrown 0.14.3",
+ "hashbrown 0.14.5",
"pyo3",
"qiskit-circuit",
]
[[package]]
name = "qiskit-qasm3"
-version = "1.1.0"
+version = "1.2.0"
dependencies = [
- "hashbrown 0.14.3",
- "indexmap 2.2.6",
+ "hashbrown 0.14.5",
+ "indexmap",
"oq3_semantics",
"pyo3",
]
@@ -1265,11 +1358,11 @@ checksum = "03251193000f4bd3b042892be858ee50e8b3719f2b08e5833ac4353724632430"
[[package]]
name = "redox_syscall"
-version = "0.4.1"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
+checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags 2.5.0",
]
[[package]]
@@ -1279,7 +1372,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a58fa8a7ccff2aec4f39cc45bf5f985cec7125ab271cf681c279fd00192b49"
dependencies = [
"countme",
- "hashbrown 0.14.3",
+ "hashbrown 0.14.5",
"memoffset",
"rustc-hash",
"text-size",
@@ -1291,16 +1384,23 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
+[[package]]
+name = "rustversion"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47"
+
[[package]]
name = "rustworkx-core"
-version = "0.14.2"
+version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "529027dfaa8125aa61bb7736ae9484f41e8544f448af96918c8da6b1def7f57b"
+checksum = "c2b9aa5926b35dd3029530aef27eac0926b544c78f8e8f1aad4d37854b132fe9"
dependencies = [
- "ahash",
+ "ahash 0.8.11",
"fixedbitset",
- "hashbrown 0.14.3",
- "indexmap 2.2.6",
+ "hashbrown 0.14.5",
+ "indexmap",
+ "ndarray",
"num-traits",
"petgraph",
"priority-queue",
@@ -1333,22 +1433,22 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4"
[[package]]
name = "serde"
-version = "1.0.198"
+version = "1.0.200"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc"
+checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.198"
+version = "1.0.200"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9"
+checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.59",
+ "syn 2.0.60",
]
[[package]]
@@ -1390,9 +1490,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.59"
+version = "2.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a"
+checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
dependencies = [
"proc-macro2",
"quote",
@@ -1427,22 +1527,22 @@ checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233"
[[package]]
name = "thiserror"
-version = "1.0.58"
+version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
+checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.58"
+version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
+checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.59",
+ "syn 2.0.60",
]
[[package]]
@@ -1477,9 +1577,9 @@ checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291"
[[package]]
name = "unicode-width"
-version = "0.1.11"
+version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
+checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6"
[[package]]
name = "unicode-xid"
@@ -1533,11 +1633,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
-version = "0.1.6"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
+checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
dependencies = [
- "winapi",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -1594,21 +1694,6 @@ dependencies = [
"windows_x86_64_msvc 0.42.2",
]
-[[package]]
-name = "windows-targets"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
-dependencies = [
- "windows_aarch64_gnullvm 0.48.5",
- "windows_aarch64_msvc 0.48.5",
- "windows_i686_gnu 0.48.5",
- "windows_i686_msvc 0.48.5",
- "windows_x86_64_gnu 0.48.5",
- "windows_x86_64_gnullvm 0.48.5",
- "windows_x86_64_msvc 0.48.5",
-]
-
[[package]]
name = "windows-targets"
version = "0.52.5"
@@ -1631,12 +1716,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
-[[package]]
-name = "windows_aarch64_gnullvm"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
-
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.5"
@@ -1649,12 +1728,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
-[[package]]
-name = "windows_aarch64_msvc"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
-
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.5"
@@ -1667,12 +1740,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
-[[package]]
-name = "windows_i686_gnu"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
-
[[package]]
name = "windows_i686_gnu"
version = "0.52.5"
@@ -1691,12 +1758,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
-[[package]]
-name = "windows_i686_msvc"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
-
[[package]]
name = "windows_i686_msvc"
version = "0.52.5"
@@ -1709,12 +1770,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
-[[package]]
-name = "windows_x86_64_gnu"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
-
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.5"
@@ -1727,12 +1782,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
-[[package]]
-name = "windows_x86_64_gnullvm"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
-
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.5"
@@ -1745,12 +1794,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
-[[package]]
-name = "windows_x86_64_msvc"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
-
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.5"
@@ -1795,5 +1838,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.59",
+ "syn 2.0.60",
]
diff --git a/Cargo.toml b/Cargo.toml
index 9c4af6260be..a6ccf60f7f4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2"
[workspace.package]
-version = "1.1.0"
+version = "1.2.0"
edition = "2021"
rust-version = "1.70" # Keep in sync with README.md and rust-toolchain.toml.
license = "Apache-2.0"
@@ -16,6 +16,12 @@ license = "Apache-2.0"
[workspace.dependencies]
indexmap.version = "2.2.6"
hashbrown.version = "0.14.0"
+num-complex = "0.4"
+ndarray = "^0.15.6"
+numpy = "0.21.0"
+smallvec = "1.13"
+thiserror = "1.0"
+
# Most of the crates don't need the feature `extension-module`, since only `qiskit-pyext` builds an
# actual C extension (the feature disables linking in `libpython`, which is forbidden in Python
# distributions). We only activate that feature when building the C extension module; we still need
diff --git a/SECURITY.md b/SECURITY.md
index 1a8e9cea671..45e6a9d6f51 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -15,13 +15,13 @@ We provide more detail on [the release and support schedule of Qiskit in our doc
## Reporting a Vulnerability
To report vulnerabilities, you can privately report a potential security issue
-via the Github security vulnerabilities feature. This can be done here:
+via the GitHub security vulnerabilities feature. This can be done here:
https://github.com/Qiskit/qiskit/security/advisories
Please do **not** open a public issue about a potential security vulnerability.
-You can find more details on the security vulnerability feature in the Github
+You can find more details on the security vulnerability feature in the GitHub
documentation here:
https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability
diff --git a/constraints.txt b/constraints.txt
index d3985581d36..6681de226d9 100644
--- a/constraints.txt
+++ b/constraints.txt
@@ -3,6 +3,10 @@
# https://github.com/Qiskit/qiskit-terra/issues/10345 for current details.
scipy<1.11; python_version<'3.12'
+# Temporary pin to avoid CI issues caused by scipy 1.14.0
+# See https://github.com/Qiskit/qiskit/issues/12655 for current details.
+scipy==1.13.1; python_version=='3.12'
+
# z3-solver from 4.12.3 onwards upped the minimum macOS API version for its
# wheels to 11.7. The Azure VM images contain pre-built CPythons, of which at
# least CPython 3.8 was compiled for an older macOS, so does not match a
diff --git a/crates/README.md b/crates/README.md
index cbe58afa07d..d72247bc61d 100644
--- a/crates/README.md
+++ b/crates/README.md
@@ -29,11 +29,11 @@ This would be a particular problem for defining the circuit object and using it
## Developer notes
-### Beware of initialisation order
+### Beware of initialization order
-The Qiskit C extension `qiskit._accelerate` needs to be initialised in a single go.
-It is the lowest part of the Python package stack, so it cannot rely on importing other parts of the Python library at initialisation time (except for exceptions through PyO3's `import_exception!` mechanism).
-This is because, unlike pure-Python modules, the initialisation of `_accelerate` cannot be done partially, and many components of Qiskit import their accelerators from `_accelerate`.
+The Qiskit C extension `qiskit._accelerate` needs to be initialized in a single go.
+It is the lowest part of the Python package stack, so it cannot rely on importing other parts of the Python library at initialization time (except for exceptions through PyO3's `import_exception!` mechanism).
+This is because, unlike pure-Python modules, the initialization of `_accelerate` cannot be done partially, and many components of Qiskit import their accelerators from `_accelerate`.
In general, this should not be too onerous a requirement, but if you violate it, you might see Rust panics on import, and PyO3 should wrap that up into an exception.
You might be able to track down the Rust source of the import cycle by running the import with the environment variable `RUST_BACKTRACE=full`.
diff --git a/crates/accelerate/Cargo.toml b/crates/accelerate/Cargo.toml
index 05ca3f5b639..9d602478399 100644
--- a/crates/accelerate/Cargo.toml
+++ b/crates/accelerate/Cargo.toml
@@ -11,20 +11,22 @@ doctest = false
[dependencies]
rayon = "1.10"
-numpy = "0.21.0"
+numpy.workspace = true
rand = "0.8"
rand_pcg = "0.3"
rand_distr = "0.4.3"
ahash = "0.8.11"
num-traits = "0.2"
-num-complex = "0.4"
+num-complex.workspace = true
num-bigint = "0.4"
-rustworkx-core = "0.14"
-faer = "0.18.2"
+rustworkx-core = "0.15"
+faer = "0.19.1"
+itertools = "0.13.0"
qiskit-circuit.workspace = true
+thiserror.workspace = true
[dependencies.smallvec]
-version = "1.13"
+workspace = true
features = ["union"]
[dependencies.pyo3]
@@ -32,7 +34,7 @@ workspace = true
features = ["hashbrown", "indexmap", "num-complex", "num-bigint", "smallvec"]
[dependencies.ndarray]
-version = "^0.15.6"
+workspace = true
features = ["rayon", "approx-0_5"]
[dependencies.approx]
@@ -48,9 +50,9 @@ workspace = true
features = ["rayon"]
[dependencies.faer-ext]
-version = "0.1.0"
+version = "0.2.0"
features = ["ndarray"]
[dependencies.pulp]
-version = "0.18.10"
+version = "0.18.21"
features = ["macro"]
diff --git a/crates/accelerate/src/convert_2q_block_matrix.rs b/crates/accelerate/src/convert_2q_block_matrix.rs
index e311c129b11..9c179397d64 100644
--- a/crates/accelerate/src/convert_2q_block_matrix.rs
+++ b/crates/accelerate/src/convert_2q_block_matrix.rs
@@ -20,10 +20,7 @@ use numpy::ndarray::{aview2, Array2, ArrayView2};
use numpy::{IntoPyArray, PyArray2, PyReadonlyArray2};
use smallvec::SmallVec;
-static ONE_QUBIT_IDENTITY: [[Complex64; 2]; 2] = [
- [Complex64::new(1., 0.), Complex64::new(0., 0.)],
- [Complex64::new(0., 0.), Complex64::new(1., 0.)],
-];
+use qiskit_circuit::gate_matrix::ONE_QUBIT_IDENTITY;
/// Return the matrix Operator resulting from a block of Instructions.
#[pyfunction]
diff --git a/crates/accelerate/src/dense_layout.rs b/crates/accelerate/src/dense_layout.rs
index 7cb54140761..9529742d7e6 100644
--- a/crates/accelerate/src/dense_layout.rs
+++ b/crates/accelerate/src/dense_layout.rs
@@ -15,8 +15,8 @@ use ahash::RandomState;
use hashbrown::{HashMap, HashSet};
use indexmap::IndexSet;
use ndarray::prelude::*;
+use numpy::IntoPyArray;
use numpy::PyReadonlyArray2;
-use numpy::ToPyArray;
use rayon::prelude::*;
use pyo3::prelude::*;
@@ -108,10 +108,35 @@ pub fn best_subset(
use_error: bool,
symmetric_coupling_map: bool,
error_matrix: PyReadonlyArray2,
-) -> PyResult<(PyObject, PyObject, PyObject)> {
+) -> (PyObject, PyObject, PyObject) {
let coupling_adj_mat = coupling_adjacency.as_array();
- let coupling_shape = coupling_adj_mat.shape();
let err = error_matrix.as_array();
+ let [rows, cols, best_map] = best_subset_inner(
+ num_qubits,
+ coupling_adj_mat,
+ num_meas,
+ num_cx,
+ use_error,
+ symmetric_coupling_map,
+ err,
+ );
+ (
+ rows.into_pyarray_bound(py).into(),
+ cols.into_pyarray_bound(py).into(),
+ best_map.into_pyarray_bound(py).into(),
+ )
+}
+
+pub fn best_subset_inner(
+ num_qubits: usize,
+ coupling_adj_mat: ArrayView2,
+ num_meas: usize,
+ num_cx: usize,
+ use_error: bool,
+ symmetric_coupling_map: bool,
+ err: ArrayView2,
+) -> [Vec; 3] {
+ let coupling_shape = coupling_adj_mat.shape();
let avg_meas_err = err.diag().mean().unwrap();
let map_fn = |k| -> SubsetResult {
@@ -172,7 +197,7 @@ pub fn best_subset(
SubsetResult {
count: 0,
map: Vec::new(),
- error: std::f64::INFINITY,
+ error: f64::INFINITY,
subgraph: Vec::new(),
}
};
@@ -216,11 +241,7 @@ pub fn best_subset(
let rows: Vec = new_cmap.iter().map(|edge| edge[0]).collect();
let cols: Vec = new_cmap.iter().map(|edge| edge[1]).collect();
- Ok((
- rows.to_pyarray_bound(py).into(),
- cols.to_pyarray_bound(py).into(),
- best_map.to_pyarray_bound(py).into(),
- ))
+ [rows, cols, best_map]
}
#[pymodule]
diff --git a/crates/accelerate/src/euler_one_qubit_decomposer.rs b/crates/accelerate/src/euler_one_qubit_decomposer.rs
index 1fd5fd7834f..01725269bb8 100644
--- a/crates/accelerate/src/euler_one_qubit_decomposer.rs
+++ b/crates/accelerate/src/euler_one_qubit_decomposer.rs
@@ -21,9 +21,9 @@ use std::f64::consts::PI;
use std::ops::Deref;
use std::str::FromStr;
-use pyo3::exceptions::{PyIndexError, PyValueError};
+use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
-use pyo3::types::PyString;
+use pyo3::types::{PyList, PyString};
use pyo3::wrap_pyfunction;
use pyo3::Python;
@@ -31,7 +31,8 @@ use ndarray::prelude::*;
use numpy::PyReadonlyArray2;
use pyo3::pybacked::PyBackedStr;
-use qiskit_circuit::SliceOrInt;
+use qiskit_circuit::slice::{PySequenceIndex, SequenceIndex};
+use qiskit_circuit::util::c64;
pub const ANGLE_ZERO_EPSILON: f64 = 1e-12;
@@ -96,46 +97,15 @@ impl OneQubitGateSequence {
Ok(self.gates.len())
}
- fn __getitem__(&self, py: Python, idx: SliceOrInt) -> PyResult {
- match idx {
- SliceOrInt::Slice(slc) => {
- let len = self.gates.len().try_into().unwrap();
- let indices = slc.indices(len)?;
- let mut out_vec: Vec<(String, SmallVec<[f64; 3]>)> = Vec::new();
- // Start and stop will always be positive the slice api converts
- // negatives to the index for example:
- // list(range(5))[-1:-3:-1]
- // will return start=4, stop=2, and step=-1
- let mut pos: isize = indices.start;
- let mut cond = if indices.step < 0 {
- pos > indices.stop
- } else {
- pos < indices.stop
- };
- while cond {
- if pos < len as isize {
- out_vec.push(self.gates[pos as usize].clone());
- }
- pos += indices.step;
- if indices.step < 0 {
- cond = pos > indices.stop;
- } else {
- cond = pos < indices.stop;
- }
- }
- Ok(out_vec.into_py(py))
- }
- SliceOrInt::Int(idx) => {
- let len = self.gates.len() as isize;
- if idx >= len || idx < -len {
- Err(PyIndexError::new_err(format!("Invalid index, {idx}")))
- } else if idx < 0 {
- let len = self.gates.len();
- Ok(self.gates[len - idx.unsigned_abs()].to_object(py))
- } else {
- Ok(self.gates[idx as usize].to_object(py))
- }
- }
+ fn __getitem__(&self, py: Python, idx: PySequenceIndex) -> PyResult {
+ match idx.with_len(self.gates.len())? {
+ SequenceIndex::Int(idx) => Ok(self.gates[idx].to_object(py)),
+ indices => Ok(PyList::new_bound(
+ py,
+ indices.iter().map(|pos| self.gates[pos].to_object(py)),
+ )
+ .into_any()
+ .unbind()),
}
}
}
@@ -855,16 +825,16 @@ pub fn params_xyx(unitary: PyReadonlyArray2) -> [f64; 4] {
fn params_xzx_inner(umat: ArrayView2) -> [f64; 4] {
let det = det_one_qubit(umat);
- let phase = (Complex64::new(0., -1.) * det.ln()).re / 2.;
+ let phase = det.ln().im / 2.;
let sqrt_det = det.sqrt();
let mat_zyz = arr2(&[
[
- Complex64::new((umat[[0, 0]] / sqrt_det).re, (umat[[1, 0]] / sqrt_det).im),
- Complex64::new((umat[[1, 0]] / sqrt_det).re, (umat[[0, 0]] / sqrt_det).im),
+ c64((umat[[0, 0]] / sqrt_det).re, (umat[[1, 0]] / sqrt_det).im),
+ c64((umat[[1, 0]] / sqrt_det).re, (umat[[0, 0]] / sqrt_det).im),
],
[
- Complex64::new(-(umat[[1, 0]] / sqrt_det).re, (umat[[0, 0]] / sqrt_det).im),
- Complex64::new((umat[[0, 0]] / sqrt_det).re, -(umat[[1, 0]] / sqrt_det).im),
+ c64(-(umat[[1, 0]] / sqrt_det).re, (umat[[0, 0]] / sqrt_det).im),
+ c64((umat[[0, 0]] / sqrt_det).re, -(umat[[1, 0]] / sqrt_det).im),
],
]);
let [theta, phi, lam, phase_zxz] = params_zxz_inner(mat_zyz.view());
diff --git a/crates/accelerate/src/isometry.rs b/crates/accelerate/src/isometry.rs
new file mode 100644
index 00000000000..ceaba2946b3
--- /dev/null
+++ b/crates/accelerate/src/isometry.rs
@@ -0,0 +1,363 @@
+// This code is part of Qiskit.
+//
+// (C) Copyright IBM 2024
+//
+// This code is licensed under the Apache License, Version 2.0. You may
+// obtain a copy of this license in the LICENSE.txt file in the root directory
+// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
+//
+// Any modifications or derivative works of this code must retain this
+// copyright notice, and modified files need to carry a notice indicating
+// that they have been altered from the originals.
+
+use std::ops::BitAnd;
+
+use approx::abs_diff_eq;
+use num_complex::{Complex64, ComplexFloat};
+use pyo3::prelude::*;
+use pyo3::wrap_pyfunction;
+use pyo3::Python;
+
+use hashbrown::HashSet;
+use itertools::Itertools;
+use ndarray::prelude::*;
+use numpy::{IntoPyArray, PyReadonlyArray1, PyReadonlyArray2};
+
+use qiskit_circuit::gate_matrix::ONE_QUBIT_IDENTITY;
+use qiskit_circuit::util::C_ZERO;
+
+/// Find special unitary matrix that maps [c0,c1] to [r,0] or [0,r] if basis_state=0 or
+/// basis_state=1 respectively
+#[pyfunction]
+pub fn reverse_qubit_state(
+ py: Python,
+ state: [Complex64; 2],
+ basis_state: usize,
+ epsilon: f64,
+) -> PyObject {
+ reverse_qubit_state_inner(&state, basis_state, epsilon)
+ .into_pyarray_bound(py)
+ .into()
+}
+
+#[inline(always)]
+fn l2_norm(vec: &[Complex64]) -> f64 {
+ vec.iter()
+ .fold(0., |acc, elem| acc + elem.norm_sqr())
+ .sqrt()
+}
+
+fn reverse_qubit_state_inner(
+ state: &[Complex64; 2],
+ basis_state: usize,
+ epsilon: f64,
+) -> Array2 {
+ let r = l2_norm(state);
+ let r_inv = 1. / r;
+ if r < epsilon {
+ Array2::eye(2)
+ } else if basis_state == 0 {
+ array![
+ [state[0].conj() * r_inv, state[1].conj() * r_inv],
+ [-state[1] * r_inv, state[0] * r_inv],
+ ]
+ } else {
+ array![
+ [-state[1] * r_inv, state[0] * r_inv],
+ [state[0].conj() * r_inv, state[1].conj() * r_inv],
+ ]
+ }
+}
+
+/// This method finds the single-qubit gates for a UCGate to disentangle a qubit:
+/// we consider the n-qubit state v[:,0] starting with k zeros (in the computational basis).
+/// The qubit with label n-s-1 is disentangled into the basis state k_s(k,s).
+
+#[pyfunction]
+pub fn find_squs_for_disentangling(
+ py: Python,
+ v: PyReadonlyArray2,
+ k: usize,
+ s: usize,
+ epsilon: f64,
+ n: usize,
+) -> Vec {
+ let v = v.as_array();
+ let k_prime = 0;
+ let i_start = if b(k, s + 1) == 0 {
+ a(k, s + 1)
+ } else {
+ a(k, s + 1) + 1
+ };
+ let mut output: Vec> = (0..i_start).map(|_| Array2::eye(2)).collect();
+ let mut squs: Vec> = (i_start..2_usize.pow((n - s - 1) as u32))
+ .map(|i| {
+ reverse_qubit_state_inner(
+ &[
+ v[[2 * i * 2_usize.pow(s as u32) + b(k, s), k_prime]],
+ v[[(2 * i + 1) * 2_usize.pow(s as u32) + b(k, s), k_prime]],
+ ],
+ k_s(k, s),
+ epsilon,
+ )
+ })
+ .collect();
+ output.append(&mut squs);
+ output
+ .into_iter()
+ .map(|x| x.into_pyarray_bound(py).into())
+ .collect()
+}
+
+#[pyfunction]
+pub fn apply_ucg(
+ py: Python,
+ m: PyReadonlyArray2,
+ k: usize,
+ single_qubit_gates: Vec>,
+) -> PyObject {
+ let mut m = m.as_array().to_owned();
+ let shape = m.shape();
+ let num_qubits = shape[0].ilog2();
+ let num_col = shape[1];
+ let spacing: usize = 2_usize.pow(num_qubits - k as u32 - 1);
+ for j in 0..2_usize.pow(num_qubits - 1) {
+ let i = (j / spacing) * spacing + j;
+ let gate_index = i / (2_usize.pow(num_qubits - k as u32));
+ for col in 0..num_col {
+ let gate = single_qubit_gates[gate_index].as_array();
+ let a = m[[i, col]];
+ let b = m[[i + spacing, col]];
+ m[[i, col]] = gate[[0, 0]] * a + gate[[0, 1]] * b;
+ m[[i + spacing, col]] = gate[[1, 0]] * a + gate[[1, 1]] * b;
+ }
+ }
+ m.into_pyarray_bound(py).into()
+}
+
+#[inline(always)]
+fn bin_to_int(bin: &[u8]) -> usize {
+ bin.iter()
+ .fold(0_usize, |acc, digit| (acc << 1) + *digit as usize)
+}
+
+#[pyfunction]
+pub fn apply_diagonal_gate(
+ py: Python,
+ m: PyReadonlyArray2,
+ action_qubit_labels: Vec,
+ diag: PyReadonlyArray1,
+) -> PyResult {
+ let diag = diag.as_slice()?;
+ let mut m = m.as_array().to_owned();
+ let shape = m.shape();
+ let num_qubits = shape[0].ilog2();
+ let num_col = shape[1];
+ for state in std::iter::repeat([0_u8, 1_u8])
+ .take(num_qubits as usize)
+ .multi_cartesian_product()
+ {
+ let diag_index = action_qubit_labels
+ .iter()
+ .fold(0_usize, |acc, i| (acc << 1) + state[*i] as usize);
+ let i = bin_to_int(&state);
+ for j in 0..num_col {
+ m[[i, j]] = diag[diag_index] * m[[i, j]]
+ }
+ }
+ Ok(m.into_pyarray_bound(py).into())
+}
+
+#[pyfunction]
+pub fn apply_diagonal_gate_to_diag(
+ mut m_diagonal: Vec,
+ action_qubit_labels: Vec,
+ diag: PyReadonlyArray1,
+ num_qubits: usize,
+) -> PyResult> {
+ let diag = diag.as_slice()?;
+ if m_diagonal.is_empty() {
+ return Ok(m_diagonal);
+ }
+ for state in std::iter::repeat([0_u8, 1_u8])
+ .take(num_qubits)
+ .multi_cartesian_product()
+ .take(m_diagonal.len())
+ {
+ let diag_index = action_qubit_labels
+ .iter()
+ .fold(0_usize, |acc, i| (acc << 1) + state[*i] as usize);
+ let i = bin_to_int(&state);
+ m_diagonal[i] *= diag[diag_index]
+ }
+ Ok(m_diagonal)
+}
+
+/// Helper method for _apply_multi_controlled_gate. This constructs the basis states the MG gate
+/// is acting on for a specific state state_free of the qubits we neither control nor act on
+fn construct_basis_states(
+ state_free: &[u8],
+ control_set: &HashSet,
+ target_label: usize,
+) -> [usize; 2] {
+ let size = state_free.len() + control_set.len() + 1;
+ let mut e1: usize = 0;
+ let mut e2: usize = 0;
+ let mut j = 0;
+ for i in 0..size {
+ e1 <<= 1;
+ e2 <<= 1;
+ if control_set.contains(&i) {
+ e1 += 1;
+ e2 += 1;
+ } else if i == target_label {
+ e2 += 1;
+ } else {
+ e1 += state_free[j] as usize;
+ e2 += state_free[j] as usize;
+ j += 1
+ }
+ }
+ [e1, e2]
+}
+
+#[pyfunction]
+pub fn apply_multi_controlled_gate(
+ py: Python,
+ m: PyReadonlyArray2,
+ control_labels: Vec,
+ target_label: usize,
+ gate: PyReadonlyArray2,
+) -> PyObject {
+ let mut m = m.as_array().to_owned();
+ let gate = gate.as_array();
+ let shape = m.shape();
+ let num_qubits = shape[0].ilog2();
+ let num_col = shape[1];
+ let free_qubits = num_qubits as usize - control_labels.len() - 1;
+ let control_set: HashSet = control_labels.into_iter().collect();
+ if free_qubits == 0 {
+ let [e1, e2] = construct_basis_states(&[], &control_set, target_label);
+ for i in 0..num_col {
+ let temp: Vec<_> = gate
+ .dot(&aview2(&[[m[[e1, i]]], [m[[e2, i]]]]))
+ .into_iter()
+ .take(2)
+ .collect();
+ m[[e1, i]] = temp[0];
+ m[[e2, i]] = temp[1];
+ }
+ return m.into_pyarray_bound(py).into();
+ }
+ for state_free in std::iter::repeat([0_u8, 1_u8])
+ .take(free_qubits)
+ .multi_cartesian_product()
+ {
+ let [e1, e2] = construct_basis_states(&state_free, &control_set, target_label);
+ for i in 0..num_col {
+ let temp: Vec<_> = gate
+ .dot(&aview2(&[[m[[e1, i]]], [m[[e2, i]]]]))
+ .into_iter()
+ .take(2)
+ .collect();
+ m[[e1, i]] = temp[0];
+ m[[e2, i]] = temp[1];
+ }
+ }
+ m.into_pyarray_bound(py).into()
+}
+
+#[pyfunction]
+pub fn ucg_is_identity_up_to_global_phase(
+ single_qubit_gates: Vec>,
+ epsilon: f64,
+) -> bool {
+ let global_phase: Complex64 = if single_qubit_gates[0].as_array()[[0, 0]].abs() >= epsilon {
+ single_qubit_gates[0].as_array()[[0, 0]].finv()
+ } else {
+ return false;
+ };
+ for raw_gate in single_qubit_gates {
+ let gate = raw_gate.as_array();
+ if !abs_diff_eq!(
+ gate.mapv(|x| x * global_phase),
+ aview2(&ONE_QUBIT_IDENTITY),
+ epsilon = 1e-8 // Default tolerance from numpy for allclose()
+ ) {
+ return false;
+ }
+ }
+ true
+}
+
+#[pyfunction]
+fn diag_is_identity_up_to_global_phase(diag: Vec, epsilon: f64) -> bool {
+ let global_phase: Complex64 = if diag[0].abs() >= epsilon {
+ diag[0].finv()
+ } else {
+ return false;
+ };
+ for d in diag {
+ if (global_phase * d - 1.0).abs() >= epsilon {
+ return false;
+ }
+ }
+ true
+}
+
+#[pyfunction]
+pub fn merge_ucgate_and_diag(
+ py: Python,
+ single_qubit_gates: Vec>,
+ diag: Vec,
+) -> Vec {
+ single_qubit_gates
+ .iter()
+ .enumerate()
+ .map(|(i, raw_gate)| {
+ let gate = raw_gate.as_array();
+ let res = aview2(&[[diag[2 * i], C_ZERO], [C_ZERO, diag[2 * i + 1]]]).dot(&gate);
+ res.into_pyarray_bound(py).into()
+ })
+ .collect()
+}
+
+#[inline(always)]
+#[pyfunction]
+fn k_s(k: usize, s: usize) -> usize {
+ if k == 0 {
+ 0
+ } else {
+ let filter = 1 << s;
+ k.bitand(filter) >> s
+ }
+}
+
+#[inline(always)]
+#[pyfunction]
+fn a(k: usize, s: usize) -> usize {
+ k / 2_usize.pow(s as u32)
+}
+
+#[inline(always)]
+#[pyfunction]
+fn b(k: usize, s: usize) -> usize {
+ k - (a(k, s) * 2_usize.pow(s as u32))
+}
+
+#[pymodule]
+pub fn isometry(m: &Bound) -> PyResult<()> {
+ m.add_wrapped(wrap_pyfunction!(diag_is_identity_up_to_global_phase))?;
+ m.add_wrapped(wrap_pyfunction!(find_squs_for_disentangling))?;
+ m.add_wrapped(wrap_pyfunction!(reverse_qubit_state))?;
+ m.add_wrapped(wrap_pyfunction!(apply_ucg))?;
+ m.add_wrapped(wrap_pyfunction!(apply_diagonal_gate))?;
+ m.add_wrapped(wrap_pyfunction!(apply_diagonal_gate_to_diag))?;
+ m.add_wrapped(wrap_pyfunction!(apply_multi_controlled_gate))?;
+ m.add_wrapped(wrap_pyfunction!(ucg_is_identity_up_to_global_phase))?;
+ m.add_wrapped(wrap_pyfunction!(merge_ucgate_and_diag))?;
+ m.add_wrapped(wrap_pyfunction!(a))?;
+ m.add_wrapped(wrap_pyfunction!(b))?;
+ m.add_wrapped(wrap_pyfunction!(k_s))?;
+ Ok(())
+}
diff --git a/crates/accelerate/src/lib.rs b/crates/accelerate/src/lib.rs
index bb7621dce34..dcfbdc9f187 100644
--- a/crates/accelerate/src/lib.rs
+++ b/crates/accelerate/src/lib.rs
@@ -19,6 +19,7 @@ pub mod dense_layout;
pub mod edge_collections;
pub mod error_map;
pub mod euler_one_qubit_decomposer;
+pub mod isometry;
pub mod nlayout;
pub mod optimize_1q_gates;
pub mod pauli_exp_val;
@@ -27,7 +28,9 @@ pub mod sabre;
pub mod sampled_exp_val;
pub mod sparse_pauli_op;
pub mod stochastic_swap;
+pub mod synthesis;
pub mod two_qubit_decompose;
+pub mod uc_gate;
pub mod utils;
pub mod vf2_layout;
diff --git a/crates/accelerate/src/nlayout.rs b/crates/accelerate/src/nlayout.rs
index 1a0b73b25fe..b3709d2804b 100644
--- a/crates/accelerate/src/nlayout.rs
+++ b/crates/accelerate/src/nlayout.rs
@@ -107,8 +107,8 @@ impl NLayout {
physical_qubits: usize,
) -> Self {
let mut res = NLayout {
- virt_to_phys: vec![PhysicalQubit(std::u32::MAX); virtual_qubits],
- phys_to_virt: vec![VirtualQubit(std::u32::MAX); physical_qubits],
+ virt_to_phys: vec![PhysicalQubit(u32::MAX); virtual_qubits],
+ phys_to_virt: vec![VirtualQubit(u32::MAX); physical_qubits],
};
for (virt, phys) in qubit_indices {
res.virt_to_phys[virt.index()] = phys;
@@ -184,7 +184,7 @@ impl NLayout {
#[staticmethod]
pub fn from_virtual_to_physical(virt_to_phys: Vec) -> PyResult {
- let mut phys_to_virt = vec![VirtualQubit(std::u32::MAX); virt_to_phys.len()];
+ let mut phys_to_virt = vec![VirtualQubit(u32::MAX); virt_to_phys.len()];
for (virt, phys) in virt_to_phys.iter().enumerate() {
phys_to_virt[phys.index()] = VirtualQubit(virt.try_into()?);
}
diff --git a/crates/accelerate/src/pauli_exp_val.rs b/crates/accelerate/src/pauli_exp_val.rs
index 29f741f6cf4..8ee4b019b3e 100644
--- a/crates/accelerate/src/pauli_exp_val.rs
+++ b/crates/accelerate/src/pauli_exp_val.rs
@@ -19,6 +19,7 @@ use pyo3::wrap_pyfunction;
use rayon::prelude::*;
use crate::getenv_use_multiple_threads;
+use qiskit_circuit::util::c64;
const PARALLEL_THRESHOLD: usize = 19;
@@ -32,7 +33,7 @@ pub fn fast_sum_with_simd(simd: S, values: &[f64]) -> f64 {
sum + tail.iter().sum::()
}
-/// Compute the pauli expectatation value of a statevector without x
+/// Compute the pauli expectation value of a statevector without x
#[pyfunction]
#[pyo3(text_signature = "(data, num_qubits, z_mask, /)")]
pub fn expval_pauli_no_x(
@@ -63,7 +64,7 @@ pub fn expval_pauli_no_x(
}
}
-/// Compute the pauli expectatation value of a statevector with x
+/// Compute the pauli expectation value of a statevector with x
#[pyfunction]
#[pyo3(text_signature = "(data, num_qubits, z_mask, x_mask, phase, x_max, /)")]
pub fn expval_pauli_with_x(
@@ -88,7 +89,7 @@ pub fn expval_pauli_with_x(
let index_0 = ((i << 1) & mask_u) | (i & mask_l);
let index_1 = index_0 ^ x_mask;
let val_0 = (phase
- * Complex64::new(
+ * c64(
data_arr[index_1].re * data_arr[index_0].re
+ data_arr[index_1].im * data_arr[index_0].im,
data_arr[index_1].im * data_arr[index_0].re
@@ -96,7 +97,7 @@ pub fn expval_pauli_with_x(
))
.re;
let val_1 = (phase
- * Complex64::new(
+ * c64(
data_arr[index_0].re * data_arr[index_1].re
+ data_arr[index_0].im * data_arr[index_1].im,
data_arr[index_0].im * data_arr[index_1].re
@@ -121,7 +122,7 @@ pub fn expval_pauli_with_x(
}
}
-/// Compute the pauli expectatation value of a density matrix without x
+/// Compute the pauli expectation value of a density matrix without x
#[pyfunction]
#[pyo3(text_signature = "(data, num_qubits, z_mask, /)")]
pub fn density_expval_pauli_no_x(
@@ -153,7 +154,7 @@ pub fn density_expval_pauli_no_x(
}
}
-/// Compute the pauli expectatation value of a density matrix with x
+/// Compute the pauli expectation value of a density matrix with x
#[pyfunction]
#[pyo3(text_signature = "(data, num_qubits, z_mask, x_mask, phase, x_max, /)")]
pub fn density_expval_pauli_with_x(
diff --git a/crates/accelerate/src/sabre/layout.rs b/crates/accelerate/src/sabre/layout.rs
index 1cb539d9598..a1e5e9ce641 100644
--- a/crates/accelerate/src/sabre/layout.rs
+++ b/crates/accelerate/src/sabre/layout.rs
@@ -15,6 +15,7 @@ use pyo3::prelude::*;
use pyo3::Python;
use hashbrown::HashSet;
+use ndarray::prelude::*;
use numpy::{IntoPyArray, PyArray, PyReadonlyArray2};
use rand::prelude::*;
use rand_pcg::Pcg64Mcg;
@@ -29,6 +30,8 @@ use super::sabre_dag::SabreDAG;
use super::swap_map::SwapMap;
use super::{Heuristic, NodeBlockResults, SabreResult};
+use crate::dense_layout::best_subset_inner;
+
#[pyfunction]
#[pyo3(signature = (dag, neighbor_table, distance_matrix, heuristic, max_iterations, num_swap_trials, num_random_trials, seed=None, partial_layouts=vec![]))]
pub fn sabre_layout_and_routing(
@@ -52,6 +55,12 @@ pub fn sabre_layout_and_routing(
let mut starting_layouts: Vec>> =
(0..num_random_trials).map(|_| vec![]).collect();
starting_layouts.append(&mut partial_layouts);
+ // Run a dense layout trial
+ starting_layouts.push(compute_dense_starting_layout(
+ dag.num_qubits,
+ &target,
+ run_in_parallel,
+ ));
let outer_rng = match seed {
Some(seed) => Pcg64Mcg::seed_from_u64(seed),
None => Pcg64Mcg::from_entropy(),
@@ -208,3 +217,26 @@ fn layout_trial(
.collect();
(initial_layout, final_permutation, sabre_result)
}
+
+fn compute_dense_starting_layout(
+ num_qubits: usize,
+ target: &RoutingTargetView,
+ run_in_parallel: bool,
+) -> Vec