Source code for surface_sim.log_gates.small_stellated_dodecahedron_code

from ..layouts.layout import Layout

__all__ = [
    "set_idle",
    "set_fold_trans_s",
    "set_fold_trans_h",
    "set_fold_trans_swap_r",
    "set_fold_trans_swap_s",
    "set_fold_trans_swap_a",
    "set_fold_trans_swap_b",
    "set_fold_trans_swap_c",
]


[docs] def set_idle(layout: Layout) -> None: """Adds the required attributes (in place) for the layout to run the Pauli I gate for the small stellated dodecahedron code. Parameters ---------- layout The layout in which to add the attributes. """ if layout.code != "small_stellated_dodecahedron_code": raise ValueError( "This function is for small stellated dodecahedron codes, " f"but a layout for the code {layout.code} was given." ) data_qubits = layout.data_qubits anc_qubits = layout.anc_qubits gate_label = "idle" # Store logical gate information to the data qubits for qubit in data_qubits: layout.set_param(gate_label, qubit, {"local": "I"}) # Store new stabilizer generators to the ancilla qubits for anc_qubit in anc_qubits: layout.set_param( gate_label, anc_qubit, {"new_stab_gen": [anc_qubit], "new_stab_gen_inv": [anc_qubit]}, ) return
[docs] def set_fold_trans_h(layout: Layout) -> None: """Adds the required attributes (in place) for the layout to run the H-like gate (:math:`H_{\\tau_0}`) described in N. P. Breuckmann and S. Burton, "Fold-Transversal Clifford Gates for Quantum Codes", Quantum 8, 1372 (2024) arXiv:2202.06647 Parameters ---------- layout The layout in which to add the attributes. Notes ----- This functions sets the H-like gate for the SSD code generated by ``surface_sim.layouts.library.small_stellated_dodecahedron_code.ssd_code``. It uses the specific definitions of the stabilizers and logicals. """ if layout.code != "small_stellated_dodecahedron_code": raise ValueError( "This function is for small stellated dodecahedron codes, " f"but a layout for the code {layout.code} was given." ) data_qubits = layout.data_qubits anc_qubits = layout.anc_qubits gate_label = "log_fold_trans_h" # this dictionaries have been precomputed swap_pairs = { "D1": "D12", "D2": None, "D3": "D8", "D4": "D16", "D5": None, "D6": "D26", "D7": None, "D8": "D3", "D9": "D28", "D10": "D17", "D11": "D25", "D12": "D1", "D13": "D15", "D14": "D22", "D15": "D13", "D16": "D4", "D17": "D10", "D18": None, "D19": "D27", "D20": "D30", "D21": "D29", "D22": "D14", "D23": None, "D24": None, "D25": "D11", "D26": "D6", "D27": "D19", "D28": "D9", "D29": "D21", "D30": "D20", } map_stabs_H = { "X1": {"Z11"}, "X2": {"Z4"}, "X3": {"Z8"}, "X4": {"Z10"}, "X5": {"Z3"}, "X6": {"Z5"}, "X7": {"Z2"}, "X8": {"Z6"}, "X9": {"Z12"}, "X10": {"Z7"}, "X11": {"Z9"}, "X12": {"Z1"}, "Z1": {"X12"}, "Z2": {"X7"}, "Z3": {"X5"}, "Z4": {"X2"}, "Z5": {"X6"}, "Z6": {"X8"}, "Z7": {"X10"}, "Z8": {"X3"}, "Z9": {"X11"}, "Z10": {"X4"}, "Z11": {"X1"}, "Z12": {"X9"}, } # Store logical gate information to the data qubits for qubit in data_qubits: layout.set_param(gate_label, qubit, {"local": "H", "swap": swap_pairs[qubit]}) # Store new stabilizer generators to the ancilla qubits for anc_qubit in anc_qubits: layout.set_param( gate_label, anc_qubit, { "new_stab_gen": list(map_stabs_H[anc_qubit]), "new_stab_gen_inv": list(map_stabs_H[anc_qubit]), }, ) return
[docs] def set_fold_trans_s(layout: Layout) -> None: """Adds the required attributes (in place) for the layout to run the S-like gate (:math:`S_{\\tau_0}`) described in N. P. Breuckmann and S. Burton, "Fold-Transversal Clifford Gates for Quantum Codes", Quantum 8, 1372 (2024) arXiv:2202.06647 Parameters ---------- layout The layout in which to add the attributes. Notes ----- This functions sets the S-like gate for the SSD code generated by ``surface_sim.layouts.library.small_stellated_dodecahedron_code.ssd_code``. It uses the specific definitions of the stabilizers and logicals. """ if layout.code != "small_stellated_dodecahedron_code": raise ValueError( "This function is for small stellated dodecahedron codes, " f"but a layout for the code {layout.code} was given." ) data_qubits = layout.data_qubits anc_qubits = layout.anc_qubits gate_label = "log_fold_trans_s" # this dictionaries have been precomputed s_gates = {"D2", "D7", "D24"} s_dag_gates = {"D23", "D5", "D18"} cz_pairs = { "D21": "D29", "D6": "D26", "D22": "D14", "D1": "D12", "D4": "D16", "D20": "D30", "D9": "D28", "D10": "D17", "D19": "D27", "D15": "D13", "D25": "D11", "D3": "D8", "D29": "D21", "D26": "D6", "D14": "D22", "D12": "D1", "D16": "D4", "D30": "D20", "D28": "D9", "D17": "D10", "D27": "D19", "D13": "D15", "D11": "D25", "D8": "D3", } map_stabs_S = { "X1": {"Z11", "X1"}, "X2": {"X2", "Z4"}, "X3": {"X3", "Z8"}, "X4": {"Z10", "X4"}, "X5": {"X5", "Z3"}, "X6": {"Z5", "X6"}, "X7": {"X7", "Z2"}, "X8": {"X8", "Z6"}, "X9": {"X9", "Z12"}, "X10": {"Z7", "X10"}, "X11": {"X11", "Z9"}, "X12": {"X12", "Z1"}, "Z1": {"Z1"}, "Z2": {"Z2"}, "Z3": {"Z3"}, "Z4": {"Z4"}, "Z5": {"Z5"}, "Z6": {"Z6"}, "Z7": {"Z7"}, "Z8": {"Z8"}, "Z9": {"Z9"}, "Z10": {"Z10"}, "Z11": {"Z11"}, "Z12": {"Z12"}, } # Store logical gate information to the data qubits for qubit in data_qubits: gates: dict[str, str | None] = {"local": None, "cz": None} if qubit in s_gates: gates["local"] = "S" if qubit in s_dag_gates: gates["local"] = "S_DAG" if qubit in cz_pairs: gates["cz"] = cz_pairs[qubit] layout.set_param(gate_label, qubit, gates) # Store new stabilizer generators to the ancilla qubits for anc_qubit in anc_qubits: layout.set_param( gate_label, anc_qubit, { "new_stab_gen": list(map_stabs_S[anc_qubit]), "new_stab_gen_inv": list(map_stabs_S[anc_qubit]), }, ) return
[docs] def set_fold_trans_swap_r(layout: Layout) -> None: """Adds the required attributes (in place) for the layout to run one SWAP-like gate (:math:`\\sigma_r`) described in N. P. Breuckmann and S. Burton, "Fold-Transversal Clifford Gates for Quantum Codes", Quantum 8, 1372 (2024) arXiv:2202.06647 Parameters ---------- layout The layout in which to add the attributes. Notes ----- This functions sets a SWAP-like gate for the SSD code generated by ``surface_sim.layouts.library.small_stellated_dodecahedron_code.ssd_code``. It uses the specific definitions of the stabilizers and logicals. """ if layout.code != "small_stellated_dodecahedron_code": raise ValueError( "This function is for small stellated dodecahedron codes, " f"but a layout for the code {layout.code} was given." ) data_qubits = layout.data_qubits anc_qubits = layout.anc_qubits gate_label = "log_fold_trans_swap_r" # this dictionaries have been precomputed swap_pairs_a = { "D1": "D9", "D2": "D8", "D3": "D7", "D4": "D6", "D5": None, "D6": "D4", "D7": "D3", "D8": "D2", "D9": "D1", "D10": "D19", "D11": "D18", "D12": "D16", "D13": "D20", "D14": "D15", "D15": "D14", "D16": "D12", "D17": None, "D18": "D11", "D19": "D10", "D20": "D13", "D21": "D22", "D22": "D21", "D23": "D25", "D24": None, "D25": "D23", "D26": "D28", "D27": None, "D28": "D26", "D29": "D30", "D30": "D29", } swap_pairs_b = { "D1": None, "D2": "D5", "D3": "D4", "D4": "D3", "D5": "D2", "D6": "D19", "D7": "D18", "D8": "D16", "D9": "D20", "D10": "D15", "D11": "D14", "D12": None, "D13": "D17", "D14": "D11", "D15": "D10", "D16": "D8", "D17": "D13", "D18": "D7", "D19": "D6", "D20": "D9", "D21": None, "D22": "D25", "D23": "D24", "D24": "D23", "D25": "D22", "D26": "D27", "D27": "D26", "D28": "D30", "D29": None, "D30": "D28", } map_stabs_sigma_r = { "X1": {"X5"}, "X2": {"X1"}, "X3": {"X2"}, "X4": {"X3"}, "X5": {"X4"}, "X6": {"X10"}, "X7": {"X6"}, "X8": {"X7"}, "X9": {"X8"}, "X10": {"X9"}, "X11": {"X11"}, "X12": {"X12"}, "Z1": {"Z5"}, "Z2": {"Z1"}, "Z3": {"Z2"}, "Z4": {"Z3"}, "Z5": {"Z4"}, "Z6": {"Z10"}, "Z7": {"Z6"}, "Z8": {"Z7"}, "Z9": {"Z8"}, "Z10": {"Z9"}, "Z11": {"Z11"}, "Z12": {"Z12"}, } inv_map_stabs_sigma_r = {list(v)[0]: {k} for k, v in map_stabs_sigma_r.items()} # Store logical gate information to the data qubits for qubit in data_qubits: layout.set_param( gate_label, qubit, {"swap_1": swap_pairs_a[qubit], "swap_2": swap_pairs_b[qubit]}, ) # Store new stabilizer generators to the ancilla qubits for anc_qubit in anc_qubits: layout.set_param( gate_label, anc_qubit, { "new_stab_gen": list(map_stabs_sigma_r[anc_qubit]), "new_stab_gen_inv": list(inv_map_stabs_sigma_r[anc_qubit]), }, ) return
[docs] def set_fold_trans_swap_s(layout: Layout) -> None: """Adds the required attributes (in place) for the layout to run one SWAP-like gate (:math:`\\sigma_s`) described in N. P. Breuckmann and S. Burton, "Fold-Transversal Clifford Gates for Quantum Codes", Quantum 8, 1372 (2024) arXiv:2202.06647 Parameters ---------- layout The layout in which to add the attributes. Notes ----- This functions sets a SWAP-like gate for the SSD code generated by ``surface_sim.layouts.library.small_stellated_dodecahedron_code.ssd_code``. It uses the specific definitions of the stabilizers and logicals. """ if layout.code != "small_stellated_dodecahedron_code": raise ValueError( "This function is for small stellated dodecahedron codes, " f"but a layout for the code {layout.code} was given." ) data_qubits = layout.data_qubits anc_qubits = layout.anc_qubits gate_label = "log_fold_trans_swap_s" # this dictionaries have been precomputed swap_pairs_b = { "D1": None, "D2": "D5", "D3": "D4", "D4": "D3", "D5": "D2", "D6": "D19", "D7": "D18", "D8": "D16", "D9": "D20", "D10": "D15", "D11": "D14", "D12": None, "D13": "D17", "D14": "D11", "D15": "D10", "D16": "D8", "D17": "D13", "D18": "D7", "D19": "D6", "D20": "D9", "D21": None, "D22": "D25", "D23": "D24", "D24": "D23", "D25": "D22", "D26": "D27", "D27": "D26", "D28": "D30", "D29": None, "D30": "D28", } swap_pairs_c = { "D1": "D4", "D2": "D3", "D3": "D2", "D4": "D1", "D5": None, "D6": "D9", "D7": "D8", "D8": "D7", "D9": "D6", "D10": None, "D11": "D23", "D12": "D28", "D13": "D22", "D14": "D29", "D15": "D30", "D16": "D26", "D17": "D27", "D18": "D25", "D19": None, "D20": "D21", "D21": "D20", "D22": "D13", "D23": "D11", "D24": None, "D25": "D18", "D26": "D16", "D27": "D17", "D28": "D12", "D29": "D14", "D30": "D15", } map_stabs_sigma_s = { "X1": {"X1"}, "X2": {"X6"}, "X3": {"X11"}, "X4": {"X8"}, "X5": {"X2"}, "X6": {"X12"}, "X7": {"X5"}, "X8": {"X10"}, "X9": {"X9"}, "X10": {"X3"}, "X11": {"X4"}, "X12": {"X7"}, "Z1": {"Z1"}, "Z2": {"Z6"}, "Z3": {"Z11"}, "Z4": {"Z8"}, "Z5": {"Z2"}, "Z6": {"Z12"}, "Z7": {"Z5"}, "Z8": {"Z10"}, "Z9": {"Z9"}, "Z10": {"Z3"}, "Z11": {"Z4"}, "Z12": {"Z7"}, } inv_map_stabs_sigma_s = {list(v)[0]: {k} for k, v in map_stabs_sigma_s.items()} # Store logical gate information to the data qubits for qubit in data_qubits: layout.set_param( gate_label, qubit, {"swap_1": swap_pairs_b[qubit], "swap_2": swap_pairs_c[qubit]}, ) # Store new stabilizer generators to the ancilla qubits for anc_qubit in anc_qubits: layout.set_param( gate_label, anc_qubit, { "new_stab_gen": list(map_stabs_sigma_s[anc_qubit]), "new_stab_gen_inv": list(inv_map_stabs_sigma_s[anc_qubit]), }, ) return
[docs] def set_fold_trans_swap_a(layout: Layout) -> None: """Adds the required attributes (in place) for the layout to run one SWAP-like gate (:math:`\\sigma_a`) described in N. P. Breuckmann and S. Burton, "Fold-Transversal Clifford Gates for Quantum Codes", Quantum 8, 1372 (2024) arXiv:2202.06647 Parameters ---------- layout The layout in which to add the attributes. Notes ----- This functions sets a SWAP-like gate for the SSD code generated by ``surface_sim.layouts.library.small_stellated_dodecahedron_code.ssd_code``. It uses the specific definitions of the stabilizers and logicals. """ if layout.code != "small_stellated_dodecahedron_code": raise ValueError( "This function is for small stellated dodecahedron codes, " f"but a layout for the code {layout.code} was given." ) data_qubits = layout.data_qubits anc_qubits = layout.anc_qubits gate_label = "log_fold_trans_swap_a" # this dictionaries have been precomputed swap_pairs_a = { "D1": "D9", "D2": "D8", "D3": "D7", "D4": "D6", "D5": None, "D6": "D4", "D7": "D3", "D8": "D2", "D9": "D1", "D10": "D19", "D11": "D18", "D12": "D16", "D13": "D20", "D14": "D15", "D15": "D14", "D16": "D12", "D17": None, "D18": "D11", "D19": "D10", "D20": "D13", "D21": "D22", "D22": "D21", "D23": "D25", "D24": None, "D25": "D23", "D26": "D28", "D27": None, "D28": "D26", "D29": "D30", "D30": "D29", } map_stabs_sigma_a = { "X1": {"X2"}, "X2": {"X1"}, "X3": {"X5"}, "X4": {"X4"}, "X5": {"X3"}, "X6": {"X8"}, "X7": {"X7"}, "X8": {"X6"}, "X9": {"X10"}, "X10": {"X9"}, "X11": {"X11"}, "X12": {"X12"}, "Z1": {"Z2"}, "Z2": {"Z1"}, "Z3": {"Z5"}, "Z4": {"Z4"}, "Z5": {"Z3"}, "Z6": {"Z8"}, "Z7": {"Z7"}, "Z8": {"Z6"}, "Z9": {"Z10"}, "Z10": {"Z9"}, "Z11": {"Z11"}, "Z12": {"Z12"}, } inv_map_stabs_sigma_a = {list(v)[0]: {k} for k, v in map_stabs_sigma_a.items()} # Store logical gate information to the data qubits for qubit in data_qubits: layout.set_param(gate_label, qubit, {"swap": swap_pairs_a[qubit]}) # Store new stabilizer generators to the ancilla qubits for anc_qubit in anc_qubits: layout.set_param( gate_label, anc_qubit, { "new_stab_gen": list(map_stabs_sigma_a[anc_qubit]), "new_stab_gen_inv": list(inv_map_stabs_sigma_a[anc_qubit]), }, ) return
[docs] def set_fold_trans_swap_b(layout: Layout) -> None: """Adds the required attributes (in place) for the layout to run one SWAP-like gate (:math:`\\sigma_b`) described in N. P. Breuckmann and S. Burton, "Fold-Transversal Clifford Gates for Quantum Codes", Quantum 8, 1372 (2024) arXiv:2202.06647 Parameters ---------- layout The layout in which to add the attributes. Notes ----- This functions sets a SWAP-like gate for the SSD code generated by ``surface_sim.layouts.library.small_stellated_dodecahedron_code.ssd_code``. It uses the specific definitions of the stabilizers and logicals. """ if layout.code != "small_stellated_dodecahedron_code": raise ValueError( "This function is for small stellated dodecahedron codes, " f"but a layout for the code {layout.code} was given." ) data_qubits = layout.data_qubits anc_qubits = layout.anc_qubits gate_label = "log_fold_trans_swap_b" # this dictionaries have been precomputed swap_pairs_b = { "D1": None, "D2": "D5", "D3": "D4", "D4": "D3", "D5": "D2", "D6": "D19", "D7": "D18", "D8": "D16", "D9": "D20", "D10": "D15", "D11": "D14", "D12": None, "D13": "D17", "D14": "D11", "D15": "D10", "D16": "D8", "D17": "D13", "D18": "D7", "D19": "D6", "D20": "D9", "D21": None, "D22": "D25", "D23": "D24", "D24": "D23", "D25": "D22", "D26": "D27", "D27": "D26", "D28": "D30", "D29": None, "D30": "D28", } map_stabs_sigma_b = { "X1": {"X1"}, "X2": {"X5"}, "X3": {"X4"}, "X4": {"X3"}, "X5": {"X2"}, "X6": {"X7"}, "X7": {"X6"}, "X8": {"X10"}, "X9": {"X9"}, "X10": {"X8"}, "X11": {"X11"}, "X12": {"X12"}, "Z1": {"Z1"}, "Z2": {"Z5"}, "Z3": {"Z4"}, "Z4": {"Z3"}, "Z5": {"Z2"}, "Z6": {"Z7"}, "Z7": {"Z6"}, "Z8": {"Z10"}, "Z9": {"Z9"}, "Z10": {"Z8"}, "Z11": {"Z11"}, "Z12": {"Z12"}, } inv_map_stabs_sigma_b = {list(v)[0]: {k} for k, v in map_stabs_sigma_b.items()} # Store logical gate information to the data qubits for qubit in data_qubits: layout.set_param(gate_label, qubit, {"swap": swap_pairs_b[qubit]}) # Store new stabilizer generators to the ancilla qubits for anc_qubit in anc_qubits: layout.set_param( gate_label, anc_qubit, { "new_stab_gen": list(map_stabs_sigma_b[anc_qubit]), "new_stab_gen_inv": list(inv_map_stabs_sigma_b[anc_qubit]), }, ) return
[docs] def set_fold_trans_swap_c(layout: Layout) -> None: """Adds the required attributes (in place) for the layout to run one SWAP-like gate (:math:`\\sigma_c`) described in N. P. Breuckmann and S. Burton, "Fold-Transversal Clifford Gates for Quantum Codes", Quantum 8, 1372 (2024) arXiv:2202.06647 Parameters ---------- layout The layout in which to add the attributes. Notes ----- This functions sets a SWAP-like gate for the SSD code generated by ``surface_sim.layouts.library.small_stellated_dodecahedron_code.ssd_code``. It uses the specific definitions of the stabilizers and logicals. """ if layout.code != "small_stellated_dodecahedron_code": raise ValueError( "This function is for small stellated dodecahedron codes, " f"but a layout for the code {layout.code} was given." ) data_qubits = layout.data_qubits anc_qubits = layout.anc_qubits gate_label = "log_fold_trans_swap_c" # this dictionaries have been precomputed swap_pairs_c = { "D1": "D4", "D2": "D3", "D3": "D2", "D4": "D1", "D5": None, "D6": "D9", "D7": "D8", "D8": "D7", "D9": "D6", "D10": None, "D11": "D23", "D12": "D28", "D13": "D22", "D14": "D29", "D15": "D30", "D16": "D26", "D17": "D27", "D18": "D25", "D19": None, "D20": "D21", "D21": "D20", "D22": "D13", "D23": "D11", "D24": None, "D25": "D18", "D26": "D16", "D27": "D17", "D28": "D12", "D29": "D14", "D30": "D15", } map_stabs_sigma_c = { "X1": {"X1"}, "X2": {"X2"}, "X3": {"X8"}, "X4": {"X11"}, "X5": {"X6"}, "X6": {"X5"}, "X7": {"X12"}, "X8": {"X3"}, "X9": {"X9"}, "X10": {"X10"}, "X11": {"X4"}, "X12": {"X7"}, "Z1": {"Z1"}, "Z2": {"Z2"}, "Z3": {"Z8"}, "Z4": {"Z11"}, "Z5": {"Z6"}, "Z6": {"Z5"}, "Z7": {"Z12"}, "Z8": {"Z3"}, "Z9": {"Z9"}, "Z10": {"Z10"}, "Z11": {"Z4"}, "Z12": {"Z7"}, } inv_map_stabs_sigma_c = {list(v)[0]: {k} for k, v in map_stabs_sigma_c.items()} # Store logical gate information to the data qubits for qubit in data_qubits: layout.set_param(gate_label, qubit, {"swap": swap_pairs_c[qubit]}) # Store new stabilizer generators to the ancilla qubits for anc_qubit in anc_qubits: layout.set_param( gate_label, anc_qubit, { "new_stab_gen": list(map_stabs_sigma_c[anc_qubit]), "new_stab_gen_inv": list(inv_map_stabs_sigma_c[anc_qubit]), }, ) return