Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
33f6f5d
draft steane_qec
perlinm Dec 16, 2024
d34ce75
fix qec_steane_z
perlinm Dec 16, 2024
a837422
factor out permute changes to another PR
perlinm Dec 16, 2024
710b0ff
factor out Steane.m cleanup to another PR
perlinm Dec 16, 2024
2743142
set flag bit correctly
perlinm Dec 16, 2024
566d266
add qec_steane_.*tel templates
perlinm Dec 16, 2024
f39c31b
fix Steane.qec_steane_tel
perlinm Dec 17, 2024
95c6891
permute all qubits for teleportation
perlinm Dec 17, 2024
661cd65
formatting fixes
perlinm Dec 17, 2024
b6c1fb2
formatting fixes
perlinm Dec 17, 2024
548f216
formatting fix
perlinm Dec 17, 2024
e7bbed0
formatting fix
perlinm Dec 17, 2024
e6077e1
no need to permute ancillas
perlinm Dec 17, 2024
622b2d2
minor rearrangement
perlinm Dec 17, 2024
4d665ce
fix teleportation-based QEC
perlinm Dec 17, 2024
b864193
fix typo
perlinm Dec 17, 2024
0e8ae1d
maybe fix classical registers in teleportation-based QEC
perlinm Dec 17, 2024
4c64865
two flag bits for Steane.qec_tel
perlinm Dec 17, 2024
3cee0b9
add warnings
perlinm Dec 17, 2024
b1ab651
rename flag_bit --> flag, in agreement with elsewhere in the repo
perlinm Dec 17, 2024
45ebaf9
minor cleanup
perlinm Dec 17, 2024
70af9a5
minor renaming
perlinm Dec 18, 2024
cc910d7
standardize docstring
perlinm Dec 18, 2024
9a59086
fix If statement
perlinm Dec 20, 2024
0eaffcc
maybe fix Steane QEC and an incorrect type hint
perlinm Dec 21, 2024
cc99d12
fix typo
perlinm Dec 21, 2024
87c739b
fix warning typo
perlinm Dec 25, 2024
ef393bb
Merge branch 'development' into steane-qec
perlinm Jan 2, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(
syndromes: CReg,
raw_syn: CReg,
pf: Bit,
flag: Bit,
flag: CReg,
flags: CReg,
scratch: CReg,
):
Expand Down Expand Up @@ -96,7 +96,7 @@ def __init__(
syndromes: CReg,
raw_syn: CReg,
pf: Bit,
flag: Bit,
flag: CReg,
flags: CReg,
scratch: CReg,
pf_bit_copy: Bit | None = None,
Expand Down
155 changes: 155 additions & 0 deletions python/quantum-pecos/src/pecos/qeclib/steane/steane_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from warnings import warn

from pecos.qeclib.steane.decoders.lookup import (
FlagLookupQASMActiveCorrectionX,
FlagLookupQASMActiveCorrectionZ,
)
from pecos.qeclib.steane.gates_sq import paulis, sqrt_paulis
Expand Down Expand Up @@ -496,6 +497,160 @@ def qec(self, flag: Bit | None = None):
block.extend(If(self.flags != 0).Then(flag.set(1)))
return block

def qec_steane(
self,
aux: Steane,
reject_x: Bit | None = None,
reject_z: Bit | None = None,
flag_x: Bit | None = None,
flag_z: Bit | None = None,
rus_limit: int | None = None,
) -> Block:
"""Run a Steane-type error-correction cycle of this code."""
return Block(
self.qec_steane_x(
aux,
reject=reject_x,
flag=flag_x,
rus_limit=rus_limit,
),
self.qec_steane_z(
aux,
reject=reject_z,
flag=flag_z,
rus_limit=rus_limit,
),
)

def qec_steane_x(
self,
aux: Steane,
reject: Bit | None = None,
flag: Bit | None = None,
rus_limit: int | None = None,
) -> Block:
"""Run a Steane-type error-correction cycle for X errors."""
warn("Using experimental feature: qec_steane_x", stacklevel=2)
block = Block(
aux.px(reject=reject, rus_limit=rus_limit),
self.cx(aux),
aux.mz(),
self.syn_z.set(aux.syn_meas),
self.last_raw_syn_z.set(0),
self.pf_x.set(0),
FlagLookupQASMActiveCorrectionZ(
self.d,
self.syn_z,
self.syn_z,
self.last_raw_syn_z,
self.pf_x,
self.syn_z,
self.syn_z,
self.scratch,
),
)
if flag is not None:
block.extend(If(self.syn_z != 0).Then(flag.set(1)))
return block

def qec_steane_z(
self,
aux: Steane,
reject: Bit | None = None,
flag: Bit | None = None,
rus_limit: int | None = None,
) -> Block:
"""Run a Steane-type error-correction cycle for Z errors."""
warn("Using experimental feature: qec_steane_z", stacklevel=2)
block = Block(
aux.pz(reject=reject, rus_limit=rus_limit),
aux.cx(self),
aux.mx(),
self.syn_x.set(aux.syn_meas),
self.last_raw_syn_x.set(0),
self.pf_z.set(0),
FlagLookupQASMActiveCorrectionX(
self.d,
self.syn_x,
self.syn_x,
self.last_raw_syn_x,
self.pf_z,
self.syn_x,
self.syn_x,
self.scratch,
),
)
if flag is not None:
block.extend(If(self.syn_x != 0).Then(flag.set(1)))
return block

def qec_tel(
self,
aux: Steane,
reject_x: Bit | None = None,
reject_z: Bit | None = None,
flag_x: Bit | None = None,
flag_z: Bit | None = None,
rus_limit: int | None = None,
) -> Block:
"""Run a teleportation-based error correction cycle."""
return Block(
self.qec_tel_x(aux, reject_x, flag_x, rus_limit),
self.qec_tel_z(aux, reject_z, flag_z, rus_limit),
)

def qec_tel_x(
self,
aux: Steane,
reject: Bit | None = None,
flag: Bit | None = None,
rus_limit: int | None = None,
) -> Block:
"""Run a teleportation-based error correction cycle for X errors."""
warn("Using experimental feature: qec_tel_x", stacklevel=2)
block = Block(
# teleport
aux.px(reject=reject, rus_limit=rus_limit),
aux.cx(self),
self.mz(),
If(self.log == 1).Then(aux.x()),
Permute(self.d, aux.d),
# update syndromes and pauli frame
self.last_raw_syn_x.set(0),
self.last_raw_syn_z.set(0),
self.syn_z.set(self.syn_meas),
self.pf_x.set(0),
)
if flag is not None:
block.extend(If(self.syn_meas != 0).Then(flag.set(1)))
return block

def qec_tel_z(
self,
aux: Steane,
reject: Bit | None = None,
flag: Bit | None = None,
rus_limit: int | None = None,
) -> Block:
"""Run a teleportation-based error correction cycle for Z errors."""
warn("Using experimental feature: qec_tel_z", stacklevel=2)
block = Block(
# teleport
aux.pz(reject=reject, rus_limit=rus_limit),
self.cx(aux),
self.mx(),
If(self.log == 1).Then(aux.z()),
Permute(self.d, aux.d),
# update syndromes and pauli frame
self.last_raw_syn_x.set(0),
self.last_raw_syn_z.set(0),
self.syn_x.set(self.syn_meas),
self.pf_z.set(0),
)
if flag is not None:
block.extend(If(self.syn_meas != 0).Then(flag.set(1)))
return block

def permute(self, other: Steane):
"""Permute this code block (including both quantum and classical registers) with another."""
block = Block(
Expand Down
Loading