Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[surface code] PhysicalCostModel #1185

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion qualtran/surface_code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
iter_ccz2t_factories,
iter_simple_data_blocks,
)
from .reference import Reference
from .physical_cost_model import PhysicalCostModel
39 changes: 16 additions & 23 deletions qualtran/surface_code/gidney_fowler_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
import math
from typing import Callable, cast, Iterable, Iterator, Optional, Tuple, TYPE_CHECKING

from .algorithm_summary import AlgorithmSummary
from .ccz2t_factory import CCZ2TFactory
from .data_block import DataBlock, SimpleDataBlock
from .magic_state_factory import MagicStateFactory
from .multi_factory import MultiFactory
from .physical_cost_model import PhysicalCostModel
from .physical_cost_summary import PhysicalCostsSummary
from .physical_parameters import PhysicalParameters
from .qec_scheme import QECScheme

if TYPE_CHECKING:
from qualtran.resource_counting import GateCounts
Expand All @@ -38,6 +42,9 @@ def get_ccz2t_costs(

Note that this function can return failure probabilities larger than 1.

This function exists for backwards-compatibility. Consider constructing a `PhysicalCostModel`
directly.

Args:
n_logical_gates: The number of algorithm logical gates.
n_algo_qubits: Number of algorithm logical qubits.
Expand All @@ -46,32 +53,18 @@ def get_ccz2t_costs(
factory: magic state factory configuration. Used to evaluate distillation error and cost.
data_block: data block configuration. Used to evaluate data error and footprint.
"""
from qualtran.surface_code import LogicalErrorModel, QECScheme

err_model = LogicalErrorModel(
qec_scheme=QECScheme.make_gidney_fowler(), physical_error=phys_err
)
distillation_error = factory.factory_error(
n_logical_gates=n_logical_gates, logical_error_model=err_model
)
n_generation_cycles = factory.n_cycles(
n_logical_gates=n_logical_gates, logical_error_model=err_model
)
n_consumption_cycles = data_block.n_cycles(
n_logical_gates=n_logical_gates, logical_error_model=err_model
)
n_cycles = max(n_generation_cycles, n_consumption_cycles)
data_error = data_block.data_error(
n_algo_qubits=n_algo_qubits, n_cycles=int(n_cycles), logical_error_model=err_model
)
failure_prob = distillation_error + data_error
footprint = factory.n_physical_qubits() + data_block.n_physical_qubits(
n_algo_qubits=n_algo_qubits
model = PhysicalCostModel(
physical_params=PhysicalParameters(physical_error=phys_err, cycle_time_us=cycle_time_us),
data_block=data_block,
factory=factory,
qec_scheme=QECScheme.make_gidney_fowler(),
)
duration_hr = (cycle_time_us * n_cycles) / (1_000_000 * 60 * 60)

algo = AlgorithmSummary(n_algo_qubits=n_algo_qubits, n_logical_gates=n_logical_gates)
return PhysicalCostsSummary(
failure_prob=failure_prob, footprint=footprint, duration_hr=duration_hr
failure_prob=model.error(algo),
footprint=model.n_phys_qubits(algo),
duration_hr=model.duration_hr(algo),
)


Expand Down
46 changes: 0 additions & 46 deletions qualtran/surface_code/magic_count.py

This file was deleted.

Loading
Loading