Commit Graph

17 Commits

Author SHA1 Message Date
dependabot[bot] 2e679dc905
Bump indexmap from 2.0.0 to 2.0.1 (#10912)
* Bump indexmap from 2.0.0 to 2.0.1

Bumps [indexmap](https://github.com/bluss/indexmap) from 2.0.0 to 2.0.1.
- [Changelog](https://github.com/bluss/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/bluss/indexmap/commits)

---
updated-dependencies:
- dependency-name: indexmap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix transitive but API-exposed dependencies on `indexmap`

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2023-09-29 14:02:48 +00:00
dependabot[bot] a9f9cee30a
Bump rayon from 1.7.0 to 1.8.0 (#10873)
Bumps [rayon](https://github.com/rayon-rs/rayon) from 1.7.0 to 1.8.0.
- [Changelog](https://github.com/rayon-rs/rayon/blob/master/RELEASES.md)
- [Commits](https://github.com/rayon-rs/rayon/compare/rayon-core-v1.7.0...rayon-core-v1.8.0)

---
updated-dependencies:
- dependency-name: rayon
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-21 15:51:16 +00:00
Jake Lishman 180f19a8fb
Use `SmallVec` in `NeighborTable` for cache locality (#10784)
* Use `SmallVec` in `NeighborTable` for cache locality

A reasonable chunk of our time in Sabre is spent reading through the
`NeighborTable` to find the candidate swaps for a given layout.  Most
coupling maps that we care about have a relatively low number of edges
between qubits, yet we needed to redirect to the heap for each
individual physical-qubit lookup currently.

This switches from using a `Vec` (which is always a fat pointer to heap
memory) to `SmallVec` with an inline buffer space of four qubits.
With the qubit type being `u32`, the `SmallVec` now takes up the same
stack size as a `Vec` but can store (usually) all the swaps directly
inline in the outer `Vec` of qubits.  This means that most lookups of
the available swaps are looking in the same (up to relatively small
offsets) in memory, which makes the access patterns much easier for
prefetching to optimise for.

* Pickle via `PyList` instead of duplicate conversion

`SmallVec` doesn't have implementations of the PyO3 conversion trait, so
it needs to be done manually.  The previous state used to convert to a
Rust-space `Vec` that then needed to have its data moved from the Python
heap to the Rust heap.  This instead changes the conversions to interact
directly with Python lists, rather than using intermediary structures.
2023-09-06 19:50:06 +00:00
Jake Lishman 1606ca3544
Fail gracefully on bad `SabreDAG` construction (#10724)
* Fail gracefully on bad `SabreDAG` construction

This is a private, internal Rust type, but it doesn't cost us anything
(meaningful) to bounds-check the accessors and ensure we fail gracefully
rather than panicking if we ever make a mistake in Python space. This
more faithfully fulfills the return value of `SabreDAG::new`, which
previously was an effectively infallible `Result`.

* Run `cargo fmt`
2023-09-04 15:15:44 +00:00
Kevin Hartman 2062246191
Bump hashbrown to 0.14.0. (#10540)
* Bump hashbrown to 0.13.2.

* Bump hashbrown to 0.14.0 and indexmap to 2.0.0.
2023-08-15 20:22:29 +00:00
Jake Lishman 290305a2b0
Update minimum Rust version to 1.64 (#10541)
Raising the minimum Rust version lets us access workspace dependencies,
which are a convenient way of managing shared metadata between the
different crates in the project, which deduplicates a good amount of
our metadata.  This also lets us share the PyO3 version and minimum
feature set between crates, reducing the number of places that need to
be updated on a Python version bump.

`Cargo.lock` is completely regenerated for this commit with the new
unification, with the minor tweak of having run

        cargo update -p 'indexmap@2.0.0' --precise '1.9.3'

This is required to unify the `hashbrown` versions down to 0.12.3
between our dependencies and `pyo3`, which otherwise transitively
depends on `hashbrown ^0.14` via pulling in `indexmap 2.0`.  This caused
a build failure, since the `hashbrown` types that PyO3 adds `impl`s of
its traits to are not the same types that our extension modules attempt
to use with it.
2023-08-03 14:13:44 +00:00
dependabot[bot] 28113b6a9f
Bump pyo3 from 0.19.1 to 0.19.2 (#10543)
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.19.1 to 0.19.2.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.19.1...v0.19.2)

---
updated-dependencies:
- dependency-name: pyo3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 12:48:14 +00:00
Jake Lishman 84aed0c3ea
Bump version numbers post 0.25.0rc1 (#10464)
This opens development on `main` for the next minor version of *Qiskit*
(no longer to be called Terra).  The version number is jumping to 0.45
to bring the version of `qiskit-terra` in line with `qiskit` (currently
the metapackge); starting from "Qiskit 0.45", this repository will be
called `qiskit` only, and the packages `qiskit` and `qiskit-terra` will
be unified, at least as far as Python packaging allows us to do.
2023-07-21 17:49:47 +00:00
Kevin Hartman 49b383a978
Support control flow in `SabreSwap` and `SabreLayout`. (#10366)
* Initial commit.

* Downgrade hashbrown to 0.12.3 for compat with Rustworkx.

* Implement gen_swap_epilogue.

* Add Python wrappers for structs.

* Implement DAG -> SabreDAG.

* Apply block results in sabre_swap.py.

* Fix node ID lookup issue.

Previously, we were using original DAG node IDs to look up nodes
in the expanded nested DAGs, but these IDs are of course not the
same.

* Fix bug where block circuits started out non-empty!

* Move DAG building and result application to functions.

* Implement control flow handling for Sabre layout.

* Fix qreg indexing bug for new swaps versus routed gates.

* Run Python formatting.

* Fix bug where root_dag was used instead of mapped_dag.

* Fix bug where swap_epilogue was in terms of physical bits instead of logical.

* Add more tests from stochastic swap.

* Fix bug mapping inner block qubits to outer circuit qubits.

* Update sabre swap testing.

* Update TODOs.

* Fix bug where a 2Q CF nodes would be mistakenly added to the extended set.

* Port more testing from stochastic swap.

* Run formatting.

* Port remaining stochastic swap tests.

* Mark Sabre routing and layout as known good for CF.

* Add random circuit valid output testing for Sabre.

* Run cargo fmt.

* Fix lint issues.

* Fix lint issues.

* Update 'test_invalid_methods_raise_on_control_flow'

* Make gen_swap_epilogue consume 'from_layout'.

* Add release note.

* Update TODO comment about num_qubits.

* Add comment about forward DAG.

* Explicitly mark NodeBlockResults as a mapping.

* Use closure instead of lambda noun.

* Add comment to make gate placement handling clearer.

* Use hashbrown::HashMap in SabreDAG.

* Add caching of circuit_to_dag.

* Simplify parameters to _build_sabre_dag.

- Makes it more explicit that the num_qubits used in a SabreDAG
  should be the number of physical qubits on the device.
- We no longer pass clbit indices because they are always local to
  the block, i.e. there's no current reason for them to be consistent
  across the root DAG and inner blocks, like we must do for qubits.

* Copy cregs during empty_dag.

* Comment-out assert.

* Use intersection_update.

* Remove unused import.

* Add caching for block dict.

* Fix import order.

* Follow types consistently in test.
2023-07-18 23:09:02 +00:00
dependabot[bot] 9bfee5612e
Bump pyo3 from 0.19.0 to 0.19.1 (#10378)
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.19.0 to 0.19.1.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.19.0...v0.19.1)

---
updated-dependencies:
- dependency-name: pyo3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-07 02:09:31 +00:00
Matthew Treinish c463b3c474
Use stable Python C API for building Rust extension (#10120)
* Use stable Python C API for building Rust extension

This commit tweaks the rust extension code to start using the PyO3 abi3
flag to build binaries that are compatible with all python versions, not
just a single release. Previously, we were building against the version
specific C API and that resulted in needing abinary file for each
supported python version on each supported platform/architecture. By
using the abi3 feature flag and marking the wheels as being built with
the limited api we can reduce our packaging overhead to just having one
wheel file per supported platform/architecture.

The only real code change needed here was to update the memory
marginalization function. PyO3's abi3 feature is incompatible with
returning a big int object from rust (the C API they use for that
conversion isn't part of the stable C API). So this commit updates the
function to convert to create a python int manually using the PyO3 api
where that was being done before.

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>

* Set minimum version on abi3 flag to Python 3.8

* Fix lint

* Use py_limited_api="auto" on RustExtension

According to the docs for the setuptools-rust RustExtension class:
https://setuptools-rust.readthedocs.io/en/latest/reference.html#setuptools_rust.RustExtension
The best setting to use for the py_limited_api argument is `"auto"` as
this will use the setting in the PyO3 module to determine the correct
value to set. This commit updates the setup.py to follow the
recommendation in the docs.

* Update handling of phase input to expval rust calls

The pauli_expval module in Rust that Statevector and DensityMatrix
leverage when computing defines the input type of the phase argument as
Complex64. Previously, the quantum info code in the Statevector and
DensityMatrix classes were passing in a 1 element ndarray for this
parameter. When using the the version specific Python C API in pyo3 it
would convert the single element array to a scalar value. However when
using abi3 this handling was not done (or was not done correctly) and
this caused the tests to fail. This commit updates the quantum info
module to pass the phase as a complex value instead of a 1 element numpy
array to bypass this behavior change in PyO3 when using abi3.

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>

* Set py_limited_api explicitly to True

* DNM: Test cibuildwheel works with abi3

* Add abi3audit to cibuildwheel repair step

* Force setuptools to use abi3 tag

* Add wheel to sdist build

* Workaround abiaudit3 not moving wheels and windows not having a default repair command

* Add source of setup.py hack

* Add comment about pending pyo3 abi3 bigint support

* Revert "DNM: Test cibuildwheel works with abi3"

This reverts commit 8ca24cf1e4.

* Add release note

* Simplify setting abi3 tag in built wheels

* Update releasenotes/notes/use-abi3-4a935e0557d3833b.yaml

Co-authored-by: Jake Lishman <jake@binhbar.com>

* Update release note

* Update releasenotes/notes/use-abi3-4a935e0557d3833b.yaml

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: Jake Lishman <jake@binhbar.com>
2023-06-12 13:45:27 +00:00
dependabot[bot] cff51cea9b
Bump rustworkx-core from 0.12.1 to 0.13.0 (#10237)
Bumps [rustworkx-core](https://github.com/Qiskit/rustworkx) from 0.12.1 to 0.13.0.
- [Release notes](https://github.com/Qiskit/rustworkx/releases)
- [Commits](https://github.com/Qiskit/rustworkx/compare/0.12.1...0.13.0)

---
updated-dependencies:
- dependency-name: rustworkx-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-07 13:30:39 +00:00
Matthew Treinish f409015bd7
Bump pyo3 and rust numpy version to 0.19.0 (#10186)
* Bump pyo3 and rust numpy version to 0.19.0

PyO3 0.19.0 and rust-numpy 0.19.0 were just released. This commit
updates the version used in qiskit to these latest releases. At the same
time this updates usage of text signature for classes that was
deprecated in the PyO3 0.19.0 release. While not fatal for normal builds
this would have failed clippy in CI because we treat warnings as errors.

* Apply suggestions from code review
2023-05-31 21:25:39 +00:00
Matthew Treinish 908adb3432
Bump main branch version post 0.24.0rc1 tag (#10005)
Now that the first release candidate for the 0.24.0 release has been
tagged, the stable branch for the 0.24 series has been created and we
can start developing the 0.25.0 release on main. This commit bumps all
the version strings from 0.24.0 to 0.25.0 (and the backport branch for
mergify to 0.24) accordingly to differentiate the main branch from
0.24.*.
2023-04-20 21:58:50 +00:00
dependabot[bot] ccf78ae592
Bump pyo3 from 0.18.2 to 0.18.3 (#9964)
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.18.2 to 0.18.3.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.18.2...v0.18.3)

---
updated-dependencies:
- dependency-name: pyo3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-14 12:54:29 +00:00
dependabot[bot] aacbc665d8
Bump pyo3 from 0.18.1 to 0.18.2 (#9854)
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.18.1 to 0.18.2.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.18.1...v0.18.2)

---
updated-dependencies:
- dependency-name: pyo3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-27 19:13:15 +00:00
Jake Lishman c6cd0d577b
Add structure for multiple Rust crates (#9742)
* Add structure for multiplie Rust extension crates

This is a precursor to adding an entirely separate and self-contained
crate to handle parsing of OpenQASM 2 (not 3 - this is kind of like a
trial run for that).  It could conceivably still live within
`qiskit._accelerate`, but having separate crates helps us enforce more
sane API barriers, and has improvements in the incremental build time
when working on only one of the Rust extensions.

The intent after this commit is still to have `qiskit._accelerate` as an
easy catch-all for accelerators for Python.  Developers should not need
to be concerned with defining a new crate for every new feature, and for
the most part `_accelerate` is still logically interoperative within
itself (for example, `NLayout` is used all over).  This is just laying
out the groundwork so more complex crate additions _can_ also be made.

Some of the niceties to do with Cargo workspaces only became stabilised
in Rust 1.64.  In particular, inheritance from the workspace root for
things like the package version, Rust version, and dependencies only
came in then.  For now, the `workspace.packages` key in the root
`Cargo.toml` is ignored with a small warning during the build, but I've
put it in place mostly to keep track of what we can change once the MSRV
becomes 1.64 or greater (likely not til at least Terra 0.26).

* Add README.md to crates/accelerate

* Correct licence metadata
2023-03-07 23:12:39 +00:00