Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native OpenQASM 3 importer #11584

Merged
merged 29 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
809fff3
Begin work on new OpenQASM 3 importer
jakelishman Jan 11, 2024
cb36c30
Tidy up public interface construction
jakelishman Jan 17, 2024
6cfcd81
Add load-from-file entry point
jakelishman Jan 17, 2024
3fed881
Create public experimental interface
jakelishman Jan 17, 2024
1994717
Credit John
jakelishman Jan 17, 2024
f84e86a
Fix lint
jakelishman Jan 18, 2024
9c622cf
Bump version (git hash) of dependency on openqasm3_parser
jlapeyre Jan 18, 2024
58cb87b
Add support for barrier
jakelishman Jan 19, 2024
2ad7880
Handle measurement with new parser version
jakelishman Jan 22, 2024
3cc0e3e
Fix Rust 1.75 code
jakelishman Jan 24, 2024
b6648c0
Depend on released version of oq3_seamntics
jlapeyre Jan 29, 2024
66e7d60
Add tests of interface successes
jakelishman Jan 30, 2024
787394f
Merge remote-tracking branch 'ibm/main' into qasm3/import
jakelishman Jan 30, 2024
4e47a2c
Add dummy library to manifest
jakelishman Jan 31, 2024
7ea2600
Depend on lastest version, 0.0.7, of openqasm3_parser crates
jlapeyre Jan 31, 2024
0c517fe
Merge remote-tracking branch 'ibm/main' into qasm3/import
jakelishman Jan 31, 2024
acb84d5
Expand on readme
jakelishman Jan 31, 2024
9f4e342
Centralise dependencies
jakelishman Jan 31, 2024
a2d2c4f
Fix typing and error typing
jakelishman Jan 31, 2024
eb474fa
Credit Matt
jakelishman Jan 31, 2024
5b8398a
Fix clippy
jakelishman Jan 31, 2024
3345c34
Clone using GIL
jakelishman Jan 31, 2024
9bd6476
Format
jakelishman Jan 31, 2024
fcc79df
Improve error for unexpected angle
jakelishman Jan 31, 2024
6712183
Add test of gate broadcasting
jakelishman Jan 31, 2024
6e729bf
Add additional warnings about experimental interface
jakelishman Jan 31, 2024
c64c8c1
Add release note
jakelishman Jan 31, 2024
fd80ea1
Add comment about diagnostics in docs
jakelishman Jan 31, 2024
f37f279
Correct release series comment
jakelishman Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
596 changes: 557 additions & 39 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ edition = "2021"
rust-version = "1.70" # Keep in sync with README.md and rust-toolchain.toml.
license = "Apache-2.0"

# Shared dependencies that can be inherited. This just helps a little with
# making sure our crates don't directly depend on different versions of things,
# although we can't help it if our transitive dependencies pull in more.
#
# Each crate can add on specific features freely as it inherits.
[workspace.dependencies]
indexmap.version = "2.2.1"
hashbrown.version = "0.14.0"
# This doesn't set `extension-module` as a shared feature because we need to be able to disable it
# during Rust-only testing (see # https://github.com/PyO3/pyo3/issues/340).
pyo3 = { version = "0.20.2", features = ["abi3-py38"] }
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include LICENSE.txt
include requirements.txt
include qiskit/qasm/libs/*.inc
recursive-include qiskit/qasm/libs *.inc
include qiskit/VERSION.txt
include qiskit/visualization/circuit/styles/*.json
recursive-include qiskit/providers/fake_provider/backends *.json
Expand Down
4 changes: 2 additions & 2 deletions crates/accelerate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ version = "^0.15.6"
features = ["rayon"]

[dependencies.hashbrown]
version = "0.14.0"
workspace = true
features = ["rayon"]

[dependencies.indexmap]
version = "2.2.1"
workspace = true
features = ["rayon"]

[dependencies.faer]
Expand Down
2 changes: 1 addition & 1 deletion crates/qasm2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ default = ["extension-module"]
extension-module = ["pyo3/extension-module"]

[dependencies]
hashbrown = "0.14.0"
hashbrown.workspace = true
pyo3.workspace = true
21 changes: 21 additions & 0 deletions crates/qasm3/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "qiskit-qasm3"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true

[lib]
name = "qiskit_qasm3"
crate-type = ["cdylib"]

[features]
# This is a test-only shim removable feature. See the root `Cargo.toml`.
default = ["extension-module"]
extension-module = ["pyo3/extension-module"]

[dependencies]
pyo3.workspace = true
indexmap.workspace = true
hashbrown.workspace = true
oq3_semantics = "0.0.7"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this pin the version at 0.0.7? In principle we could make backward compatible bug fixes in 0.0.8. There are certainly some bugs that would affect this importer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we might want to release 0.1.0 of the parser in order to allow fixes:
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-cratesio

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then oq3_semantics = "0.1.0" would be compatible with 0.1.1, etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this dependency is equivalent to >=0.0.7,<0.0.8. Cargo treats leading zeros specially - it basically treats the leftmost non-zero as the semantic-version "major". For how we're updating the base library at the moment, I think that's actually fairly accurate (and not a problem on either side).

That said, this doesn't really affect anything, because we build our Rust crates into cdylib Python extensions that we treat give-or-take like fixed binary objects - one of those ways is that we pin our dependencies with the lockfile, so only precise lockfile updates affect the build environment, and (for the most part) are made separately to Rust code changes. In this case, large tracts of the lockfile are updated because there's so many new dependencies getting pulled in.

Copy link
Contributor

@jlapeyre jlapeyre Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, I just released openqasm3_parser 0.1.0 ., This is the same as 0.0.7. Just changed the version (and reduced the sleep between publishing crates to 60 s) : https://crates.io/crates/oq3_semantics

I'm not sure I follow everything you said about versions. But if I understand correctly, a particular version of Qiskit includes a fixed version of every file, including the Cargo.lock files. And these
fix precise versions of Rust dependencies of Qiksit.

7 changes: 7 additions & 0 deletions crates/qasm3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# `qiskit._qasm3`

This crate is the Rust-level Qiskit interface to [a separately managed OpenQASM 3
parser](https://github.com/Qiskit/openqasm3_parser). In order to maintain a sensible separation of
concerns, and because we hope to expand the use of that parser outside Qiskit, the parsing side does
not depend on Qiskit, and this crate interfaces with it in a Qiskit-specific manner to produce
`QuantumCircuit`s.