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

Add Rust representation of EquivalenceLibrary #12585

Merged
merged 83 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
a8cddcd
Initial: Add equivalence to `qiskit._accelerate.circuit`
raynelfss Jun 5, 2024
f53b89c
Add: `build_basis_graph` method
raynelfss Jun 10, 2024
a215694
Add: `EquivalencyLibrary` to `qiskit._accelerate.circuit`
raynelfss Jun 11, 2024
7d0f4de
Add: PyDiGraph converter for `equivalence.rs`
raynelfss Jun 12, 2024
0f85dc0
Merge branch 'main' into move-equivalence
raynelfss Jun 12, 2024
f73581e
Add: Extend original equivalence with rust representation
raynelfss Jun 12, 2024
57e0ef8
Fix: Correct circuit parameter extraction
raynelfss Jun 13, 2024
9eddbbf
Merge branch 'Qiskit:main' into move-equivalence
raynelfss Jun 13, 2024
11611e2
Add: Stable infrastructure for EquivalenceLibrary
raynelfss Jun 13, 2024
a013d5b
Merge branch 'main' into move-equivalence
raynelfss Jun 14, 2024
1bf0316
Add: Default methods to equivalence data structures.
raynelfss Jun 14, 2024
ab57e3e
Fix: Adapt to new Gate Structure
raynelfss Jun 14, 2024
0e822b5
Fix: Erroneous display of `Parameters`
raynelfss Jun 15, 2024
6a033c9
Format: Fix lint test
raynelfss Jun 17, 2024
b04cae2
Fix: Use EdgeReferences instead of edge_indices.
raynelfss Jun 17, 2024
5a3bf2b
Merge branch 'main' into move-equivalence
raynelfss Jun 18, 2024
38436cd
Fix: Use StableDiGraph for more stable indexing.
raynelfss Jun 21, 2024
db6acb4
Merge branch 'main' into move-equivalence
raynelfss Jun 21, 2024
e16e57b
Fix: Use `clone` instead of `to_owned`
raynelfss Jun 21, 2024
b8bd422
Merge branch 'Qiskit:main' into move-equivalence
raynelfss Jun 24, 2024
fb1652c
Fix: Use `OperationTypeConstruct` instead of `CircuitInstruction`
raynelfss Jun 24, 2024
139af74
Merge branch 'main' into move-equivalence
raynelfss Jun 24, 2024
27b25e3
Merge branch 'main' into move-equivalence
raynelfss Jun 25, 2024
ab84d04
Merge branch 'Qiskit:main' into move-equivalence
raynelfss Jun 26, 2024
6dec921
Fix: Elide implicit lifetime of PyRef
raynelfss Jun 26, 2024
785564f
Merge branch 'main' into move-equivalence
raynelfss Jun 26, 2024
3b954e4
Fix: Make `CircuitRep` attributes OneCell-like.
raynelfss Jun 26, 2024
48bb8eb
Merge branch 'main' into move-equivalence
raynelfss Jun 26, 2024
ffa0a81
Merge branch 'main' into move-equivalence
raynelfss Jun 27, 2024
9a7d9a0
Fix: Incorrect pickle attribute extraction
raynelfss Jun 28, 2024
e2c8dcb
Merge branch 'main' into move-equivalence
raynelfss Jun 28, 2024
dc3041e
Remove: Default initialization methods from custom datatypes.
raynelfss Jun 28, 2024
a072635
Remove: `__getstate__`, `__setstate__`, use `__getnewargs__` instead.
raynelfss Jun 28, 2024
77dbec8
Fix: Further improvements to pickling
raynelfss Jul 1, 2024
cd0b36e
Merge branch 'main' into move-equivalence
raynelfss Jul 1, 2024
73e5b5b
Merge branch 'main' into move-equivalence
raynelfss Jul 1, 2024
72e1c33
Fix: Use `PyList` and iterators when possible to skip extra conversion.
raynelfss Jul 2, 2024
17eb9d2
Fix: incorrect list operation in `__getstate__`
raynelfss Jul 3, 2024
9d39cf6
Fix: improvements on rust native methods
raynelfss Jul 3, 2024
e9e3921
Remove: `add_equiv`, `set_entry` from rust-native methods.
raynelfss Jul 3, 2024
5519659
Merge branch 'main' into move-equivalence
raynelfss Jul 3, 2024
bf9aedd
Remove: Undo changes to Param
raynelfss Jul 5, 2024
82a456e
Merge branch 'main' into move-equivalence
raynelfss Jul 11, 2024
41764f2
Merge branch 'main' into move-equivalence
raynelfss Jul 12, 2024
08915c0
Fix: Leverage usage of `CircuitData` for accessing the `QuantumCircui…
raynelfss Jul 12, 2024
d24c134
Add: `data()` method to avoid extracting `CircuitData`
raynelfss Jul 15, 2024
bd582f0
Merge branch 'main' into move-equivalence
raynelfss Jul 15, 2024
f61288f
Merge branch 'main' into move-equivalence
raynelfss Jul 16, 2024
5a2c57b
Merge branch 'main' into move-equivalence
raynelfss Jul 18, 2024
6772305
Fix: Make `graph` attribute public.
raynelfss Jul 19, 2024
1e44817
Fix: Make `NoteData` attributes public.
raynelfss Jul 19, 2024
22210e3
Fix: Revert reference to `CircuitData`, extract instead.
raynelfss Jul 21, 2024
c99ca3f
Add: Make `EquivalenceLibrary` graph weights optional.
raynelfss Jul 21, 2024
561553a
Merge branch 'Qiskit:main' into move-equivalence
raynelfss Jul 23, 2024
d257db1
Merge branch 'main' into move-equivalence
raynelfss Jul 24, 2024
dd2773a
Fix: Adapt to #12730
raynelfss Jul 24, 2024
e7b3cb0
Fix: Use `IndexSet` and `IndexMap`
raynelfss Jul 24, 2024
aa626b9
Fix: Revert changes from previously failing test
raynelfss Jul 25, 2024
1aaf17a
Merge branch 'main' into move-equivalence
raynelfss Jul 25, 2024
ba90411
Merge branch 'main' into move-equivalence
raynelfss Jul 25, 2024
9f4bfb7
Merge branch 'main' into move-equivalence
raynelfss Jul 25, 2024
d59f0db
Merge branch 'main' into move-equivalence
raynelfss Aug 1, 2024
0d3a164
Fix: Adapt to #12974
raynelfss Aug 1, 2024
feff6eb
Fix: Use `EquivalenceLibrary.keys()` instead of `._key_to_node_index`
raynelfss Aug 2, 2024
6554b38
Merge branch 'main' into move-equivalence
raynelfss Aug 2, 2024
132b6be
Chore: update dependencies
raynelfss Aug 2, 2024
3dbcc41
Refactor: Move `EquivalenceLibrary` to `_accelerate`.
raynelfss Aug 6, 2024
c48f0da
Merge branch 'main' into move-equivalence
raynelfss Aug 6, 2024
d12dee6
Fix: Erroneous `pymodule` function for `equivalence`.
raynelfss Aug 6, 2024
bc9c83f
Merge branch 'main' into move-equivalence
raynelfss Aug 10, 2024
fda119d
Merge branch 'main' into move-equivalence
raynelfss Aug 29, 2024
f44eaba
Merge branch 'main' into move-equivalence
raynelfss Aug 30, 2024
3479254
Fix: Update `EquivalenceLibrary` to store `CircuitData`.
raynelfss Aug 30, 2024
c433c87
Fix: Make inner `CircuitData` instance public.
raynelfss Aug 30, 2024
c77af69
Merge branch 'main' into move-equivalence
raynelfss Sep 4, 2024
82a6dcf
Merge branch 'main' into move-equivalence
raynelfss Sep 5, 2024
1a21204
Merge branch 'main' into move-equivalence-gjl
jlapeyre Sep 18, 2024
b7c6316
Fix: Review comments and ownership issues.
raynelfss Sep 20, 2024
b8e7cff
Merge branch 'main' into move-equivalence
raynelfss Sep 20, 2024
e7d99bc
Fix: Use maximum possible integer value for Key in basis_translator.
raynelfss Sep 23, 2024
bf7486c
Fix: Use generated string, instead of large int
raynelfss Sep 24, 2024
56278bc
Merge branch 'main' into move-equivalence
raynelfss Sep 24, 2024
11f0470
Merge branch 'main' into move-equivalence
raynelfss Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/circuit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ doctest = false

[dependencies]
hashbrown.workspace = true
itertools = "0.13.0"
num-complex.workspace = true
ndarray.workspace = true
numpy.workspace = true
rustworkx-core = "0.14.2"

[dependencies.pyo3]
workspace = true
Expand Down
13 changes: 5 additions & 8 deletions crates/circuit/src/circuit_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,7 @@ impl CircuitInstruction {

/// Take a reference to a `CircuitInstruction` and convert the operation
/// inside that to a python side object.
pub(crate) fn operation_type_to_py(
py: Python,
circuit_inst: &CircuitInstruction,
) -> PyResult<PyObject> {
pub fn operation_type_to_py(py: Python, circuit_inst: &CircuitInstruction) -> PyResult<PyObject> {
let (label, duration, unit, condition) = match &circuit_inst.extra_attrs {
None => (None, None, None, None),
Some(extra_attrs) => (
Expand All @@ -688,7 +685,7 @@ pub(crate) fn operation_type_to_py(
/// a Python side full-fat Qiskit operation as a PyObject. This is typically
/// used by accessor functions that need to return an operation to Qiskit, such
/// as accesing `CircuitInstruction.operation`.
pub(crate) fn operation_type_and_data_to_py(
pub fn operation_type_and_data_to_py(
py: Python,
operation: &OperationType,
params: &[Param],
Expand Down Expand Up @@ -727,8 +724,8 @@ pub(crate) fn operation_type_and_data_to_py(

/// A container struct that contains the output from the Python object to
/// conversion to construct a CircuitInstruction object
#[derive(Debug)]
pub(crate) struct OperationTypeConstruct {
#[derive(Debug, Clone)]
pub struct OperationTypeConstruct {
pub operation: OperationType,
pub params: SmallVec<[Param; 3]>,
pub label: Option<String>,
Expand All @@ -740,7 +737,7 @@ pub(crate) struct OperationTypeConstruct {
/// Convert an inbound Python object for a Qiskit operation and build a rust
/// representation of that operation. This will map it to appropriate variant
/// of operation type based on class
pub(crate) fn convert_py_to_operation_type(
pub fn convert_py_to_operation_type(
py: Python,
py_op: PyObject,
) -> PyResult<OperationTypeConstruct> {
Expand Down
Loading
Loading