Skip to content

Commit

Permalink
override FastDataBlock.n_logical_qubits (#896)
Browse files Browse the repository at this point in the history
* override FastDataBlock.n_logical_qubits

* lint

---------

Co-authored-by: Matthew Harrigan <mpharrigan@google.com>
  • Loading branch information
NoureldinYosri and mpharrigan authored Apr 26, 2024
1 parent 4b16d77 commit 41c9cc5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 10 additions & 4 deletions qualtran/surface_code/data_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ def footprint(self, n_algo_qubits: int) -> int:

def data_error(self, n_algo_qubits: int, n_cycles: int, phys_err: float) -> float:
"""The error associated with storing data on `n_algo_qubits` for `n_cycles`."""
data_cells = self.n_logical_qubits(n_algo_qubits) * n_cycles
return data_cells * self.qec_scheme.logical_error_rate(
# spacetime_volue = number of data cells x number of cycles they will live for.
spacetime_volume = self.n_logical_qubits(n_algo_qubits) * n_cycles
return spacetime_volume * self.qec_scheme.logical_error_rate(
physical_error_rate=phys_err, code_distance=self.data_d
)

Expand Down Expand Up @@ -177,11 +178,16 @@ def footprint(self, n_algo_qubits: int) -> int:
return FastDataBlock.grid_size(n_algo_qubits)

def data_error(self, n_algo_qubits: int, n_cycles: int, phys_err: float) -> float:
data_cells = self.n_logical_qubits(n_algo_qubits) * n_cycles
return data_cells * self.qec_scheme.logical_error_rate(
"""The error associated with storing data on `n_algo_qubits` for `n_cycles`."""
# spacetime_volue = number of data cells x number of cycles they will live for.
spacetime_volume = self.n_logical_qubits(n_algo_qubits) * n_cycles
return spacetime_volume * self.qec_scheme.logical_error_rate(
physical_error_rate=phys_err, code_distance=self.data_d
)

def n_logical_qubits(self, n_algo_qubits: int) -> int:
return FastDataBlock.grid_size(n_algo_qubits)

def n_cycles_to_consume_a_magic_state(self) -> int:
return self.data_d

Expand Down
8 changes: 6 additions & 2 deletions qualtran/surface_code/data_block_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@


@pytest.mark.parametrize(
["logical_qubits", "logical_qubits_with_routing"], [[100, 230], [1318, 2740], [12581, 25481]]
["logical_qubits", "logical_qubits_with_routing", "data_error"],
[[100, 230, 0.69], [1318, 2740, 8.22], [12581, 25481, 76.443]],
)
def test_fast_block(logical_qubits, logical_qubits_with_routing):
def test_fast_block(logical_qubits, logical_qubits_with_routing, data_error):
assert FastDataBlock.grid_size(n_algo_qubits=logical_qubits) == logical_qubits_with_routing
assert FastDataBlock(3).data_error(
n_algo_qubits=logical_qubits, n_cycles=3, phys_err=1e-3
) == pytest.approx(data_error)

0 comments on commit 41c9cc5

Please sign in to comment.