Skip to content

Commit

Permalink
Test plus state preparation as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
pehamTom committed Jul 2, 2024
1 parent 009fa7f commit 5daf9a2
Showing 1 changed file with 41 additions and 6 deletions.
47 changes: 41 additions & 6 deletions test/python/ft_stateprep/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,25 @@ def non_ft_steane_zero(steane_code: CSSCode) -> QuantumCircuit:


@pytest.fixture()
def ft_steane_circ(steane_code: CSSCode) -> QuantumCircuit:
def non_ft_steane_plus(steane_code: CSSCode) -> QuantumCircuit:
"""Return a non fault-tolerant Steane code state preparation circuit."""
return heuristic_prep_circuit(steane_code, zero_state=False).circ


@pytest.fixture()
def ft_steane_zero(steane_code: CSSCode) -> QuantumCircuit:
"""Return a fault-tolerant Steane code state preparation circuit."""
circ = heuristic_prep_circuit(steane_code)
return heuristic_verification_circuit(circ)


@pytest.fixture()
def ft_steane_plus(steane_code: CSSCode) -> QuantumCircuit:
"""Return a fault-tolerant Steane code state preparation circuit."""
circ = heuristic_prep_circuit(steane_code, zero_state=False)
return heuristic_verification_circuit(circ)


def test_lut(steane_code: CSSCode) -> None:
"""Test the LutDecoder class."""
assert steane_code.Hx is not None, "Steane code does not have X stabilizers."
Expand Down Expand Up @@ -84,8 +97,8 @@ def test_lut(steane_code: CSSCode) -> None:
assert np.sum(estimate_3) == 0


def test_non_ft_sim(steane_code: CSSCode, non_ft_steane_zero: QuantumCircuit) -> None:
"""Test the simulation of a non fault-tolerant state preparation circuit."""
def test_non_ft_sim_zero(steane_code: CSSCode, non_ft_steane_zero: QuantumCircuit) -> None:
"""Test the simulation of a non fault-tolerant state preparation circuit for the Steane |0>."""
tol = 5e-4
p = 1e-3
lower = 1e-4
Expand All @@ -95,12 +108,34 @@ def test_non_ft_sim(steane_code: CSSCode, non_ft_steane_zero: QuantumCircuit) ->
assert p_l - tol > lower


def test_ft_sim(steane_code: CSSCode, ft_steane_circ: QuantumCircuit) -> None:
"""Test the simulation of a fault-tolerant state preparation circuit."""
def test_ft_sim_zero(steane_code: CSSCode, ft_steane_zero: QuantumCircuit) -> None:
"""Test the simulation of a fault-tolerant state preparation circuit for the Steane |0>."""
tol = 5e-4
p = 1e-3
lower = 1e-4
simulator = NoisyNDFTStatePrepSimulator(ft_steane_zero, steane_code, p=p)
p_l, _, _, _ = simulator.logical_error_rate()

assert p_l - tol < lower


def test_non_ft_sim_plus(steane_code: CSSCode, non_ft_steane_plus: QuantumCircuit) -> None:
"""Test the simulation of a non fault-tolerant state preparation circuit for the Steane |0>."""
tol = 5e-4
p = 1e-3
lower = 1e-4
simulator = NoisyNDFTStatePrepSimulator(non_ft_steane_plus, steane_code, p=p, zero_state=False)
p_l, _, _, _ = simulator.logical_error_rate()

assert p_l - tol > lower


def test_ft_sim_plus(steane_code: CSSCode, ft_steane_plus: QuantumCircuit) -> None:
"""Test the simulation of a fault-tolerant state preparation circuit for the Steane |0>."""
tol = 5e-4
p = 1e-3
lower = 1e-4
simulator = NoisyNDFTStatePrepSimulator(ft_steane_circ, steane_code, p=p)
simulator = NoisyNDFTStatePrepSimulator(ft_steane_plus, steane_code, p=p, zero_state=False)
p_l, _, _, _ = simulator.logical_error_rate()

assert p_l - tol < lower

0 comments on commit 5daf9a2

Please sign in to comment.