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

feat: Support classical expressions #86

Merged
merged 8 commits into from
Nov 6, 2024
Merged

feat: Support classical expressions #86

merged 8 commits into from
Nov 6, 2024

Conversation

aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented Nov 5, 2024

Closes #83

The json schema has not been updated yet (see CQCL/tket#1654), so the format may not be completely correct.

Edit: json schema is now merged CQCL/tket#1660

@aborgna-q aborgna-q force-pushed the ab/clexprop branch 2 times, most recently from 7e4c675 to c1fbb5f Compare November 5, 2024 14:03
@aborgna-q aborgna-q requested a review from cqc-alec November 5, 2024 14:32
Variable(ClVariable),
/// A constant integer.
#[serde(rename = "int")]
Int(u32),
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are actually u64 values.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or rather, they will be after CQCL/tket#1657 is merged.

Register {
/// The register index.
index: u32,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is also a Bit variable which should be in this enum too.

src/clexpr.rs Outdated
#[non_exhaustive]
pub struct ClExpr {
/// TODO: ???
pub bit_posn: Vec<u32>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a vector of pairs of u32 (in the C++ it's a map from u32 to u32 but I think it gets serialized as a list of 2-element lists).

src/clexpr.rs Outdated Show resolved Hide resolved
src/clexpr.rs Outdated Show resolved Hide resolved
src/clexpr.rs Outdated Show resolved Hide resolved
src/clexpr.rs Outdated
#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ClExpr {
/// TODO: ???
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a list of pairs of u32, the first of which is the index of a bit variable in the expression, and the second of which is the position in the args list of the bit corresponding to that variable.

src/clexpr.rs Outdated Show resolved Hide resolved
@aborgna-q aborgna-q requested a review from cqc-alec November 5, 2024 16:59
Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

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

LGTM

@aborgna-q aborgna-q added this pull request to the merge queue Nov 6, 2024
Merged via the queue into main with commit aeb1930 Nov 6, 2024
8 checks passed
@aborgna-q aborgna-q deleted the ab/clexprop branch November 6, 2024 17:00
@hugrbot hugrbot mentioned this pull request Nov 6, 2024
github-merge-queue bot pushed a commit that referenced this pull request Nov 13, 2024
## 🤖 New release
* `tket-json-rs`: 0.6.2 -> 0.7.0 (⚠️ API breaking changes)

### ⚠️ `tket-json-rs` breaking changes

```
--- failure enum_variant_missing: pub enum variant removed or renamed ---

Description:
A publicly-visible enum has at least one variant that is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/enum_variant_missing.ron

Failed in:
  variant ClassicalExpUnit::Register, previously in file /tmp/.tmpgK5lkw/tket-json-rs/src/circuit_json.rs:56

--- failure struct_marked_non_exhaustive: struct marked #[non_exhaustive] ---

Description:
A public struct has been marked #[non_exhaustive], which will prevent it from being constructed using a struct literal outside of its crate. It previously had no private fields, so a struct literal could be used to construct it outside its crate.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#attr-adding-non-exhaustive
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/struct_marked_non_exhaustive.ron

Failed in:
  struct SerialCircuit in /tmp/.tmp7Vjg5L/tket-json-rs/src/circuit_json.rs:202
  struct SerialCircuit in /tmp/.tmp7Vjg5L/tket-json-rs/src/circuit_json.rs:202

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/struct_missing.ron

Failed in:
  struct tket_json_rs::circuit_json::Bitstring, previously in file /tmp/.tmpgK5lkw/tket-json-rs/src/circuit_json.rs:35
  struct tket_json_rs::circuit_json::BitRegister, previously in file /tmp/.tmpgK5lkw/tket-json-rs/src/circuit_json.rs:25
  struct tket_json_rs::circuit_json::CompositeGate, previously in file /tmp/.tmpgK5lkw/tket-json-rs/src/circuit_json.rs:14
  struct tket_json_rs::circuit_json::Register, previously in file /tmp/.tmpgK5lkw/tket-json-rs/src/circuit_json.rs:10
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

### ⚠ BREAKING CHANGES

- Made `SerialCircuit` non exhaustive.
- `Register` renamed to `ElementId`, `Qubit` and `Bit`
- Moved some definitions from `::circuit_json` to `::register`
- Bumped MSRV to rust 1.75
- Renamed `circuit_json::CompositeGate` to `CustomGate`

## 0.7.0 (2024-11-13)

### Features

- [**breaking**] `created/discarded_qubits` circuit attribute
([#87](#87))
- Support classical expressions
([#86](#86))
- [**breaking**] Rename `Register` and cleanup definitions
([#89](#89))
- [**breaking**] Support old `Composite` alias for `CustomGate`
([#91](#91))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

---------

Co-authored-by: Agustín Borgna <[email protected]>
@hugrbot hugrbot mentioned this pull request Nov 18, 2024
@aborgna-q aborgna-q assigned aborgna-q and unassigned aborgna-q Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ClExprOp
2 participants