From 7d0633e0f1204efcbf9ec5920f8a4dcc1adde8e7 Mon Sep 17 00:00:00 2001 From: Hannah McDougall Date: Tue, 6 Aug 2024 12:07:03 +0100 Subject: [PATCH 1/5] updated ToffoliBox permutation type to match tket schema and nexus dataclasses --- src/opbox.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opbox.rs b/src/opbox.rs index 794e5a2..abf211d 100644 --- a/src/opbox.rs +++ b/src/opbox.rs @@ -190,7 +190,7 @@ pub enum OpBox { ToffoliBox { id: BoxID, /// The classical basis state permutation. - permutation: Permutation, + permutation: Vec<(Vec, Vec)>, // Synthesis strategy. See [`ToffoliBoxSynthStrat`]. strat: ToffoliBoxSynthStrat, // The rotation axis of the multiplexors used in the decomposition. Can From 887d1c015f6e3a8f33c38aea2378cd6f22c07468 Mon Sep 17 00:00:00 2001 From: Hannah McDougall Date: Tue, 6 Aug 2024 12:17:24 +0100 Subject: [PATCH 2/5] remove unused import --- src/opbox.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opbox.rs b/src/opbox.rs index abf211d..5dc9b99 100644 --- a/src/opbox.rs +++ b/src/opbox.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use crate::circuit_json::{ - Bitstring, ClassicalExp, CompositeGate, Matrix, Operation, Permutation, Register, SerialCircuit, + Bitstring, ClassicalExp, CompositeGate, Matrix, Operation, Register, SerialCircuit, }; use crate::optype::OpType; use serde::{Deserialize, Serialize}; From df3fad3fcf96c9b52c8be3095654b285e666dc3c Mon Sep 17 00:00:00 2001 From: Hannah McDougall Date: Tue, 6 Aug 2024 12:37:10 +0100 Subject: [PATCH 3/5] differentiate Permutation and ImplicitPermutation structs --- src/circuit_json.rs | 12 +++++++++--- src/opbox.rs | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/circuit_json.rs b/src/circuit_json.rs index 35b48fb..feedf53 100644 --- a/src/circuit_json.rs +++ b/src/circuit_json.rs @@ -180,9 +180,15 @@ pub struct Command

{ pub opgroup: Option, } -/// A permutation of the elements of a register. +/// A classic basis state permutation. +/// Used when defining Toffoli boxes. #[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)] -pub struct Permutation(pub Register, pub Register); +#[serde(transparent)] +pub struct Permutation(Vec<(Vec, Vec)>); + +/// An implicit permutation of the elements of a register. +#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)] +pub struct ImplicitPermutation(pub Register, pub Register); /// Pytket canonical serialized circuit #[derive(Deserialize, Serialize, Clone, Debug, PartialEq)] @@ -199,7 +205,7 @@ pub struct SerialCircuit

{ /// Input bit registers. pub bits: Vec, /// Implicit permutation of the output qubits. - pub implicit_permutation: Vec, + pub implicit_permutation: Vec, } impl

Default for Operation

{ diff --git a/src/opbox.rs b/src/opbox.rs index 5dc9b99..2e058c8 100644 --- a/src/opbox.rs +++ b/src/opbox.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use crate::circuit_json::{ - Bitstring, ClassicalExp, CompositeGate, Matrix, Operation, Register, SerialCircuit, + Bitstring, ClassicalExp, CompositeGate, Matrix, Operation, Permutation, Register, SerialCircuit }; use crate::optype::OpType; use serde::{Deserialize, Serialize}; @@ -190,7 +190,7 @@ pub enum OpBox { ToffoliBox { id: BoxID, /// The classical basis state permutation. - permutation: Vec<(Vec, Vec)>, + permutation: Permutation, // Synthesis strategy. See [`ToffoliBoxSynthStrat`]. strat: ToffoliBoxSynthStrat, // The rotation axis of the multiplexors used in the decomposition. Can From ed12e6e9075914a6397e505afac856f45b49c474 Mon Sep 17 00:00:00 2001 From: Hannah McDougall Date: Tue, 6 Aug 2024 12:40:47 +0100 Subject: [PATCH 4/5] update formatting --- src/opbox.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opbox.rs b/src/opbox.rs index 2e058c8..794e5a2 100644 --- a/src/opbox.rs +++ b/src/opbox.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use crate::circuit_json::{ - Bitstring, ClassicalExp, CompositeGate, Matrix, Operation, Permutation, Register, SerialCircuit + Bitstring, ClassicalExp, CompositeGate, Matrix, Operation, Permutation, Register, SerialCircuit, }; use crate::optype::OpType; use serde::{Deserialize, Serialize}; From d04ac5c0850f73a94d182075c1d8a2d8b38d67b6 Mon Sep 17 00:00:00 2001 From: hannah-mcdougall Date: Tue, 6 Aug 2024 13:45:27 +0100 Subject: [PATCH 5/5] Update src/circuit_json.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Agustín Borgna <121866228+aborgna-q@users.noreply.github.com> --- src/circuit_json.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/circuit_json.rs b/src/circuit_json.rs index feedf53..74111a4 100644 --- a/src/circuit_json.rs +++ b/src/circuit_json.rs @@ -184,7 +184,7 @@ pub struct Command

{ /// Used when defining Toffoli boxes. #[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)] #[serde(transparent)] -pub struct Permutation(Vec<(Vec, Vec)>); +pub struct Permutation(pub Vec<(Vec, Vec)>); /// An implicit permutation of the elements of a register. #[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Hash)]