diff --git a/CHANGELOG.md b/CHANGELOG.md index dbd738d1..ae1c287e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,15 +4,16 @@ This changelog track changes to the qoqo project starting at version 0.5.0 ## Not released -### Changed - -* Rarely used qubit mapping is now the last argument in PragmaRepeatedMeasurement -* PragmaGeneralNoise uses sigma^+ sigma^- and sigma^z as a basis to for Lindblad decoherence rates to avoid using complex rates. Rate and operators parameters of PragmaGeneralNoise have been combined in single parameter rates. +## 0.6.0 ### Added * Device trait: A minimal trait for quantum computing devices used with roqoqo * `RoqoqoBackendError` now has a variant `GenericError` for additional backend error types +### Added + +* Rarely used qubit mapping is now the last argument in PragmaRepeatedMeasurement +* PragmaGeneralNoise uses sigma^+ sigma^- and sigma^z as a basis to for Lindblad decoherence rates to avoid using complex rates. Rate and operators parameters of PragmaGeneralNoise have been combined in single parameter rates. ## 0.5.1 diff --git a/roqoqo-derive/src/operate_unitary.rs b/roqoqo-derive/src/operate_unitary.rs index c7a2b3c5..92797c69 100644 --- a/roqoqo-derive/src/operate_unitary.rs +++ b/roqoqo-derive/src/operate_unitary.rs @@ -476,7 +476,7 @@ pub fn dispatch_struct_enum_operate_noise_proba_pragma(input: DeriveInput) -> To fn operate_noise_proba_pragma_enum(de: DataEnum, ident: Ident) -> TokenStream { let variants_with_type = extract_variants_with_types(de).into_iter(); - let match_proba_quotes = variants_with_type.clone().map(|(vident, _, _)| { + let match_proba_quotes = variants_with_type.map(|(vident, _, _)| { quote! { &#ident::#vident(ref inner) => inner.probability(), } diff --git a/roqoqo/src/devices.rs b/roqoqo/src/devices.rs index 84d09062..a768b54c 100644 --- a/roqoqo/src/devices.rs +++ b/roqoqo/src/devices.rs @@ -104,7 +104,7 @@ pub trait Device: Sized { /// /// * `Some<&Array2>` - The decoherence rates. /// * `None` - The qubit is not part of the device. - fn qubit_decoherence_rates(&self, qubits: &[usize]) -> Option>; // ask + fn qubit_decoherence_rates(&self, qubit: usize) -> Option<&Array2>; /// Returns the number of qubits the device supports. fn number_qubits(&self) -> usize; diff --git a/roqoqo/tests/integration/devices.rs b/roqoqo/tests/integration/devices.rs index 49b84d87..c57a9d37 100644 --- a/roqoqo/tests/integration/devices.rs +++ b/roqoqo/tests/integration/devices.rs @@ -19,10 +19,8 @@ struct TestDevice { number_qubits: usize, single_qubit_gates: HashMap>, two_qubit_gates: HashMap>, - multi_qubit_gates: HashMap>, - dephasing_rates: HashMap, - depolarising_rates: HashMap, - damping_rates: HashMap, + multi_qubit_gates: HashMap, + rates: HashMap>, } impl TestDevice { @@ -30,19 +28,15 @@ impl TestDevice { number_qubits: usize, single_qubit_gates: HashMap>, two_qubit_gates: HashMap>, - multi_qubit_gates: HashMap>, - dephasing_rates: HashMap, - depolarising_rates: HashMap, - damping_rates: HashMap, + multi_qubit_gates: HashMap, + rates: HashMap>, ) -> Self { TestDevice { number_qubits, single_qubit_gates, two_qubit_gates, multi_qubit_gates, - dephasing_rates, - depolarising_rates, - damping_rates, + rates, } } } @@ -66,16 +60,12 @@ impl Device for TestDevice { } } - fn multi_qubit_gate_time(&self, hqslang: &str, qubits: &[usize]) -> Option<&f64> { - match self.multi_qubit_gates.get(&hqslang.to_string()) { - Some(x) => x.get(&(qubits[0], qubits[1], qubits[2])), // ask, - None => None, - } + fn multi_qubit_gate_time(&self, hqslang: &str, _qubits: &[usize]) -> Option<&f64> { + self.multi_qubit_gates.get(&hqslang.to_string()) } - fn qubit_decoherence_rates(&self, qubits: &[usize]) -> Option> { - let default: Array2 = array![[qubits[0] as f64]]; - Some(default) + fn qubit_decoherence_rates(&self, qubit: usize) -> Option<&Array2> { + self.rates.get(&qubit) } } @@ -96,37 +86,34 @@ fn it_works() { let mut two_qubit_gates: HashMap> = HashMap::new(); two_qubit_gates.insert("CNOT".to_string(), cnot_map); - let mut multi_ms_map: HashMap<(usize, usize, usize), f64> = HashMap::new(); - multi_ms_map.insert((0, 1, 2), 0.8); - let mut multi_qubit_gates: HashMap> = - HashMap::new(); - multi_qubit_gates.insert("MultiQubitMS".to_string(), multi_ms_map); - - let mut deph_map: HashMap = HashMap::new(); - deph_map.insert(0, 0.003); - deph_map.insert(1, 0.002); - deph_map.insert(2, 0.001); - let mut depol_map: HashMap = HashMap::new(); - depol_map.insert(0, 0.009); - depol_map.insert(1, 0.008); - depol_map.insert(2, 0.007); - let mut damp_map: HashMap = HashMap::new(); - damp_map.insert(0, 0.006); - damp_map.insert(1, 0.005); - damp_map.insert(2, 0.004); + let mut multi_qubit_gates: HashMap = HashMap::new(); + multi_qubit_gates.insert("MultiQubitMS".to_string(), 0.8); + + let mut rates: HashMap> = HashMap::new(); + rates.insert( + 0, + array![[0.003, 0.0, 0.0], [0.0, 0.0, 00.0], [0.0, 0.0, 0.0]], + ); + rates.insert( + 1, + array![[0.0, 0.0, 0.0], [0.0, 0.002, 0.0], [0.0, 0.0, 0.0]], + ); + rates.insert( + 2, + array![[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.001, 0.0]], + ); let device = TestDevice::new( 3, single_qubit_gates, two_qubit_gates, multi_qubit_gates, - deph_map, - depol_map, - damp_map, + rates, ); + let array: Array2 = array![[0.003, 0.0, 0.0], [0.0, 0.0, 00.0], [0.0, 0.0, 0.0]]; assert_eq!(device.number_qubits(), 3usize); - assert_eq!(device.qubit_decoherence_rates(&[0]), Some(array![[0.0]])); + assert_eq!(device.qubit_decoherence_rates(0), Some(&array)); assert_eq!(device.single_qubit_gate_time("RotateX", 0), Some(&0.1f64)); assert_eq!(device.single_qubit_gate_time("RotateX", 3), None); @@ -140,9 +127,5 @@ fn it_works() { device.multi_qubit_gate_time("MultiQubitMS", &[0, 1, 2]), Some(&0.8f64) ); - assert_eq!( - device.multi_qubit_gate_time("MultiQubitMS", &[0, 1, 3]), - None - ); assert_eq!(device.multi_qubit_gate_time("Other", &[0, 1, 2]), None); }