Skip to content

Commit

Permalink
Optional TweezerDevice Current Layout (#194)
Browse files Browse the repository at this point in the history
* stash merge

* test correction

* versioning

* interface

* tests correction

* CHANGELOG correction

* CHANGELOG corr

* more corr

* get_current_layout_info Result
  • Loading branch information
mlodi-hqs authored Nov 2, 2023
1 parent ba361f6 commit 18c532a
Show file tree
Hide file tree
Showing 11 changed files with 504 additions and 181 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Tracks qoqo-qryd changes after 0.5

# 0.11.6

* Modified `TweezerDevice`'s current layout to be optional

# 0.11.5

* Modified `TweezerDevice.from_api()` endpoint, default device name for better `APIBackend` support
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion qoqo-qryd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qoqo-qryd"
version = "0.11.5"
version = "0.11.6"
authors = ["HQS Quantum Simulations <info@quantumsimulations.de>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion qoqo-qryd/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "qoqo_qryd"
version = "0.11.5"
version = "0.11.6"
dependencies = [
'numpy',
'qoqo>=1.6',
Expand Down
62 changes: 41 additions & 21 deletions qoqo-qryd/src/tweezer_devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ impl TweezerDeviceWrapper {
/// Returns:
/// str: The name of the current layout.
pub fn current_layout(&self) -> &str {
self.internal.current_layout.as_str()
self.internal
.current_layout
.as_ref()
.expect("None")
.as_str()
}

/// Switch to a different pre-defined layout.
Expand Down Expand Up @@ -625,7 +629,11 @@ impl TweezerMutableDeviceWrapper {
/// Returns:
/// str: The name of the current layout.
pub fn current_layout(&self) -> &str {
self.internal.current_layout.as_str()
self.internal
.current_layout
.as_ref()
.expect("None")
.as_str()
}

/// Add a new layout to the device.
Expand Down Expand Up @@ -1047,16 +1055,20 @@ impl TweezerMutableDeviceWrapper {
/// gate_time (float): The the gate time for the given gate.
/// layout_name (Optional[str]): The name of the Layout to apply the gate time in.
/// Defaults to the current Layout.
///
/// Raises:
/// ValueError: No layout name provided and no current layout set.
#[pyo3(text_signature = "(hqslang, tweezer, gate_time, layout_name, /)")]
pub fn set_tweezer_single_qubit_gate_time(
&mut self,
hqslang: &str,
tweezer: usize,
gate_time: f64,
layout_name: Option<String>,
) {
) -> PyResult<()> {
self.internal
.set_tweezer_single_qubit_gate_time(hqslang, tweezer, gate_time, layout_name)
.map_err(|err| PyValueError::new_err(format!("{:}", err)))
}

/// Set the time of a two-qubit gate for a tweezer couple in a given Layout.
Expand All @@ -1068,6 +1080,9 @@ impl TweezerMutableDeviceWrapper {
/// gate_time (float): The the gate time for the given gate.
/// layout_name (Optional[str]): The name of the Layout to apply the gate time in.
/// Defaults to the current Layout.
///
/// Raises:
/// ValueError: No layout name provided and no current layout set.
#[pyo3(text_signature = "(hqslang, tweezer0, tweezer1, gate_time, layout_name, /)")]
pub fn set_tweezer_two_qubit_gate_time(
&mut self,
Expand All @@ -1076,14 +1091,10 @@ impl TweezerMutableDeviceWrapper {
tweezer1: usize,
gate_time: f64,
layout_name: Option<String>,
) {
self.internal.set_tweezer_two_qubit_gate_time(
hqslang,
tweezer0,
tweezer1,
gate_time,
layout_name,
)
) -> PyResult<()> {
self.internal
.set_tweezer_two_qubit_gate_time(hqslang, tweezer0, tweezer1, gate_time, layout_name)
.map_err(|err| PyValueError::new_err(format!("{:}", err)))
}

/// Set the time of a three-qubit gate for a tweezer trio in a given Layout.
Expand All @@ -1096,6 +1107,9 @@ impl TweezerMutableDeviceWrapper {
/// gate_time (float): The the gate time for the given gate.
/// layout_name (Optional[str]): The name of the Layout to apply the gate time in.
/// Defaults to the current Layout.
///
/// Raises:
/// ValueError: No layout name provided and no current layout set.
#[pyo3(text_signature = "(hqslang, tweezer0, tweezer1, tweezer2, gate_time, layout_name, /)")]
pub fn set_tweezer_three_qubit_gate_time(
&mut self,
Expand All @@ -1105,15 +1119,17 @@ impl TweezerMutableDeviceWrapper {
tweezer2: usize,
gate_time: f64,
layout_name: Option<String>,
) {
self.internal.set_tweezer_three_qubit_gate_time(
hqslang,
tweezer0,
tweezer1,
tweezer2,
gate_time,
layout_name,
)
) -> PyResult<()> {
self.internal
.set_tweezer_three_qubit_gate_time(
hqslang,
tweezer0,
tweezer1,
tweezer2,
gate_time,
layout_name,
)
.map_err(|err| PyValueError::new_err(format!("{:}", err)))
}

/// Set the time of a multi-qubit gate for a list of tweezers in a given Layout.
Expand All @@ -1124,16 +1140,20 @@ impl TweezerMutableDeviceWrapper {
/// gate_time (float): The the gate time for the given gate.
/// layout_name (Optional[str]): The name of the Layout to apply the gate time in.
/// Defaults to the current Layout.
///
/// Raises:
/// ValueError: No layout name provided and no current layout set.
#[pyo3(text_signature = "(hqslang, tweezers, gate_time, layout_name, /)")]
pub fn set_tweezer_multi_qubit_gate_time(
&mut self,
hqslang: &str,
tweezers: Vec<usize>,
gate_time: f64,
layout_name: Option<String>,
) {
) -> PyResult<()> {
self.internal
.set_tweezer_multi_qubit_gate_time(hqslang, &tweezers, gate_time, layout_name)
.map_err(|err| PyValueError::new_err(format!("{:}", err)))
}

/// Set the allowed Tweezer shifts of a specified Tweezer.
Expand Down
Loading

0 comments on commit 18c532a

Please sign in to comment.