Skip to content

Commit

Permalink
Initial commit of Python bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhartman committed Nov 22, 2023
1 parent 2935f0d commit 5f3dc42
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/accelerate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ mod sampled_exp_val;
mod sparse_pauli_op;
mod stochastic_swap;
mod vf2_layout;
mod quantum_info;

#[inline]
pub fn getenv_use_multiple_threads() -> bool {
Expand All @@ -54,6 +55,7 @@ fn _accelerate(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pymodule!(pauli_exp_val::pauli_expval))?;
m.add_wrapped(wrap_pymodule!(dense_layout::dense_layout))?;
m.add_wrapped(wrap_pymodule!(quantum_circuit::quantum_circuit))?;
m.add_wrapped(wrap_pymodule!(quantum_info::quantum_info))?;
m.add_wrapped(wrap_pymodule!(error_map::error_map))?;
m.add_wrapped(wrap_pymodule!(sparse_pauli_op::sparse_pauli_op))?;
m.add_wrapped(wrap_pymodule!(results::results))?;
Expand Down
21 changes: 21 additions & 0 deletions crates/accelerate/src/quantum_info/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This code is part of Qiskit.
//
// (C) Copyright IBM 2023
//
// 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.

pub mod two_qubit_decompose;

use pyo3::prelude::*;

#[pymodule]
pub fn quantum_info(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(two_qubit_decompose::decompose_two_qubit_product_gate))?;
Ok(())
}
24 changes: 24 additions & 0 deletions crates/accelerate/src/quantum_info/two_qubit_decompose.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// This code is part of Qiskit.
//
// (C) Copyright IBM 2023
//
// 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 pyo3::prelude::*;

#[pyfunction]
#[pyo3(
text_signature = "(special_unitary_matrix)"
)]
pub fn decompose_two_qubit_product_gate(
py: Python<'_>,
special_unitary_matrix: &PyAny,
) -> PyObject {
"This is a string.".into_py(py)
}
1 change: 1 addition & 0 deletions qiskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# and not have to rely on attribute access. No action needed for top-level extension packages.
sys.modules["qiskit._accelerate.nlayout"] = qiskit._accelerate.nlayout
sys.modules["qiskit._accelerate.quantum_circuit"] = qiskit._accelerate.quantum_circuit
sys.modules["qiskit._accelerate.quantum_info"] = qiskit._accelerate.quantum_info
sys.modules["qiskit._accelerate.stochastic_swap"] = qiskit._accelerate.stochastic_swap
sys.modules["qiskit._accelerate.sabre_swap"] = qiskit._accelerate.sabre_swap
sys.modules["qiskit._accelerate.sabre_layout"] = qiskit._accelerate.sabre_layout
Expand Down
23 changes: 23 additions & 0 deletions test/python/quantum_info/test_accelerate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2023.
#
# 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.

"""Tests for synthesis routines in qiskit._accelerate.quantum_info."""
from qiskit._accelerate.quantum_info import decompose_two_qubit_product_gate

from qiskit.test import QiskitTestCase


class TestAccelerate(QiskitTestCase):
"""Test accelerate."""

def test_decompose_two_qubit_product_gate(self):
self.assertIsNotNone(decompose_two_qubit_product_gate(None))

0 comments on commit 5f3dc42

Please sign in to comment.