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

New 3-qubit and 4-qubit Gates #592

Merged
merged 81 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
08bc553
temp commit
mlodi-hqs Sep 13, 2024
af37b26
moved to new file
mlodi-hqs Sep 16, 2024
db4c99e
first tests
mlodi-hqs Sep 16, 2024
8f1df73
mqg test fixes
mlodi-hqs Sep 16, 2024
c09d4a8
prelude OperateFourQubit
mlodi-hqs Sep 16, 2024
d627fe3
four_qubit_gate_op file mod
mlodi-hqs Sep 16, 2024
97005fd
tests mod
mlodi-hqs Sep 16, 2024
13988eb
involv qubits
mlodi-hqs Sep 16, 2024
a6538be
lib OperateFourQubit
mlodi-hqs Sep 16, 2024
960c8c4
substitute control_2
mlodi-hqs Sep 16, 2024
7086eb8
finished testing cccx
mlodi-hqs Sep 16, 2024
2d83b8e
circuits
mlodi-hqs Sep 16, 2024
4b515aa
again circuits
mlodi-hqs Sep 16, 2024
51d9814
tests
mlodi-hqs Sep 16, 2024
2b221d2
operate enum four + three fix
mlodi-hqs Sep 16, 2024
df6c24a
missed build.rs stuff (enum)
mlodi-hqs Sep 16, 2024
21143be
OperateFourQubitGate
mlodi-hqs Sep 16, 2024
7312710
JsonSchema test
mlodi-hqs Sep 16, 2024
9da4934
doctests fix
mlodi-hqs Sep 16, 2024
0f6ac49
newline
mlodi-hqs Sep 16, 2024
88f0e17
feature gate
mlodi-hqs Sep 16, 2024
7e2f4fe
missed qoqo build.rs
mlodi-hqs Sep 16, 2024
92ead25
mod qoqo
mlodi-hqs Sep 16, 2024
85062a0
lib qoqo-macro
mlodi-hqs Sep 16, 2024
790b4f9
interface
mlodi-hqs Sep 16, 2024
20a15af
interface tests
mlodi-hqs Sep 16, 2024
e5c87a1
fmt
mlodi-hqs Sep 16, 2024
5be0a9f
CHANGELOG
mlodi-hqs Sep 16, 2024
6669160
Merge branch 'main' into triple_controlled
mlodi-hqs Oct 1, 2024
057faee
json_schema fix
mlodi-hqs Oct 1, 2024
6a9508b
compat tests
mlodi-hqs Oct 1, 2024
6804170
lock
mlodi-hqs Oct 1, 2024
1104fda
qoqo
mlodi-hqs Oct 1, 2024
3a38500
macros
mlodi-hqs Oct 1, 2024
46dbf46
derive
mlodi-hqs Oct 1, 2024
a13ad5f
test
mlodi-hqs Oct 1, 2024
6869d92
roqoqo
mlodi-hqs Oct 1, 2024
a95aac0
changelog
mlodi-hqs Oct 1, 2024
6e1ed50
build.rs roq
mlodi-hqs Oct 1, 2024
bdd3b94
ops mod roq
mlodi-hqs Oct 1, 2024
3a9bd03
copyright
mlodi-hqs Oct 1, 2024
f1d6a4b
lock
mlodi-hqs Oct 1, 2024
e307d8d
DEP
mlodi-hqs Oct 1, 2024
8cbc032
Merge branch '0_16' into triple_controlled
mlodi-hqs Oct 2, 2024
9f2bb8a
fixed changelog
mlodi-hqs Oct 2, 2024
6826f46
again fix
mlodi-hqs Oct 2, 2024
e254f9d
cswap definitions
mlodi-hqs Oct 7, 2024
d4374f9
cswap tests
mlodi-hqs Oct 7, 2024
eff8109
qoqo-macros new targets-controls
mlodi-hqs Oct 7, 2024
12dbca4
prelude
mlodi-hqs Oct 7, 2024
018031e
OperateThreeQubit new sol
mlodi-hqs Oct 7, 2024
3767519
involvequbits new targets-controls
mlodi-hqs Oct 7, 2024
2fcf18e
again
mlodi-hqs Oct 7, 2024
77f45f0
operate n qubits new targets-controls
mlodi-hqs Oct 7, 2024
e7a30aa
substitute
mlodi-hqs Oct 7, 2024
4695a37
test fix
mlodi-hqs Oct 7, 2024
4df84be
lock
mlodi-hqs Oct 7, 2024
ab8a277
doc fix
mlodi-hqs Oct 7, 2024
32acf28
changelog
mlodi-hqs Oct 7, 2024
2dc3d6f
triplecontrolledphaseshift definitions
mlodi-hqs Oct 7, 2024
d63e3c1
changelog
mlodi-hqs Oct 7, 2024
d4fea6c
triplecontrolledphaseshift tests
mlodi-hqs Oct 7, 2024
9d7b0d7
phase-shifted changelog
mlodi-hqs Oct 8, 2024
c43334e
roq derive sol (to be changed)
mlodi-hqs Oct 8, 2024
10b7ff8
phase-shifted double-controlled definitions
mlodi-hqs Oct 10, 2024
c081c48
phse-shifted double-controlled tests
mlodi-hqs Oct 10, 2024
f7064cb
roq derive incompatibility fix (wip qoqo)
mlodi-hqs Oct 10, 2024
b097a74
better docs
mlodi-hqs Oct 10, 2024
f1d50d5
qoqo compatiiblity issue cswap fix
mlodi-hqs Oct 10, 2024
f4f32f4
fmt
mlodi-hqs Oct 10, 2024
53bce2f
qoqo mod
mlodi-hqs Oct 10, 2024
f1555ff
Merge branch 'main' into triple_controlled
mlodi-hqs Oct 10, 2024
6ad92ec
redundant changlog
mlodi-hqs Oct 10, 2024
416a912
clippy
mlodi-hqs Oct 10, 2024
4b4e220
dereference
mlodi-hqs Oct 10, 2024
bd602bd
pr corrections
mlodi-hqs Oct 16, 2024
d2d1a74
Merge branch 'main' into triple_controlled
mlodi-hqs Oct 16, 2024
3cbe88e
misisng tests
mlodi-hqs Oct 16, 2024
7c2ba70
small derive fixes
mlodi-hqs Oct 17, 2024
bbebe27
no target_0 target_1 reserved fields
mlodi-hqs Oct 17, 2024
6dd5b07
Merge branch 'main' into triple_controlled
mlodi-hqs Oct 17, 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
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

This changelog track changes to the qoqo project starting at version v0.5.0


## 1.16.0

### Fixed in 1.16.0
Expand All @@ -11,7 +10,7 @@ This changelog track changes to the qoqo project starting at version v0.5.0

### Added in 1.16.0

* Added `InvSGate`, `InvTGate`, `SXGate`, `InvSXGate` gates.
* Added `InvSGate`, `InvTGate`, `SXGate`, `InvSXGate`, `TripleControlledPauliX`, `TripleControlledPauliZ`, `TripleControlledPhaseShift`, `ControlledSWAP`, `PhaseShiftedControlledControlledZ`, `PhaseShiftedControlledControlledPhase` gates.

## 1.15.2

Expand Down Expand Up @@ -39,7 +38,7 @@ This changelog track changes to the qoqo project starting at version v0.5.0

### Added in 1.15.0

* Added `SqrtPaulY` and `InvSqrtPauliY` gates.
* Added `SqrtPauliY` and `InvSqrtPauliY` gates.

## 1.14.0

Expand Down
40 changes: 39 additions & 1 deletion qoqo-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ pub fn devicechainenvironmentwrapper(
}

/// Array of field names that are reserved for use with specific traits
const RESERVED_FIELDS: &[&str; 15] = &[
const RESERVED_FIELDS: &[&str; 16] = &[
"qubit",
"control",
"control_0",
"control_1",
"control_2",
"target",
"qubits",
"global_phase",
Expand Down Expand Up @@ -368,6 +369,41 @@ pub fn wrap(
} else {
TokenStream::new()
};
let operate_four_qubit_quote = if attribute_arguments.contains("OperateFourQubit") {
quote! {
/// Returns control_0 qubit of the four-qubit operation
pub fn control_0(&self) -> usize {
self.internal.control_0().clone()
}
/// Returns control_1 qubit of the four-qubit operation
pub fn control_1(&self) -> usize {
self.internal.control_1().clone()
}
/// Returns control_2 qubit of the four-qubit operation
pub fn control_2(&self) -> usize {
self.internal.control_2().clone()
}
/// Returns target qubit of the four-qubit operation
pub fn target(&self) -> usize {
self.internal.target().clone()
}
}
} else {
TokenStream::new()
};
let operate_four_qubit_gate_quote = if attribute_arguments.contains("OperateFourQubitGate") {
quote! {
/// Returns circuit implementing the FourQubitGateOperation
///
/// Returns:
/// Circuit
pub fn circuit(&self) -> CircuitWrapper {
CircuitWrapper { internal: self.internal.circuit().clone() }
}
}
} else {
TokenStream::new()
};
let operate_gate_quote = if attribute_arguments.contains("OperateGate") {
quote! {
/// Return unitary matrix of gate.
Expand Down Expand Up @@ -623,6 +659,8 @@ pub fn wrap(
// #operate_two_qubit_gate_quote
#operate_three_qubit_quote
#operate_three_qubit_gate_quote
#operate_four_qubit_quote
#operate_four_qubit_gate_quote
#operate_multi_qubit_quote
#operate_multi_qubit_gate_quote
#operate_gate_quote
Expand Down
1 change: 1 addition & 0 deletions qoqo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const SOURCE_FILES: &[&str] = &[
"src/operations/pragma_operations.rs",
"src/operations/two_qubit_gate_operations.rs",
"src/operations/three_qubit_gate_operations.rs",
"src/operations/four_qubit_gate_operations.rs",
"src/operations/multi_qubit_gate_operations.rs",
"src/operations/measurement_operations.rs",
"src/operations/define_operations.rs",
Expand Down
81 changes: 81 additions & 0 deletions qoqo/src/operations/four_qubit_gate_operations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright © 2021-2024 HQS Quantum Simulations GmbH. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing permissions and
// limitations under the License.

use num_complex::Complex64;
use numpy::{PyArray2, ToPyArray};

use qoqo_calculator::CalculatorFloat;
use qoqo_calculator_pyo3::{convert_into_calculator_float, CalculatorFloatWrapper};

use crate::CircuitWrapper;

use pyo3::exceptions::{PyRuntimeError, PyValueError};
use pyo3::prelude::*;
use pyo3::types::PySet;

use std::collections::HashMap;

#[cfg(feature = "json_schema")]
use roqoqo::ROQOQO_VERSION;

use roqoqo::operations::*;

use qoqo_macros::*;

#[wrap(
Operate,
OperateFourQubit,
OperateGate,
OperateFourQubitGate,
JsonSchema
)]
/// The triple-controlled PauliX gate.
///
pub struct TripleControlledPauliX {
control_0: usize,
control_1: usize,
control_2: usize,
target: usize,
}

#[wrap(
Operate,
OperateFourQubit,
OperateGate,
OperateFourQubitGate,
JsonSchema
)]
/// The triple-controlled PauliZ gate.
///
pub struct TripleControlledPauliZ {
control_0: usize,
control_1: usize,
control_2: usize,
target: usize,
}

#[wrap(
Operate,
OperateFourQubit,
OperateGate,
OperateFourQubitGate,
JsonSchema
)]
/// The triple-controlled PhaseShift gate.
///
pub struct TripleControlledPhaseShift {
control_0: usize,
control_1: usize,
control_2: usize,
target: usize,
theta: CalculatorFloat,
}
8 changes: 8 additions & 0 deletions qoqo/src/operations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ mod two_qubit_gate_operations;
pub use two_qubit_gate_operations::*;
mod three_qubit_gate_operations;
pub use three_qubit_gate_operations::*;
mod four_qubit_gate_operations;
pub use four_qubit_gate_operations::*;
mod multi_qubit_gate_operations;
pub use multi_qubit_gate_operations::*;
mod bosonic_operations;
Expand Down Expand Up @@ -190,6 +192,12 @@ pub fn operations(_py: Python, m: &Bound<PyModule>) -> PyResult<()> {
m.add_class::<InvTGateWrapper>()?;
m.add_class::<SXGateWrapper>()?;
m.add_class::<InvSXGateWrapper>()?;
m.add_class::<TripleControlledPauliXWrapper>()?;
m.add_class::<TripleControlledPauliZWrapper>()?;
m.add_class::<TripleControlledPhaseShiftWrapper>()?;
m.add_class::<ControlledSWAPWrapper>()?;
m.add_class::<PhaseShiftedControlledControlledZWrapper>()?;
m.add_class::<PhaseShiftedControlledControlledPhaseWrapper>()?;

Ok(())
}
Loading
Loading