diff --git a/source/qdk_package/qdk/qre/models/qubits/_msft.py b/source/qdk_package/qdk/qre/models/qubits/_msft.py index 1d74300e3e..0266f5484d 100644 --- a/source/qdk_package/qdk/qre/models/qubits/_msft.py +++ b/source/qdk_package/qdk/qre/models/qubits/_msft.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. from dataclasses import KW_ONLY, dataclass, field +from typing import cast, Optional from ..._architecture import Architecture, ISAContext from ...instruction_ids import ( @@ -20,15 +21,22 @@ class Majorana(Architecture): """ This class models physical instructions that may be relevant for future - Majorana qubits. For these qubits, we assume that measurements - and the physical T gate each take 1 µs. Owing to topological protection in - the hardware, we assume single and two-qubit measurement error rates - (Clifford error rates) in $10^{-4}$, $10^{-5}$, and $10^{-6}$ as a range - between realistic and optimistic targets. Non-Clifford operations in this + Majorana qubits. For these qubits, we assume that measurements and the + physical T gate each take 1 µs. Owing to topological protection in the + hardware, we assume single and two-qubit measurement error rates (Clifford + error rates) in $10^{-4}$, $10^{-5}$, and $10^{-6}$ as a range between + realistic and optimistic targets. Non-Clifford operations in this architecture do not have topological protection, so we assume a 5%, 1.5%, and 1% error rate for non-Clifford physical T gates for the three cases, respectively. + Attributes: + error_rate: The error rate for physical Clifford operations (state + preparation and measurement). Defaults to 1e-5, with a domain of + [1e-4, 1e-5, 1e-6] for use in design space exploration. + time: The time (in ns) for physical Clifford operations and the T gate. + Defaults to 1000 ns (1 µs). + References: - Torsten Karzig, Christina Knapp, Roman M. Lutchyn, Parsa Bonderson, @@ -46,25 +54,37 @@ class Majorana(Architecture): _: KW_ONLY error_rate: float = field(default=1e-5, metadata={"domain": [1e-4, 1e-5, 1e-6]}) + time: int = 1_000 + t_error_rate: Optional[float] = None - def provided_isa(self, ctx: ISAContext) -> ISA: - if abs(self.error_rate - 1e-4) <= 1e-8: - t_error_rate = 0.05 - elif abs(self.error_rate - 1e-5) <= 1e-8: - t_error_rate = 0.015 - elif abs(self.error_rate - 1e-6) <= 1e-8: - t_error_rate = 0.01 + def __post_init__(self) -> None: + if self.t_error_rate is None: + if abs(self.error_rate - 1e-4) <= 1e-8: + self.t_error_rate = 0.05 + elif abs(self.error_rate - 1e-5) <= 1e-8: + self.t_error_rate = 0.015 + elif abs(self.error_rate - 1e-6) <= 1e-8: + self.t_error_rate = 0.01 + else: + raise ValueError( + "Invalid error_rate value. Must be one of [1e-4, 1e-5, 1e-6]." + ) + def provided_isa(self, ctx: ISAContext) -> ISA: return ctx.make_isa( - ctx.add_instruction(PREP_X, time=1000, error_rate=self.error_rate), - ctx.add_instruction(PREP_Z, time=1000, error_rate=self.error_rate), + ctx.add_instruction(PREP_X, time=self.time, error_rate=self.error_rate), + ctx.add_instruction(PREP_Z, time=self.time, error_rate=self.error_rate), + ctx.add_instruction( + MEAS_XX, arity=2, time=self.time, error_rate=self.error_rate + ), ctx.add_instruction( - MEAS_XX, arity=2, time=1000, error_rate=self.error_rate + MEAS_ZZ, arity=2, time=self.time, error_rate=self.error_rate ), + ctx.add_instruction(MEAS_X, time=self.time, error_rate=self.error_rate), + ctx.add_instruction(MEAS_Z, time=self.time, error_rate=self.error_rate), + # NOTE From __post_init__, t_error_rate is guaranteed to be non-None + # if error_rate is valid, so we can safely cast it to float here. ctx.add_instruction( - MEAS_ZZ, arity=2, time=1000, error_rate=self.error_rate + T, time=self.time, error_rate=cast(float, self.t_error_rate) ), - ctx.add_instruction(MEAS_X, time=1000, error_rate=self.error_rate), - ctx.add_instruction(MEAS_Z, time=1000, error_rate=self.error_rate), - ctx.add_instruction(T, time=1000, error_rate=t_error_rate), ) diff --git a/source/qdk_package/qdk/qre/models/qubits/_neutral_atoms.py b/source/qdk_package/qdk/qre/models/qubits/_neutral_atoms.py index db60ce216e..706694ae98 100644 --- a/source/qdk_package/qdk/qre/models/qubits/_neutral_atoms.py +++ b/source/qdk_package/qdk/qre/models/qubits/_neutral_atoms.py @@ -121,7 +121,11 @@ def provided_isa(self, ctx: ISAContext) -> ISA: T, encoding=Encoding.PHYSICAL, arity=1, - time=0, + # NOTE: We assume a time of 0, however, some transforms may use + # the time in arithmetic expressions, which require its value to + # be non-zero. Setting it to 1 leads to no or at most + # negligible contributions to the overall resource estimates. + time=1, error_rate=0.00001, ), ctx.add_instruction( diff --git a/source/qdk_package/qdk/qre/property_keys.pyi b/source/qdk_package/qdk/qre/property_keys.pyi index ae1f8f32ea..e9df7d84a4 100644 --- a/source/qdk_package/qdk/qre/property_keys.pyi +++ b/source/qdk_package/qdk/qre/property_keys.pyi @@ -5,8 +5,6 @@ DISTANCE: int SURFACE_CODE_ONE_QUBIT_TIME_FACTOR: int SURFACE_CODE_TWO_QUBIT_TIME_FACTOR: int ACCELERATION: int -ATOM_SPACING: int -VELOCITY: int NUM_TS_PER_ROTATION: int EXPECTED_SHOTS: int RUNTIME_SINGLE_SHOT: int @@ -23,6 +21,9 @@ NAME: int LOSS: int LOGICAL_CYCLE_TIME: int CODE_CYCLE_TIME: int +ATOM_SPACING: int +VELOCITY: int ASSUMPTIONS: int FEASIBILITY: int TARGET_YEAR: int +BLOCK_SIZE: int diff --git a/source/qdk_package/src/qre.rs b/source/qdk_package/src/qre.rs index 64b4ad743e..170c539de0 100644 --- a/source/qdk_package/src/qre.rs +++ b/source/qdk_package/src/qre.rs @@ -1623,8 +1623,6 @@ fn add_property_keys(m: &Bound<'_, PyModule>) -> PyResult<()> { SURFACE_CODE_ONE_QUBIT_TIME_FACTOR, SURFACE_CODE_TWO_QUBIT_TIME_FACTOR, ACCELERATION, - ATOM_SPACING, - VELOCITY, NUM_TS_PER_ROTATION, EXPECTED_SHOTS, RUNTIME_SINGLE_SHOT, @@ -1641,9 +1639,12 @@ fn add_property_keys(m: &Bound<'_, PyModule>) -> PyResult<()> { LOSS, LOGICAL_CYCLE_TIME, CODE_CYCLE_TIME, + ATOM_SPACING, + VELOCITY, ASSUMPTIONS, FEASIBILITY, TARGET_YEAR, + BLOCK_SIZE, ); m.add_submodule(&property_keys)?; diff --git a/source/qre/src/isa/property_keys.rs b/source/qre/src/isa/property_keys.rs index 98b5bde15a..5c9fb56e95 100644 --- a/source/qre/src/isa/property_keys.rs +++ b/source/qre/src/isa/property_keys.rs @@ -50,8 +50,6 @@ define_properties! { SURFACE_CODE_ONE_QUBIT_TIME_FACTOR, SURFACE_CODE_TWO_QUBIT_TIME_FACTOR, ACCELERATION, - ATOM_SPACING, - VELOCITY, NUM_TS_PER_ROTATION, RUNTIME_SINGLE_SHOT, EXPECTED_SHOTS, @@ -68,7 +66,10 @@ define_properties! { LOSS, LOGICAL_CYCLE_TIME, CODE_CYCLE_TIME, + ATOM_SPACING, + VELOCITY, ASSUMPTIONS, FEASIBILITY, TARGET_YEAR, + BLOCK_SIZE, }