Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NoureldinYosri committed Dec 9, 2023
1 parent 5e843ee commit 9eaea79
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 47 deletions.
95 changes: 49 additions & 46 deletions qualtran/surface_code/azure_cost_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"metadata": {},
"source": [
"# Azure Cost Model\n",
"In this notebook, we go through the cost model in \"Assessing requirements to scale to practical quantum advantage\" by [Beverland et al](https://arxiv.org/abs/2211.07629) to reproduce the estimated costs in Appendix F."
"In this notebook, we go through the cost model in \"Assessing requirements to scale to practical quantum advantage\" by [Beverland et al](https://arxiv.org/abs/2211.07629) to reproduce the estimated costs in Appendix F.\n",
"\n",
"The paper describes the formulas used for estimating cost in the various appendices. The final estimation procedure is put together in Appendix E. Throughout, we reproduce the costs from the paper; in particular Appendix F."
]
},
{
Expand All @@ -15,10 +17,10 @@
"metadata": {},
"source": [
"The Azure cost model has 5 inputs:\n",
"1. The physical assumptions about the hardware (e.g. error rate, the latency of Clifford and measurement operations, ...etc).\n",
"1. A summary of the circuit/algorithm to execute (e.g. number of T gates, ..etc).\n",
"1. The magic state factory (e.g. number of qubits consumed by it, its error rate, ...etc)\n",
"1. Cost model of Approximating rotations using T operations up to error $\\epsilon$\n",
"1. The physical assumptions about the hardware (e.g. error rate, the latency of Clifford and measurement operations, etc).\n",
"1. A summary of the circuit/algorithm to execute (e.g. number of T gates, etc).\n",
"1. The magic state factory (e.g. number of qubits consumed by it, its error rate, etc).\n",
"1. Cost model of Approximating rotations using T operations up to error $\\epsilon$.\n",
"1. The quantum error correction scheme.\n",
"\n",
"We take a look at each of these and then reproduce the results of Appendix F."
Expand All @@ -32,11 +34,11 @@
"## The Inputs\n",
"### Physical Parameters\n",
"These are assumptions about the quantum hardware and are:\n",
"- `t_gate`: Latency of Clifford gates. \n",
"- `t_meas`: Latency of Measurement operations.\n",
"- `t_gate_us`: Latency time of Clifford gates. \n",
"- `t_meas_us`: Latency time of Measurement operations.\n",
"- `physical_error_rate`: Physical error rate ($p$).\n",
"\n",
"These parameters are used to compute other quantities such as the time for a single stabilizer round. In Qualtran these are represented by the `PhysicalParameters` dataclass."
"In Qualtran these are represented by the `PhysicalParameters` dataclass."
]
},
{
Expand All @@ -45,9 +47,9 @@
"metadata": {},
"outputs": [],
"source": [
"from qualtran.surface_code.physical_parameters import BeverlandEtAl\n",
"from qualtran.surface_code.physical_parameters import BEVERLAND_PARAMS\n",
"\n",
"BeverlandEtAl"
"BEVERLAND_PARAMS"
]
},
{
Expand All @@ -58,10 +60,10 @@
"### Algorithm Summary\n",
"This is a summary of the circuit or algorithm to execute. This summary is several simple counts:\n",
"- `algorithm_qubits` is the number of algorithm qubits.\n",
"- `measurements` is the umber of Clifford measurements ($M_R$).\n",
"- `measurements` is the number of Clifford measurements ($M_R$).\n",
"- `t_gates` is the number of T gates ($M_T$).\n",
"- `toffoli_gates` is the number of Toffoli gates ($M_{Tof}$).\n",
"- `rotation_gates` is the number of Rotations ($M_R$).\n",
"- `rotation_gates` is the number of rotations ($M_R$).\n",
"- `rotation_circuit_depth` is the depth of rotation circuit ($D_R$).\n",
"\n",
"Note: The symbol in parentheses corresponds to the notation in the paper\n",
Expand Down Expand Up @@ -89,7 +91,7 @@
"source": [
"### Magic State Factory\n",
"\n",
"The magic state factory in our case is a T-state factory. The paper describes 15-to-1 factories in Appendix C, but only the overall summary in Table VII in terms of physical qubits count and generation time is used in estimation in Appendix F."
"The magic state factory in our case is a T-state factory. The paper describes 15-to-1 factories in Appendix C, but only the overall summary in Table VII in terms of physical qubit count and generation time is used in estimation in Appendix F."
]
},
{
Expand All @@ -99,14 +101,14 @@
"source": [
"### Rotation Approximation Model\n",
"\n",
"This is a model that approximates the number of T gates needed to implement a rotation up to error $\\epsilon$. [Beverland et al](https://arxiv.org/abs/2211.07629) use the approximation model from [Kliuchnikov et al](https://arxiv.org/abs/2203.10064). The formula for the number of T gates used to approximate an angle up to error $\\epsilon$ is given by:\n",
"This is a model that approximates the number of T gates needed to implement a rotation up to error $\\epsilon$. In the paper they use the approximation model from [Kliuchnikov et al](https://arxiv.org/abs/2203.10064). The formula for the number of T gates used to approximate an angle up to error $\\epsilon$ is given by:\n",
"$$\n",
"a \\log_2{\\frac{1}{\\epsilon}} + b\n",
"$$\n",
"\n",
"Where $a$ and $b$ are constants that depend on the gate set and the approximation protocol. Table 1 of [Kliuchnikov et al](https://arxiv.org/abs/2203.10064) gives estimates for those constants for different combinations of gate sets and protocols.\n",
"\n",
"In [Beverland et al](https://arxiv.org/abs/2211.07629), Although they don't specify the approximation algorithm their constants of $a=0.53, b=5.3$ are closest to the mixed fallback approximation protocol with a Clifford+T gate set constants of $a=0.53, b=4.86$. "
"In the paper, they use $a=0.53, b=5.3$"
]
},
{
Expand All @@ -127,29 +129,29 @@
"source": [
"### Quantum Error Correction Scheme\n",
"The quantum error correction scheme determines three things:\n",
"1. The logical error rate given a code distance and physical error rate $P(d)$.\n",
"1. The number of physical qubits needed per logical qubit $n(d)$.\n",
"1. The number of logical time steps $\\tau(d)$.\n",
"1. The logical error rate given a code distance and physical error rate: $P(d)$.\n",
"1. The number of physical qubits needed per logical qubit: $n(d)$.\n",
"1. The number of logical time steps: $\\tau(d)$.\n",
"\n",
"Tabel V of [Beverland et al](https://arxiv.org/abs/2211.07629) lists how these are computed from the QEC scheme.\n",
"Table V of the paper lists how these are related to the QEC scheme.\n",
"\n",
"In [Beverland et al](https://arxiv.org/abs/2211.07629), they use a gate-based QEC that has $P(d), n(d), \\tau(d)$ as:\n",
"In the paper, they use gate-based QEC which has $P(d), n(d), \\tau(d)$ as:\n",
"$$\n",
"P(d) = 0.03 \\left ( \\frac{p}{0.01} \\right) ^ \\frac{d+1}{2}\\\\\n",
"n(d) = 2 d^2\\\\\n",
"\\tau(d) = \\textrm{\\{error detection circuit time\\}} \\cdot d\\\\\n",
"\\tau(d) = \\textrm{\\{single stabilizer time\\}} \\cdot d\\\\\n",
"$$\n",
"\n",
"The error detection circuit time depends on several factors including the time to apply a Clifford, measurement and reset operations as well as classical processing.\n",
"The error detection circuit time depends on several factors physical factors including the time to apply a Clifford, measurement and reset operations as well as classical processing.\n",
"\n",
"In [Beverland et al](https://arxiv.org/abs/2211.07629) Table V they don't take into account the classical processing part and assume that a reset takes the same time as a measurement leading to the formula:\n",
"In Table V they don't take into account the classical processing part and assume that a reset takes the same time as a measurement leading to the formula:\n",
"$$\n",
"\\textrm{\\{error detection circuit time\\}} = 4t_\\textrm{gate} + 2t_\\textrm{meas}\n",
"\\textrm{\\{single stabilizer time\\}} = 4t_\\textrm{gate} + 2t_\\textrm{meas}\n",
"$$\n",
"\n",
"Other authors (e.g. [Fowler, Gidney](https://arxiv.org/abs/1808.06709)) assume that the entire process takes a specific time (e.g. $\\approx 1\\mu s$).\n",
"\n",
"In Qualtran, we use \"error detection circuit time\" rather than fall to the low level hardware parameters. "
"In Qualtran, we use \"single stabilizer time\" rather than fall to the low-level hardware parameters. We also default to the Fowler, Gidney parameters (i.e. `FowlerSuperconductingQubits`) when none are given."
]
},
{
Expand Down Expand Up @@ -182,14 +184,14 @@
"source": [
"### Quantum Dynamics\n",
"The algorithm specs of this circuit are given as:\n",
"- number of algorithm qubits: 100\n",
"- number of rotation gates: $30100$\n",
"- number of algorithm qubits: $100$\n",
"- number of rotation gates: $30,100$\n",
"- number of measurements: $1.4 \\times 10^6$\n",
"- number of T gates: $0$\n",
"- number of Toffoli gates: $0$\n",
"- depth of rotation circuit: $501$\n",
"\n",
"with an error budget $\\epsilon$ of 0.001"
"with an error budget $\\epsilon$ of $0.001$"
]
},
{
Expand Down Expand Up @@ -259,7 +261,7 @@
"\n",
"D4 gives the formula for $M$ as $$M = M_T + 4 M_{Tof} + M_R \\lceil A \\log_2{M_R/\\epsilon_{syn}} + B\\rceil$$\n",
"\n",
"Since $M_T = M_{Tof} = 0$, the only contribution to $M$ comes from rotations where $M_R = 30100, \\epsilon_{syn} = \\frac{10^{-3}}{3} , A = 0.53, B = 5.3$ which give our value of 6.02e5."
"Since $M_T = M_{Tof} = 0$, the only contribution to $M$ comes from rotations where $M_R = 30100, \\epsilon_{syn} = \\frac{10^{-3}}{3} , A = 0.53, B = 5.3$ which give our value of $6.02e5$."
]
},
{
Expand All @@ -271,7 +273,7 @@
"$$\n",
"P(d) = a \\left ( \\frac{p}{p^*} \\right )^\\frac{d+1}{2} \n",
"$$\n",
"subject ot the constraint on the logical error rate of $QCP(d) = \\frac{\\epsilon}{3}$. Where $p$ is the physical error rate. $a$ and $p^*$ are constants determined by the QEC scheme."
"subject ot the constraint on the logical error rate of $Q \\cdot C \\cdot P(d) = \\frac{\\epsilon}{3}$. Where $p$ is the physical error rate. $a$ and $p^*$ are constants determined by the QEC scheme."
]
},
{
Expand All @@ -285,7 +287,7 @@
" time_steps=c_min,\n",
" alg=quantum_dynamics_specs,\n",
" qec=BeverlandSuperconductingQubits,\n",
" physical_error_rate=BeverlandEtAl.physical_error_rate,\n",
" physical_error_rate=BEVERLAND_PARAMS.physical_error_rate,\n",
")\n",
"print(f'{d=}')"
]
Expand All @@ -295,7 +297,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Matching the surface code of $d = 9$. This leads to a total run time (Eq. E3) of 0.65s which is close to the time in the paper of 0.55s"
"Matching the paper's code distance of $d = 9$. This leads to a total run time (Eq. E3) of 0.65s which is close to the time in the paper of 0.55s"
]
},
{
Expand All @@ -304,15 +306,16 @@
"metadata": {},
"outputs": [],
"source": [
"'algorithm run time of %g seconds' % (qec.error_detection_circuit_time_us(d) * 1e-6 * c_min)"
"t_s = qec.error_detection_circuit_time_us(d) * 1e-6 * c_min\n",
"f'algorithm run time of {t_s:g} seconds'.format()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Next we examine the magic state factories. In [Beverland et al](https://arxiv.org/abs/2211.07629) for the quantum dynamics example we are given 199 factories each producing one T state every 46.8us at an error rate of 5.6e-11 while consuming 3240 qubits. "
"Next, we examine the magic state factories. In the paper, for the quantum dynamics example, we are given $199$ factories each producing one T state every $46.8 \\mu s$ at an error rate of $5.6e-11$ while consuming $3,240$ qubits. "
]
},
{
Expand Down Expand Up @@ -343,7 +346,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Our estimate of 0.68M physical qubits with 94.5% of them being consumed by the T states factories match exactly with the numbers in the paper."
"Our estimate of 0.68M physical qubits with 94.5% of them being consumed by the T states factories match the numbers in the paper."
]
},
{
Expand Down Expand Up @@ -447,7 +450,7 @@
" time_steps=c_min,\n",
" alg=quantum_chemistry_specs,\n",
" qec=qec,\n",
" physical_error_rate=BeverlandEtAl.physical_error_rate,\n",
" physical_error_rate=BEVERLAND_PARAMS.physical_error_rate,\n",
")\n",
"print(f'{d=}')"
]
Expand Down Expand Up @@ -484,7 +487,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Next we examine the magic state factories. In [Beverland et al](https://arxiv.org/abs/2211.07629) for the quantum chemistry example we are given 17 factories each producing one T state every 83.2us at an error rate of 2.13e-15 while consuming 16000 qubits. "
"Next we examine the magic state factories. In the paper, for the quantum chemistry example, we are given $17$ factories each producing one T state every $83.2\\mu s$ at an error rate of $2.13e-15$ while consuming $16,000$ qubits. "
]
},
{
Expand Down Expand Up @@ -515,7 +518,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Our estimate of 1.86M physical qubits matches exactly with the paper's."
"Our estimate of 1.86M physical qubits matches the paper's estimate."
]
},
{
Expand All @@ -525,14 +528,14 @@
"source": [
"### Shor Factoring\n",
"The algorithm specs of this circuit are given as:\n",
"- number of algorithm qubits: 12581\n",
"- number of algorithm qubits: $12,581$\n",
"- number of rotation gates: $12$\n",
"- number of measurements: $1.08 \\times 10^9$\n",
"- number of T gates: 12\n",
"- number of Toffoli gates: $3.73 \\times 10^{10}$\n",
"- depth of rotation circuit: $12$\n",
"\n",
"with an error budget of 1/3"
"with an error budget of $1/3$"
]
},
{
Expand Down Expand Up @@ -595,7 +598,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Our estimates of $Q = 25481, C_{min} = 1.23 \\cdot 10^{10}, M = 1.49 \\cdot 10^{10}$ match exactly with the estimates of the paper."
"Our estimates of $Q = 25481, C_{min} = 1.23 \\cdot 10^{10}, M = 1.49 \\cdot 10^{10}$ match the estimates of the paper."
]
},
{
Expand All @@ -609,7 +612,7 @@
" time_steps=c_min,\n",
" alg=shor_specs,\n",
" qec=qec,\n",
" physical_error_rate=BeverlandEtAl.physical_error_rate,\n",
" physical_error_rate=BEVERLAND_PARAMS.physical_error_rate,\n",
")\n",
"print(f'{d=}')"
]
Expand All @@ -619,7 +622,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Matching the surface code of $d = 13$ in the paper."
"Matching the code distance of $d = 13$ in the paper."
]
},
{
Expand All @@ -640,15 +643,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Our estimate runtime of 17h43m matches exactly with the estimate of the paper."
"Our estimate runtime of 17h43m matches with the estimate of the paper."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Next we examine the magic state factories. In [Beverland et al](https://arxiv.org/abs/2211.07629) for the quantum chemistry example we are given 18 factories each producing one T state every 72.8us at an error rate of 5.51e-13 while consuming 5760 qubits. "
"Next we examine the magic state factories. In the paper, for the quantum chemistry example, we are given $18$ factories each producing one T state every $72.8 \\mu s$ at an error rate of $5.51e-13$ while consuming $5,760$ qubits. "
]
},
{
Expand Down Expand Up @@ -679,7 +682,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Our estimate of 8.72M physical qubits matches exactly with the paper."
"Our estimate of 8.72M physical qubits matches the paper's estimate."
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion qualtran/surface_code/physical_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PhysicalParameters:
reference: Optional[str] = None


BeverlandEtAl = PhysicalParameters(
BEVERLAND_PARAMS = PhysicalParameters(
t_gate_ns=50, # 50ns
t_meas_ns=100, # 100ns
physical_error_rate=1e-4,
Expand Down

0 comments on commit 9eaea79

Please sign in to comment.