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

feat: expand box types and match order #15

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
56 changes: 54 additions & 2 deletions src/circuit_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,31 @@ pub enum OpBox {
id: BoxID,
/// List of Pauli operators.
paulis: Vec<String>,
/// Symengine expression
/// Symengine expression.
phase: String,
/// Config param for decomposition of Pauli exponentials.
#[serde(default)]
cx_config: String,
},
/// Operation defined as a pair of exponential of a tensor of Pauli operators.
PauliExpPairBox {
id: BoxID,
/// List of List of Pauli operators.
paulis: Vec<Vec<String>>,
/// List of Symengine expressions.
phase: Vec<String>,
/// Config param for decomposition of Pauli exponentials.
cx_config: String,
},
/// Operation defined as a set of commuting exponentials of a tensor of Pauli operators.
PauliExpCommutingSetBox {
id: BoxID,
/// List of List of Pauli operators.
paulis: Vec<(Vec<String>, String)>,
/// List of Symengine expressions.
pauli_gadgets: Vec<(Vec<String>, String)>,
/// Config param for decomposition of Pauli exponentials.
cx_config: String,
},
/// An operation capable of representing arbitrary Circuits made up of CNOT
/// and RZ, as a PhasePolynomial plus a boolean matrix representing an
Expand All @@ -112,16 +135,19 @@ pub enum OpBox {
id: BoxID,
/// Number of qubits.
n_qubits: u32,
qubit_indices: Vec<(u32, u32)>,
qubit_indices: Vec<(Register, u32)>,
},
/// A user-defined assertion specified by a list of Pauli stabilisers.
StabiliserAssertionBox {
id: BoxID,
stabilisers: Vec<PauliStabiliser>,
},
/// A user-defined assertion specified by a 2x2, 4x4, or 8x8 projector matrix.
ProjectorAssertionBox {
id: BoxID,
matrix: Vec<Vec<(f32, f32)>>,
},
/// A user-defined gate defined by a parametrized Circuit.
Composite {
id: BoxID,
gate: CompositeGate,
Expand All @@ -135,6 +161,9 @@ pub enum OpBox {
n_controls: u32,
/// The operation to be controlled.
op: Box<Operation>,
/// The state of the control.
#[serde(default)]
control_state: u32,
},
/// Holding box for abstract expressions on Bits.
ClassicalExpBox {
Expand All @@ -144,6 +173,29 @@ pub enum OpBox {
n_o: u32,
exp: ClassicalExp,
},
/// A user-defined multiplexor specified by a map from bitstrings to Operations.
MultiplexorBox {
id: BoxID,
op_map: Vec<(Vec<bool>, Operation)>,
},
/// A user-defined multiplexed rotation gate specified by a map from
/// bitstrings to Operations.
MultiplexedRotationBox {
id: BoxID,
op_map: Vec<(Vec<bool>, Operation)>,
},
/// A user-defined multiplexed rotation gate specified by a map from
/// bitstrings to Operations.
MultiplexedU2Box {
id: BoxID,
op_map: Vec<(Vec<bool>, Operation)>,
#[serde(default = "default_impl_diag")]
impl_diag: bool,
},
}

fn default_impl_diag() -> bool {
johnchildren marked this conversation as resolved.
Show resolved Hide resolved
true
}

/// Decorates another op, adding a QASM-style classical condition.
Expand Down
39 changes: 27 additions & 12 deletions src/optype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,32 +373,47 @@ pub enum OpType {
/// See \ref PauliExpBox
PauliExpBox,

/// See \ref PauliExpPairBox
PauliExpPairBox,

/// See \ref PauliExpCommutingSetBox
PauliExpCommutingSetBox,

/// NYI
CliffBox,

/// See \ref CustomGate
CustomGate,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell CustomGate is the same as Composite I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

50788ab Fixed here


/// See \ref PhasePolyBox
PhasePolyBox,

/// NYI
Conditional,

/// See \ref StabiliserAssertionBox
StabiliserAssertionBox,

/// See \ref ProjectorAssertionBox
ProjectorAssertionBox,

/// See \ref CustomGate
CustomGate,

/// See \ref QControlBox
QControlBox,

/// NYI
UnitaryTableauBox,

/// See \ref ClassicalExpBox
ClassicalExpBox,

/// See \ref Conditional
Conditional,
/// See \ref MultiplexorBox
MultiplexorBox,

/// See \ref ProjectorAssertionBox
ProjectorAssertionBox,

/// See \ref StabiliserAssertionBox
StabiliserAssertionBox,
/// See \ref MultiplexedRotationBox
MultiplexedRotationBox,

/// See \ref UnitaryTableauBox
UnitaryTableauBox,
/// See \ref MultiplexedU2Box
MultiplexedU2Box,
}

#[cfg(feature = "pyo3")]
Expand Down