dyberforge 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dyberforge/__init__.py +34 -0
- dyberforge/cat_generation.py +335 -0
- dyberforge/cat_loss_budget.py +104 -0
- dyberforge/resource_model.py +259 -0
- dyberforge-0.1.0.dist-info/METADATA +61 -0
- dyberforge-0.1.0.dist-info/RECORD +9 -0
- dyberforge-0.1.0.dist-info/WHEEL +5 -0
- dyberforge-0.1.0.dist-info/licenses/LICENSE +202 -0
- dyberforge-0.1.0.dist-info/top_level.txt +1 -0
dyberforge/__init__.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""
|
|
2
|
+
dyberforge: the open H-cat simulation SDK (Workbench).
|
|
3
|
+
|
|
4
|
+
One import surface over the validated, public H-cat simulation physics:
|
|
5
|
+
cat-state generation, the cat loss budget with parity stabilization, and the
|
|
6
|
+
end-to-end physical-to-logical resource model.
|
|
7
|
+
|
|
8
|
+
import dyberforge as df
|
|
9
|
+
df.generate_cat(s_db=6.0, k=1, N=40) # cat fidelity, parity, state
|
|
10
|
+
df.loss_curves(2.0, [10**-0.32]) # loss budget, parity stabilization
|
|
11
|
+
df.estimate(gamma=0.005, target_logical_err=1e-9) # target -> device spec
|
|
12
|
+
|
|
13
|
+
Public, non-proprietary science only. The proprietary compiler passes, the
|
|
14
|
+
calibration internals, the architecture loss-chain ledger, and the foundry
|
|
15
|
+
recipes are NOT part of this package. The physics modules are vendored into the
|
|
16
|
+
package so it is fully self-contained (no path injection into a research repo).
|
|
17
|
+
"""
|
|
18
|
+
from .cat_generation import ( # noqa: F401
|
|
19
|
+
generate_cat, ideal_cat, squeezed_vacuum, subtract_ideal,
|
|
20
|
+
apply_loss, parity, mean_n, purity, best_squeezed_cat_fidelity,
|
|
21
|
+
)
|
|
22
|
+
from .cat_loss_budget import loss_curves # noqa: F401
|
|
23
|
+
from .resource_model import ( # noqa: F401
|
|
24
|
+
estimate, attempts_per_cat, code_distance, cats_per_logical, loss_to_errors,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
__version__ = "0.1.0"
|
|
28
|
+
|
|
29
|
+
__all__ = [
|
|
30
|
+
"generate_cat", "ideal_cat", "squeezed_vacuum", "subtract_ideal", "apply_loss",
|
|
31
|
+
"parity", "mean_n", "purity", "best_squeezed_cat_fidelity", "loss_curves",
|
|
32
|
+
"estimate", "attempts_per_cat", "code_distance", "cats_per_logical", "loss_to_errors",
|
|
33
|
+
"__version__",
|
|
34
|
+
]
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"""
|
|
2
|
+
H-cat cat-state generation from squeezed vacuum by photon subtraction.
|
|
3
|
+
|
|
4
|
+
Vendored into dyberforge so the package is self-contained (no path injection
|
|
5
|
+
into the research repo). Pure published physics, all in a truncated Fock space
|
|
6
|
+
with QuTiP:
|
|
7
|
+
|
|
8
|
+
squeezed vacuum -> photon subtraction (herald) -> approximate Schroedinger cat
|
|
9
|
+
S(r)|0> a^k |psi> (ideal) compare to ideal |cat(alpha)>
|
|
10
|
+
or beamsplitter tap + PNR (realistic)
|
|
11
|
+
|
|
12
|
+
Key quantities returned for each generated state:
|
|
13
|
+
- fidelity to the best-matched ideal cat (amplitude alpha optimized)
|
|
14
|
+
- purity Tr(rho^2)
|
|
15
|
+
- mean photon number <n>
|
|
16
|
+
- parity <(-1)^n> (the H-cat readout signature / loss syndrome)
|
|
17
|
+
|
|
18
|
+
Squeezing convention
|
|
19
|
+
--------------------
|
|
20
|
+
Squeezing in dB of the squeezed quadrature variance relative to vacuum:
|
|
21
|
+
S_dB = -10 log10(V), V = e^{-2r} => r = S_dB * ln(10) / 20
|
|
22
|
+
So 3.5 dB -> r=0.403, 6 dB -> r=0.691, 8 dB -> r=0.921, 10 dB -> r=1.151.
|
|
23
|
+
|
|
24
|
+
References
|
|
25
|
+
----------
|
|
26
|
+
Lee, Park & Jeong, PRX Quantum 5, 030322 (2024) (H-cat architecture)
|
|
27
|
+
Ourjoumtsev et al., Science 312, 83 (2006) (photon subtraction -> kitten)
|
|
28
|
+
"""
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
from functools import lru_cache
|
|
32
|
+
|
|
33
|
+
import numpy as np
|
|
34
|
+
import qutip as qt
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# ---------------------------------------------------------------------------
|
|
38
|
+
# cached primitives
|
|
39
|
+
# ---------------------------------------------------------------------------
|
|
40
|
+
# qt.squeeze / qt.coherent build a matrix exponential / displacement each call.
|
|
41
|
+
# In the (alpha, s) fidelity scans these get hit ~10^5 times for a handful of
|
|
42
|
+
# distinct values, so cache on quantized keys (1e-3 resolution is plenty).
|
|
43
|
+
@lru_cache(maxsize=None)
|
|
44
|
+
def _squeeze_op(N: int, r_milli: int) -> qt.Qobj:
|
|
45
|
+
return qt.squeeze(N, r_milli / 1000.0)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@lru_cache(maxsize=None)
|
|
49
|
+
def _coherent(N: int, a_milli: int) -> qt.Qobj:
|
|
50
|
+
return qt.coherent(N, a_milli / 1000.0)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def squeeze_op(N: int, r: float) -> qt.Qobj:
|
|
54
|
+
return _squeeze_op(N, int(round(r * 1000)))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def coherent_state(N: int, alpha: float) -> qt.Qobj:
|
|
58
|
+
return _coherent(N, int(round(alpha * 1000)))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@lru_cache(maxsize=None)
|
|
62
|
+
def _destroy(N: int) -> qt.Qobj:
|
|
63
|
+
return qt.destroy(N)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@lru_cache(maxsize=None)
|
|
67
|
+
def _num(N: int) -> qt.Qobj:
|
|
68
|
+
return qt.num(N)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# ---------------------------------------------------------------------------
|
|
72
|
+
# conversions
|
|
73
|
+
# ---------------------------------------------------------------------------
|
|
74
|
+
def db_to_r(s_db: float) -> float:
|
|
75
|
+
"""Squeezing in dB -> squeezing parameter r (real)."""
|
|
76
|
+
return s_db * np.log(10.0) / 20.0
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def r_to_db(r: float) -> float:
|
|
80
|
+
return 20.0 * r / np.log(10.0)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# ---------------------------------------------------------------------------
|
|
84
|
+
# ideal reference states
|
|
85
|
+
# ---------------------------------------------------------------------------
|
|
86
|
+
@lru_cache(maxsize=None)
|
|
87
|
+
def _ideal_cat(N: int, a_milli: int, parity: str) -> qt.Qobj:
|
|
88
|
+
alpha = a_milli / 1000.0
|
|
89
|
+
plus = coherent_state(N, alpha)
|
|
90
|
+
minus = coherent_state(N, -alpha)
|
|
91
|
+
if parity == "even":
|
|
92
|
+
psi = plus + minus
|
|
93
|
+
elif parity == "odd":
|
|
94
|
+
psi = plus - minus
|
|
95
|
+
else:
|
|
96
|
+
raise ValueError("parity must be 'even' or 'odd'")
|
|
97
|
+
return psi.unit()
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def ideal_cat(N: int, alpha: float, parity: str = "odd") -> qt.Qobj:
|
|
101
|
+
"""Normalized even/odd Schroedinger cat |alpha> +/- |-alpha>."""
|
|
102
|
+
return _ideal_cat(N, int(round(alpha * 1000)), parity)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def squeezed_vacuum(N: int, s_db: float) -> qt.Qobj:
|
|
106
|
+
"""Single-mode squeezed vacuum S(r)|0> for a given squeezing in dB."""
|
|
107
|
+
r = db_to_r(s_db)
|
|
108
|
+
return squeeze_op(N, r) * qt.basis(N, 0)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def ideal_squeezed_cat(N: int, alpha: float, s: float, parity: str = "odd") -> qt.Qobj:
|
|
112
|
+
"""
|
|
113
|
+
Squeezed cat S(s)(|alpha> +/- |-alpha>). This is the natural output of
|
|
114
|
+
photon subtraction from squeezed vacuum (Ourjoumtsev 2006), so it is the
|
|
115
|
+
correct high-fidelity reference manifold for a heralded kitten. s is a real
|
|
116
|
+
squeezing parameter (can be negative).
|
|
117
|
+
"""
|
|
118
|
+
cat = ideal_cat(N, alpha, parity)
|
|
119
|
+
return (squeeze_op(N, s) * cat).unit()
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# ---------------------------------------------------------------------------
|
|
123
|
+
# photon subtraction
|
|
124
|
+
# ---------------------------------------------------------------------------
|
|
125
|
+
def subtract_ideal(state: qt.Qobj, k: int = 1) -> qt.Qobj:
|
|
126
|
+
"""
|
|
127
|
+
Ideal k-photon subtraction: apply a^k and renormalize.
|
|
128
|
+
Subtracting an odd number of photons from squeezed vacuum yields an
|
|
129
|
+
approximate odd cat; an even number yields an approximate even cat.
|
|
130
|
+
"""
|
|
131
|
+
N = state.shape[0]
|
|
132
|
+
a = _destroy(N)
|
|
133
|
+
out = a ** k * state
|
|
134
|
+
return out.unit()
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def subtract_beamsplitter(state: qt.Qobj, k: int = 1, tap_db: float = 13.0,
|
|
138
|
+
eta_det: float = 1.0) -> qt.Qobj:
|
|
139
|
+
"""
|
|
140
|
+
Realistic heralded subtraction: send the signal through a weakly-reflecting
|
|
141
|
+
beamsplitter (tap), detect exactly k photons in the tap arm with a PNR
|
|
142
|
+
detector of efficiency eta_det, and keep the conditional signal state.
|
|
143
|
+
|
|
144
|
+
tap_db : tap arm reflectivity expressed as -10 log10(R) (e.g. 13 dB -> R~0.05).
|
|
145
|
+
Returns the (mixed) conditional density matrix of the signal mode.
|
|
146
|
+
"""
|
|
147
|
+
N = state.shape[0]
|
|
148
|
+
R = 10 ** (-tap_db / 10.0) # tap reflectivity (small)
|
|
149
|
+
theta = np.arcsin(np.sqrt(R)) # beamsplitter mixing angle
|
|
150
|
+
Ntap = max(k + 4, 8)
|
|
151
|
+
|
|
152
|
+
a = qt.tensor(qt.destroy(N), qt.qeye(Ntap))
|
|
153
|
+
b = qt.tensor(qt.qeye(N), qt.destroy(Ntap))
|
|
154
|
+
BS = (theta * (a.dag() * b - a * b.dag())).expm()
|
|
155
|
+
|
|
156
|
+
sig = state if state.isket else state
|
|
157
|
+
full = qt.tensor(sig, qt.basis(Ntap, 0))
|
|
158
|
+
if full.isket:
|
|
159
|
+
full = full * full.dag()
|
|
160
|
+
rho = BS * full * BS.dag()
|
|
161
|
+
|
|
162
|
+
# PNR projector onto exactly k photons in the tap arm (with detector loss)
|
|
163
|
+
if eta_det >= 1.0:
|
|
164
|
+
proj = qt.tensor(qt.qeye(N), qt.basis(Ntap, k) * qt.basis(Ntap, k).dag())
|
|
165
|
+
cond = (proj * rho * proj).ptrace(0)
|
|
166
|
+
else:
|
|
167
|
+
# detector efficiency: photons arriving m >= k, click registers k
|
|
168
|
+
cond = 0
|
|
169
|
+
for m in range(k, Ntap):
|
|
170
|
+
pm = qt.basis(Ntap, m) * qt.basis(Ntap, m).dag()
|
|
171
|
+
weight = _binom(m, k) * eta_det ** k * (1 - eta_det) ** (m - k)
|
|
172
|
+
blk = qt.tensor(qt.qeye(N), pm) * rho * qt.tensor(qt.qeye(N), pm)
|
|
173
|
+
cond = cond + weight * blk.ptrace(0)
|
|
174
|
+
return cond.unit()
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _binom(n: int, k: int) -> float:
|
|
178
|
+
from math import comb
|
|
179
|
+
return float(comb(n, k))
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
# ---------------------------------------------------------------------------
|
|
183
|
+
# loss channel (pure-loss / vacuum) on a single mode
|
|
184
|
+
# ---------------------------------------------------------------------------
|
|
185
|
+
def apply_loss(rho: qt.Qobj, eta: float, kmax: int | None = None) -> qt.Qobj:
|
|
186
|
+
"""
|
|
187
|
+
Pure-loss bosonic channel with transmissivity eta (eta=1 -> lossless).
|
|
188
|
+
Kraus operators E_l = sqrt((1-eta)^l / l!) * eta^{n/2} a^l. This is the
|
|
189
|
+
standard trace-preserving (sum_l E_l.dag E_l = I) pure-loss / amplitude-damping
|
|
190
|
+
form and is exactly the t-integral of the Lindblad dissipator kappa D[a] with
|
|
191
|
+
eta = exp(-kappa t); the operator order eta^{n/2} a^l (number-weight applied
|
|
192
|
+
after the lowering) is what makes the coefficient (1-eta)^l correct.
|
|
193
|
+
"""
|
|
194
|
+
if rho.isket:
|
|
195
|
+
rho = rho * rho.dag()
|
|
196
|
+
N = rho.shape[0]
|
|
197
|
+
if eta >= 1.0:
|
|
198
|
+
return rho
|
|
199
|
+
a = _destroy(N)
|
|
200
|
+
n = _num(N)
|
|
201
|
+
eta_half_n = (0.5 * np.log(eta) * n).expm() # eta^{n/2}
|
|
202
|
+
if kmax is None:
|
|
203
|
+
kmax = N - 1
|
|
204
|
+
from math import factorial
|
|
205
|
+
out = 0
|
|
206
|
+
one_m_eta = 1.0 - eta
|
|
207
|
+
for l in range(kmax + 1):
|
|
208
|
+
coeff = np.sqrt(one_m_eta ** l / factorial(l))
|
|
209
|
+
E = coeff * eta_half_n * (a ** l)
|
|
210
|
+
out = out + E * rho * E.dag()
|
|
211
|
+
# trace is preserved exactly by the Kraus set; renormalize only to absorb the
|
|
212
|
+
# tiny Fock-truncation defect from cutting the l-sum / a^l at the boundary.
|
|
213
|
+
return out.unit()
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
# ---------------------------------------------------------------------------
|
|
217
|
+
# observables
|
|
218
|
+
# ---------------------------------------------------------------------------
|
|
219
|
+
def parity(state: qt.Qobj) -> float:
|
|
220
|
+
"""<(-1)^n> (Wigner value at the origin, up to a factor)."""
|
|
221
|
+
N = state.shape[0]
|
|
222
|
+
P = (1j * np.pi * qt.num(N)).expm()
|
|
223
|
+
return float(np.real(qt.expect(P, state)))
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def mean_n(state: qt.Qobj) -> float:
|
|
227
|
+
N = state.shape[0]
|
|
228
|
+
return float(np.real(qt.expect(_num(N), state)))
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def purity(state: qt.Qobj) -> float:
|
|
232
|
+
rho = state * state.dag() if state.isket else state
|
|
233
|
+
return float(np.real((rho * rho).tr()))
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def best_cat_fidelity(state: qt.Qobj, parity_hint: str = "odd",
|
|
237
|
+
alpha_grid: np.ndarray | None = None) -> tuple[float, float]:
|
|
238
|
+
"""
|
|
239
|
+
Fidelity to the best-matched bare ideal cat, optimizing over amplitude.
|
|
240
|
+
Returns (max_fidelity, best_alpha). For a pure target |c>, <c|rho|c> is the
|
|
241
|
+
(squared) state fidelity.
|
|
242
|
+
"""
|
|
243
|
+
N = state.shape[0]
|
|
244
|
+
if alpha_grid is None:
|
|
245
|
+
alpha_grid = np.linspace(0.3, 2.8, 60)
|
|
246
|
+
rho = state if state.isoper else state * state.dag()
|
|
247
|
+
best_f, best_a = 0.0, 0.0
|
|
248
|
+
for a in alpha_grid:
|
|
249
|
+
tgt = ideal_cat(N, a, parity_hint)
|
|
250
|
+
f = float(np.real(qt.expect(rho, tgt)))
|
|
251
|
+
if f > best_f:
|
|
252
|
+
best_f, best_a = f, a
|
|
253
|
+
return best_f, best_a
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def best_squeezed_cat_fidelity(state: qt.Qobj, parity_hint: str = "odd",
|
|
257
|
+
alpha_min: float = 0.3,
|
|
258
|
+
alpha_max: float = 2.8,
|
|
259
|
+
n_alpha: int = 40,
|
|
260
|
+
s_grid: np.ndarray | None = None
|
|
261
|
+
) -> tuple[float, float, float]:
|
|
262
|
+
"""
|
|
263
|
+
Fidelity to the best-matched squeezed cat, optimizing over (alpha, s) with
|
|
264
|
+
alpha constrained to [alpha_min, alpha_max]. This is the physically correct
|
|
265
|
+
reference for photon-subtracted squeezed vacuum.
|
|
266
|
+
|
|
267
|
+
Set alpha_min ~ 1.0 to demand a usable cat: a cat with |alpha| < ~1 has
|
|
268
|
+
strongly overlapping lobes (|<alpha|-alpha>|^2 = exp(-4 alpha^2)) and is not
|
|
269
|
+
a good logical qubit, so an unconstrained fit (alpha -> 0) over-reports
|
|
270
|
+
quality. Returns (max_fidelity, best_alpha, best_s).
|
|
271
|
+
"""
|
|
272
|
+
N = state.shape[0]
|
|
273
|
+
alpha_grid = np.linspace(alpha_min, alpha_max, n_alpha)
|
|
274
|
+
if s_grid is None:
|
|
275
|
+
s_grid = np.linspace(-1.4, 1.4, 43)
|
|
276
|
+
rho = state if state.isoper else state * state.dag()
|
|
277
|
+
best = (0.0, alpha_min, 0.0)
|
|
278
|
+
for a in alpha_grid:
|
|
279
|
+
for s in s_grid:
|
|
280
|
+
tgt = ideal_squeezed_cat(N, a, s, parity_hint)
|
|
281
|
+
f = float(np.real(qt.expect(rho, tgt)))
|
|
282
|
+
if f > best[0]:
|
|
283
|
+
best = (f, a, s)
|
|
284
|
+
return best
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
# ---------------------------------------------------------------------------
|
|
288
|
+
# one-shot generator + characterization
|
|
289
|
+
# ---------------------------------------------------------------------------
|
|
290
|
+
def generate_cat(s_db: float, k: int = 1, N: int = 40, method: str = "ideal",
|
|
291
|
+
eta_loss: float = 1.0, **kw) -> dict:
|
|
292
|
+
"""
|
|
293
|
+
Generate an approximate cat at a given squeezing level and characterize it.
|
|
294
|
+
|
|
295
|
+
method: 'ideal' -> apply a^k
|
|
296
|
+
'beamsplitter' -> tap + PNR heralding (pass tap_db, eta_det)
|
|
297
|
+
eta_loss: optional downstream transmissivity applied AFTER generation.
|
|
298
|
+
"""
|
|
299
|
+
sv = squeezed_vacuum(N, s_db)
|
|
300
|
+
if method == "ideal":
|
|
301
|
+
state = subtract_ideal(sv, k)
|
|
302
|
+
elif method == "beamsplitter":
|
|
303
|
+
state = subtract_beamsplitter(sv, k, **kw)
|
|
304
|
+
else:
|
|
305
|
+
raise ValueError("method must be 'ideal' or 'beamsplitter'")
|
|
306
|
+
|
|
307
|
+
if eta_loss < 1.0:
|
|
308
|
+
state = apply_loss(state, eta_loss)
|
|
309
|
+
|
|
310
|
+
parity_hint = "odd" if (k % 2 == 1) else "even"
|
|
311
|
+
fid_bare, alpha_bare = best_cat_fidelity(state, parity_hint)
|
|
312
|
+
fid_uncon, a_uncon, s_uncon = best_squeezed_cat_fidelity(
|
|
313
|
+
state, parity_hint, alpha_min=0.3)
|
|
314
|
+
fid_use, a_use, s_use = best_squeezed_cat_fidelity(
|
|
315
|
+
state, parity_hint, alpha_min=1.0) # demand a usable (well-separated) cat
|
|
316
|
+
return {
|
|
317
|
+
"s_db": s_db,
|
|
318
|
+
"k": k,
|
|
319
|
+
"method": method,
|
|
320
|
+
"eta_loss": eta_loss,
|
|
321
|
+
# primary engineering metric: fidelity to a usable squeezed cat (|a|>=1)
|
|
322
|
+
"fidelity": fid_use,
|
|
323
|
+
"alpha": a_use,
|
|
324
|
+
"out_squeeze": s_use,
|
|
325
|
+
# intrinsic (unconstrained) squeezed-cat fidelity
|
|
326
|
+
"fidelity_uncon": fid_uncon,
|
|
327
|
+
"alpha_uncon": a_uncon,
|
|
328
|
+
# bare-cat fidelity (no output squeezing allowed)
|
|
329
|
+
"fidelity_bare": fid_bare,
|
|
330
|
+
"alpha_bare": alpha_bare,
|
|
331
|
+
"purity": purity(state),
|
|
332
|
+
"mean_n": mean_n(state),
|
|
333
|
+
"parity": parity(state),
|
|
334
|
+
"state": state,
|
|
335
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cat loss budget and parity stabilization: "how long does a cat last, and how do
|
|
3
|
+
we make it last longer?"
|
|
4
|
+
|
|
5
|
+
Vendored into dyberforge so the package is self-contained. This module ships the
|
|
6
|
+
public physics only: the parity-stabilized loss-curve calculation. The
|
|
7
|
+
architecture-specific component loss chain, the plotting, and the file output of
|
|
8
|
+
the research script are deliberately not included here.
|
|
9
|
+
|
|
10
|
+
For a flying photonic cat, "lifetime" = loss budget. Photon loss (transmissivity
|
|
11
|
+
eta) does TWO physically distinct things to a cat |C(alpha)>:
|
|
12
|
+
|
|
13
|
+
(1) PARITY FLIP per lost photon, detectable by a parity measurement and
|
|
14
|
+
correctable by a classical feedforward (Pauli-frame) update.
|
|
15
|
+
(2) AMPLITUDE DECAY alpha -> sqrt(eta)*alpha, the no-jump shrinkage; NOT
|
|
16
|
+
visible to parity and NOT correctable without re-amplification (breeding).
|
|
17
|
+
|
|
18
|
+
Key consequence:
|
|
19
|
+
|
|
20
|
+
* WITHOUT correction, loss looks like dephasing whose rate ~ |alpha|^2, so
|
|
21
|
+
bigger cats die faster.
|
|
22
|
+
* WITH parity stabilization, the dephasing channel is removed; the cat stays a
|
|
23
|
+
perfect (smaller) cat and the only limit is amplitude decay below the usable
|
|
24
|
+
threshold alpha_min. The survivable loss budget is then
|
|
25
|
+
|
|
26
|
+
budget(dB) = 20 * log10(alpha0 / alpha_min)
|
|
27
|
+
|
|
28
|
+
which GROWS with alpha0: parity stabilization inverts the size/lifetime
|
|
29
|
+
tradeoff.
|
|
30
|
+
"""
|
|
31
|
+
from __future__ import annotations
|
|
32
|
+
|
|
33
|
+
import numpy as np
|
|
34
|
+
import qutip as qt
|
|
35
|
+
|
|
36
|
+
from . import cat_generation as cg
|
|
37
|
+
|
|
38
|
+
N = 50
|
|
39
|
+
ALPHA_MIN = 1.0 # usable-cat threshold (well-separated lobes)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def parity_projectors(n):
|
|
43
|
+
P = (1j * np.pi * cg._num(n)).expm()
|
|
44
|
+
Peven = (qt.qeye(n) + P) / 2
|
|
45
|
+
Podd = (qt.qeye(n) - P) / 2
|
|
46
|
+
return Peven, Podd
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def loss_curves(alpha0, etas, eta_det=1.0):
|
|
50
|
+
"""
|
|
51
|
+
For each transmissivity eta, return logical fidelities of an even-cat |+_L>:
|
|
52
|
+
F_unc : fidelity to the original even cat, no correction (dephasing)
|
|
53
|
+
F_cor_fixed : parity-frame corrected, compared to original-amplitude cat
|
|
54
|
+
(residual error = amplitude mismatch only)
|
|
55
|
+
F_cor_shrunk : parity-frame corrected, compared to the decayed-amplitude cat
|
|
56
|
+
(coherence preserved -> ~1; this is the stabilized lifetime)
|
|
57
|
+
eta_det < 1 models an imperfect parity measurement (mis-assigns the sector with
|
|
58
|
+
probability (1-eta_det)/2), which re-introduces some dephasing into the
|
|
59
|
+
corrected curves.
|
|
60
|
+
"""
|
|
61
|
+
Peven, Podd = parity_projectors(N)
|
|
62
|
+
cat0 = cg.ideal_cat(N, alpha0, "even")
|
|
63
|
+
rows = []
|
|
64
|
+
for eta in etas:
|
|
65
|
+
rho = cg.apply_loss(cat0, float(eta))
|
|
66
|
+
a_dec = np.sqrt(eta) * alpha0
|
|
67
|
+
|
|
68
|
+
even0 = cg.ideal_cat(N, alpha0, "even")
|
|
69
|
+
odd0 = cg.ideal_cat(N, alpha0, "odd")
|
|
70
|
+
evend = cg.ideal_cat(N, a_dec, "even")
|
|
71
|
+
oddd = cg.ideal_cat(N, a_dec, "odd")
|
|
72
|
+
|
|
73
|
+
F_unc = float(np.real(qt.expect(rho, even0)))
|
|
74
|
+
|
|
75
|
+
pe = float(np.real((Peven * rho).tr()))
|
|
76
|
+
po = float(np.real((Podd * rho).tr()))
|
|
77
|
+
rho_e = (Peven * rho * Peven) / max(pe, 1e-12)
|
|
78
|
+
rho_o = (Podd * rho * Podd) / max(po, 1e-12)
|
|
79
|
+
|
|
80
|
+
# perfect parity assignment
|
|
81
|
+
Fcf = pe * float(np.real(qt.expect(rho_e, even0))) + \
|
|
82
|
+
po * float(np.real(qt.expect(rho_o, odd0)))
|
|
83
|
+
Fcs = pe * float(np.real(qt.expect(rho_e, evend))) + \
|
|
84
|
+
po * float(np.real(qt.expect(rho_o, oddd)))
|
|
85
|
+
|
|
86
|
+
# imperfect parity measurement: probability em of mis-assigning sector
|
|
87
|
+
if eta_det < 1.0:
|
|
88
|
+
em = (1.0 - eta_det) / 2.0
|
|
89
|
+
Fcf = (1 - em) * Fcf + em * (
|
|
90
|
+
pe * float(np.real(qt.expect(rho_e, odd0))) +
|
|
91
|
+
po * float(np.real(qt.expect(rho_o, even0))))
|
|
92
|
+
Fcs = (1 - em) * Fcs + em * (
|
|
93
|
+
pe * float(np.real(qt.expect(rho_e, oddd))) +
|
|
94
|
+
po * float(np.real(qt.expect(rho_o, evend))))
|
|
95
|
+
|
|
96
|
+
rows.append({"eta": float(eta), "loss_db": float(-10 * np.log10(eta)),
|
|
97
|
+
"alpha0": alpha0, "alpha_decayed": float(a_dec),
|
|
98
|
+
"F_unc": F_unc, "F_cor_fixed": Fcf, "F_cor_shrunk": Fcs})
|
|
99
|
+
return rows
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def budget_db(alpha0, alpha_min=ALPHA_MIN):
|
|
103
|
+
"""Parity-stabilized amplitude-decay loss budget, 20 log10(alpha0/alpha_min)."""
|
|
104
|
+
return 20 * np.log10(alpha0 / alpha_min)
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"""
|
|
2
|
+
H-cat integrated end-to-end resource model (v2 calibrated, v1 preserved).
|
|
3
|
+
|
|
4
|
+
Vendored into dyberforge so the package is self-contained. This module ships the
|
|
5
|
+
public physics-to-logical estimate: the loss split, the outer-code distance, the
|
|
6
|
+
cats-per-logical count, and the production-throughput estimate. The internal
|
|
7
|
+
roadmap tables, the architecture loss-chain ledger, the plotting, and the file
|
|
8
|
+
output of the research script are deliberately not included here.
|
|
9
|
+
|
|
10
|
+
Chains the validated sub-results into one physical-to-logical estimate:
|
|
11
|
+
|
|
12
|
+
squeezing -> kitten -> breeding (multiplexing) -> usable cat
|
|
13
|
+
-> photon loss -> heralded erasure + quadratic Pauli residue
|
|
14
|
+
-> outer surface code (distance d) -> logical qubit
|
|
15
|
+
|
|
16
|
+
Two model versions
|
|
17
|
+
------------------
|
|
18
|
+
model="v1" pure exact-Kraus loss split on the ideal cat, phenomenological
|
|
19
|
+
sub-threshold scaling with p_th = 0.68 percent.
|
|
20
|
+
model="v2" (default) recalibrated loss split (digital-twin correction factors)
|
|
21
|
+
and circuit-level code distance, threshold p_th_circ = 0.79 percent
|
|
22
|
+
(corrected; 0.898 percent uncorrected option),
|
|
23
|
+
Lambda(gamma) = (p_th_circ/gamma)^1.61, LER(d) = A_CIRC*Lambda^(-(d+1)/2).
|
|
24
|
+
"""
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
from math import factorial, ceil, log
|
|
28
|
+
import numpy as np
|
|
29
|
+
|
|
30
|
+
from . import cat_generation as cg
|
|
31
|
+
|
|
32
|
+
MODEL_DEFAULT = "v2"
|
|
33
|
+
|
|
34
|
+
# ---- validated constants ----
|
|
35
|
+
P_GEN = 0.30 # heralded subtraction success
|
|
36
|
+
P_BREED = 0.24 # breeding herald success (realistic)
|
|
37
|
+
P_TH = 0.0068 # v1 phenomenological surface threshold
|
|
38
|
+
ERASURE_TH = 0.5 # surface-code erasure threshold (literature/standard)
|
|
39
|
+
C_SUB = 0.1 # v1 sub-threshold prefactor (standard QEC scaling)
|
|
40
|
+
ALPHA0 = 1.0 # kitten amplitude
|
|
41
|
+
ALPHA_TARGET = 2.0 # usable computational cat
|
|
42
|
+
ALPHA_MIN = 1.0 # parity-stabilized amplitude floor
|
|
43
|
+
|
|
44
|
+
# ---- v2 calibration constants ----
|
|
45
|
+
# Circuit-level calibration:
|
|
46
|
+
P_TH_CIRC = 0.0079 # corrected threshold (3x p_pauli folded in); default
|
|
47
|
+
P_TH_CIRC_UNCORRECTED = 0.00898 # uncorrected circuit-level threshold
|
|
48
|
+
LAMBDA_EXP = 1.61 # Lambda(gamma) = (p_th/gamma)^1.61 (margin ladder fit)
|
|
49
|
+
A_CIRC = 0.30 # LER(d) = A_CIRC * Lambda^(-(d+1)/2)
|
|
50
|
+
|
|
51
|
+
# Mux/feedforward herald-collision tax (16-candidate architecture):
|
|
52
|
+
MUX_ATTEMPT_FACTOR = 239.0 / 231.0
|
|
53
|
+
|
|
54
|
+
# v2 operating points
|
|
55
|
+
GAMMA_SPEC = 0.005 # per-cycle loss spec
|
|
56
|
+
GAMMA_STRETCH = 0.004 # stretch case
|
|
57
|
+
|
|
58
|
+
# ---- digital-twin loss-split correction factors ----
|
|
59
|
+
# exact channel measured on the bred-cat density matrix vs the Poisson closed form
|
|
60
|
+
_SPLIT_GAMMA_GRID = np.array([0.005, 0.010, 0.020, 0.030])
|
|
61
|
+
_SPLIT_F_ERASE = np.array([0.9583507007766099, 0.9205203546179248,
|
|
62
|
+
0.854608265667542, 0.7994035470416974])
|
|
63
|
+
_SPLIT_F_PAULI = np.array([3.0846032998386854, 2.919170374042666,
|
|
64
|
+
2.629331412714363, 2.384856621831815])
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def split_correction(gamma):
|
|
68
|
+
"""
|
|
69
|
+
Digital-twin correction factors (f_erase, f_pauli) for the Poisson loss
|
|
70
|
+
split, linearly interpolated on the measured grid gamma in [0.5, 3] percent.
|
|
71
|
+
Outside the grid the interpolation is CLIPPED (constant extrapolation at the
|
|
72
|
+
nearest measured point).
|
|
73
|
+
"""
|
|
74
|
+
g = float(np.clip(gamma, _SPLIT_GAMMA_GRID[0], _SPLIT_GAMMA_GRID[-1]))
|
|
75
|
+
f_e = float(np.interp(g, _SPLIT_GAMMA_GRID, _SPLIT_F_ERASE))
|
|
76
|
+
f_p = float(np.interp(g, _SPLIT_GAMMA_GRID, _SPLIT_F_PAULI))
|
|
77
|
+
return f_e, f_p
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# ---------------------------------------------------------------------------
|
|
81
|
+
# Stage A -- cat production throughput
|
|
82
|
+
# ---------------------------------------------------------------------------
|
|
83
|
+
def breeding_rounds(alpha0=ALPHA0, alpha_target=ALPHA_TARGET):
|
|
84
|
+
"""alpha *= sqrt(2) per round -> rounds to reach target."""
|
|
85
|
+
return max(0, ceil(2 * np.log2(alpha_target / alpha0)))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def attempts_per_cat(p_gen=P_GEN, p_breed=P_BREED, alpha0=ALPHA0, alpha_target=ALPHA_TARGET):
|
|
89
|
+
"""Expected raw subtraction attempts to deliver one usable cat (ideal
|
|
90
|
+
routing; estimate() applies the MUX_ATTEMPT_FACTOR collision tax on top)."""
|
|
91
|
+
R = breeding_rounds(alpha0, alpha_target)
|
|
92
|
+
kittens = (2.0 / p_breed) ** R # binary breeding tree w/ herald losses
|
|
93
|
+
return kittens / p_gen, R
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# ---------------------------------------------------------------------------
|
|
97
|
+
# Stage B -- loss -> erasure + Pauli, and outer-code distance
|
|
98
|
+
# ---------------------------------------------------------------------------
|
|
99
|
+
def _loss_distribution(alpha, gamma, N=50):
|
|
100
|
+
cat = cg.ideal_cat(N, alpha, "even")
|
|
101
|
+
rho = cat * cat.dag()
|
|
102
|
+
eta = 1.0 - gamma
|
|
103
|
+
a = cg._destroy(N)
|
|
104
|
+
eta_half_n = (0.5 * np.log(eta) * cg._num(N)).expm()
|
|
105
|
+
P = []
|
|
106
|
+
for l in range(N):
|
|
107
|
+
E = np.sqrt((1.0 - eta) ** l / factorial(l)) * eta_half_n * (a ** l)
|
|
108
|
+
P.append(float(np.real((E * rho * E.dag()).tr())))
|
|
109
|
+
return np.array(P)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def poisson_loss_split(gamma, alpha=ALPHA_TARGET):
|
|
113
|
+
"""Closed-form Poisson loss split at lambda = alpha^2 gamma:
|
|
114
|
+
p_erase = (1 - exp(-2 lam))/2, p_pauli = (1 + exp(-2 lam))/2 - exp(-lam)."""
|
|
115
|
+
lam = alpha * alpha * gamma
|
|
116
|
+
p_e = 0.5 * (1.0 - np.exp(-2.0 * lam))
|
|
117
|
+
p_z = 0.5 * (1.0 + np.exp(-2.0 * lam)) - np.exp(-lam)
|
|
118
|
+
return float(p_e), float(p_z)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def loss_to_errors(gamma, alpha=ALPHA_TARGET, model=MODEL_DEFAULT):
|
|
122
|
+
"""
|
|
123
|
+
Per-cycle physical loss -> (erasure rate, unheralded Pauli rate).
|
|
124
|
+
|
|
125
|
+
v1: exact Kraus loss distribution on the IDEAL cat (odd losses -> heralded
|
|
126
|
+
erasure, even >= 2 -> silent Pauli).
|
|
127
|
+
v2: Poisson closed form x digital-twin correction factors (split_correction).
|
|
128
|
+
"""
|
|
129
|
+
if model == "v1":
|
|
130
|
+
P = _loss_distribution(alpha, gamma)
|
|
131
|
+
p_e = P[1::2].sum() # odd losses -> heralded erasure
|
|
132
|
+
p_z = P[2::2].sum() # even(>=2) losses -> unheralded Pauli
|
|
133
|
+
return p_e, p_z
|
|
134
|
+
p_e0, p_z0 = poisson_loss_split(gamma, alpha)
|
|
135
|
+
f_e, f_p = split_correction(gamma)
|
|
136
|
+
return p_e0 * f_e, p_z0 * f_p
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def code_distance(p_z, target_logical_err, p_th=P_TH, c=C_SUB):
|
|
140
|
+
"""v1: smallest odd distance d with C (p_z/p_th)^((d+1)/2) <= target."""
|
|
141
|
+
if p_z >= p_th:
|
|
142
|
+
return None # above threshold: no distance helps
|
|
143
|
+
ratio = p_z / p_th
|
|
144
|
+
m = log(target_logical_err / c) / log(ratio) # = (d+1)/2
|
|
145
|
+
d = int(2 * ceil(m) - 1)
|
|
146
|
+
return max(d, 3)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def lambda_circ(gamma, corrected=True):
|
|
150
|
+
"""Circuit-level error-suppression factor per distance step,
|
|
151
|
+
Lambda(gamma) = (p_th_circ/gamma)^1.61."""
|
|
152
|
+
p_th = P_TH_CIRC if corrected else P_TH_CIRC_UNCORRECTED
|
|
153
|
+
return (p_th / gamma) ** LAMBDA_EXP
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def code_distance_v2(gamma, target_logical_err, corrected=True):
|
|
157
|
+
"""
|
|
158
|
+
v2: smallest odd distance d with A_CIRC * Lambda^(-(d+1)/2) <= target,
|
|
159
|
+
Lambda = (p_th_circ/gamma)^1.61. corrected=True (default) folds in the
|
|
160
|
+
digital-twin 3x p_pauli correction via the 0.79 percent threshold. Returns
|
|
161
|
+
None at or above threshold (Lambda <= 1: increasing d makes the logical
|
|
162
|
+
error worse).
|
|
163
|
+
"""
|
|
164
|
+
lam = lambda_circ(gamma, corrected)
|
|
165
|
+
if lam <= 1.0:
|
|
166
|
+
return None
|
|
167
|
+
m = ceil(log(A_CIRC / target_logical_err) / log(lam)) # = (d+1)/2
|
|
168
|
+
d = int(2 * m - 1)
|
|
169
|
+
return max(d, 3)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def cats_per_logical(d):
|
|
173
|
+
"""Rotated surface code: d^2 data + (d^2 - 1) ancilla."""
|
|
174
|
+
return 2 * d * d - 1
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
# ---------------------------------------------------------------------------
|
|
178
|
+
# Stage C -- hardware split
|
|
179
|
+
# ---------------------------------------------------------------------------
|
|
180
|
+
def hardware_modes_per_logical(attempts, cats_per_log, spatial, wavelength):
|
|
181
|
+
"""
|
|
182
|
+
Total attempt-throughput is spread over spatial x wavelength x temporal
|
|
183
|
+
multiplexing. hardware sources per cat = spatial; temporal bins absorb the
|
|
184
|
+
rest: T = ceil(D / (spatial*wavelength)).
|
|
185
|
+
hardware modes per logical = spatial * cats_per_logical.
|
|
186
|
+
"""
|
|
187
|
+
T = max(1, ceil(attempts / (spatial * wavelength)))
|
|
188
|
+
hw_modes = spatial * cats_per_log
|
|
189
|
+
return hw_modes, T
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
# ---------------------------------------------------------------------------
|
|
193
|
+
# end-to-end
|
|
194
|
+
# ---------------------------------------------------------------------------
|
|
195
|
+
QLDPC_GAIN = 10.0 # quantum-LDPC overhead reduction vs surface code
|
|
196
|
+
# (Panteleev-Kalachev 2022 / Bravyi 2024)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def estimate(gamma, target_logical_err, p_gen=P_GEN, p_breed=P_BREED,
|
|
200
|
+
alpha_target=ALPHA_TARGET, spatial=8, wavelength=32,
|
|
201
|
+
use_outer_code=True, verbose=False, model=MODEL_DEFAULT,
|
|
202
|
+
corrected_threshold=True):
|
|
203
|
+
"""
|
|
204
|
+
End-to-end physical-to-logical estimate at one operating point.
|
|
205
|
+
|
|
206
|
+
model="v2" (default) applies the calibrated digital-twin loss split, the
|
|
207
|
+
circuit-level code distance (corrected_threshold selects 0.79 vs 0.898
|
|
208
|
+
percent), and the mux herald-collision attempts tax. model="v1" reproduces
|
|
209
|
+
the historical phenomenological model.
|
|
210
|
+
"""
|
|
211
|
+
att_ideal, R = attempts_per_cat(p_gen, p_breed, ALPHA0, alpha_target)
|
|
212
|
+
if model == "v1":
|
|
213
|
+
att = att_ideal
|
|
214
|
+
p_e, p_z = loss_to_errors(gamma, alpha_target, model="v1")
|
|
215
|
+
else:
|
|
216
|
+
att = att_ideal * MUX_ATTEMPT_FACTOR
|
|
217
|
+
p_e, p_z = loss_to_errors(gamma, alpha_target, model="v2")
|
|
218
|
+
|
|
219
|
+
# NISQ regime: H-cat loss detection only, no outer code (target ~>= 1e-2)
|
|
220
|
+
if not use_outer_code:
|
|
221
|
+
cpl = 1
|
|
222
|
+
hw, T = hardware_modes_per_logical(att, cpl, spatial, wavelength)
|
|
223
|
+
return {"gamma": gamma, "target_err": target_logical_err, "rounds": R,
|
|
224
|
+
"attempts_per_cat": att, "p_erase": p_e, "p_pauli": p_z,
|
|
225
|
+
"distance": 1, "cats_per_logical": cpl,
|
|
226
|
+
"throughput_per_logical": att * cpl, "hw_modes_per_logical": hw,
|
|
227
|
+
"time_bins": T, "erasure_ok": p_e < ERASURE_TH, "model": model}
|
|
228
|
+
|
|
229
|
+
if model == "v1":
|
|
230
|
+
d = code_distance(p_z, target_logical_err)
|
|
231
|
+
else:
|
|
232
|
+
d = code_distance_v2(gamma, target_logical_err, corrected_threshold)
|
|
233
|
+
res = {"gamma": gamma, "target_err": target_logical_err,
|
|
234
|
+
"rounds": R, "attempts_per_cat": att,
|
|
235
|
+
"p_erase": p_e, "p_pauli": p_z, "distance": d, "model": model}
|
|
236
|
+
if d is None:
|
|
237
|
+
res.update({"cats_per_logical": None, "throughput_per_logical": None,
|
|
238
|
+
"hw_modes_per_logical": None, "time_bins": None,
|
|
239
|
+
"erasure_ok": p_e < ERASURE_TH})
|
|
240
|
+
return res
|
|
241
|
+
cpl = cats_per_logical(d)
|
|
242
|
+
hw, T = hardware_modes_per_logical(att, cpl, spatial, wavelength)
|
|
243
|
+
res.update({"cats_per_logical": cpl,
|
|
244
|
+
"throughput_per_logical": att * cpl,
|
|
245
|
+
"hw_modes_per_logical": hw, "time_bins": T,
|
|
246
|
+
"erasure_ok": p_e < ERASURE_TH})
|
|
247
|
+
if verbose:
|
|
248
|
+
thr = (P_TH if model == "v1" else
|
|
249
|
+
(P_TH_CIRC if corrected_threshold else P_TH_CIRC_UNCORRECTED))
|
|
250
|
+
print(f" [{model}] gamma={gamma*100:.2f}%/cycle, "
|
|
251
|
+
f"target eL={target_logical_err:.0e}")
|
|
252
|
+
print(f" breeding rounds R={R}, attempts/cat={att:.0f}")
|
|
253
|
+
print(f" loss -> erasure p_e={p_e:.3e} (<{ERASURE_TH}: {res['erasure_ok']}),"
|
|
254
|
+
f" Pauli p_z={p_z:.3e} (threshold ref {thr})")
|
|
255
|
+
print(f" code distance d={d}, cats/logical={cpl}")
|
|
256
|
+
print(f" throughput/logical={att*cpl:.3e} attempts; "
|
|
257
|
+
f"hw modes/logical={hw} (spatial {spatial} x wl {wavelength}, "
|
|
258
|
+
f"{T} time bins)")
|
|
259
|
+
return res
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dyberforge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Open H-cat photonic quantum computing simulation SDK (Dyber Forge Workbench)
|
|
5
|
+
Author: Dyber, Inc.
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://quantaforge.dyber.org
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: numpy
|
|
16
|
+
Requires-Dist: scipy
|
|
17
|
+
Requires-Dist: qutip>=5
|
|
18
|
+
Requires-Dist: matplotlib
|
|
19
|
+
Requires-Dist: stim>=1.13
|
|
20
|
+
Requires-Dist: pymatching>=2
|
|
21
|
+
Provides-Extra: devices
|
|
22
|
+
Requires-Dist: meep; extra == "devices"
|
|
23
|
+
Provides-Extra: crosscheck
|
|
24
|
+
Requires-Dist: strawberryfields; extra == "crosscheck"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# dyberforge (Workbench SDK)
|
|
30
|
+
|
|
31
|
+
Open-source H-cat photonic quantum computing simulation SDK. One import surface over the
|
|
32
|
+
validated Dyber simulation code.
|
|
33
|
+
|
|
34
|
+
## Install (development)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
conda create -n dyber python=3.11 -y && conda activate dyber
|
|
38
|
+
pip install numpy scipy qutip matplotlib stim pymatching
|
|
39
|
+
pip install -e . # from forge/sdk/
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Use
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import dyberforge as df
|
|
46
|
+
df.generate_cat(s_db=6.0, k=1, N=40) # cat fidelity, parity, Wigner-ready state
|
|
47
|
+
df.loss_curves(2.0, [10**-0.32]) # loss budget, parity stabilization
|
|
48
|
+
df.estimate(gamma=0.005, target_logical_err=1e-9) # 0.5% spec -> device spec (v2)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Run the example: `python examples/quickstart.py`.
|
|
52
|
+
|
|
53
|
+
## Notes
|
|
54
|
+
|
|
55
|
+
- The physics modules are vendored into `dyberforge/`, so the package is fully
|
|
56
|
+
self-contained: `pip install dyberforge` works standalone with no path injection.
|
|
57
|
+
- Public science only. The OpenForge compiler passes, calibration internals, the
|
|
58
|
+
architecture loss-chain ledger, and foundry recipes are proprietary and are not part of
|
|
59
|
+
this package.
|
|
60
|
+
- Optional extras: `pip install .[devices]` (Meep), `.[crosscheck]` (Strawberry Fields),
|
|
61
|
+
`.[dev]` (pytest).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
dyberforge/__init__.py,sha256=GfrvHr6V7vmu-YFeAmVkkuQFZOcQyTvr9WKIgUpStiQ,1519
|
|
2
|
+
dyberforge/cat_generation.py,sha256=spiKSFt-sN6EB7wxa2GGk6ePaD21hwVok2CQqfWxLM4,12560
|
|
3
|
+
dyberforge/cat_loss_budget.py,sha256=DBsCd4NgqVUXMOxT1a9a3jQqH2V8VxEPRP67OwCjvaw,4222
|
|
4
|
+
dyberforge/resource_model.py,sha256=S3uYB15AC4c3IBDHDAh4Qh762du07F20tO7inX66n3Q,11383
|
|
5
|
+
dyberforge-0.1.0.dist-info/licenses/LICENSE,sha256=f7DuGEDcRwcVk0yt1RxHL5gFqq5gfHOCjguwsCziuIo,11342
|
|
6
|
+
dyberforge-0.1.0.dist-info/METADATA,sha256=yXPs_XXIPtBEqYRpuCmO0zrih0ZmDBSXTt-Rbt9C9GM,2076
|
|
7
|
+
dyberforge-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
8
|
+
dyberforge-0.1.0.dist-info/top_level.txt,sha256=ZWWTjXO1W4bEmKWOF8_Uj1_d1m1K5-No6VozVnDG4uA,11
|
|
9
|
+
dyberforge-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Dyber, Inc.
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dyberforge
|