dyber 0.1.0__tar.gz
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.
- dyber-0.1.0/LICENSE +202 -0
- dyber-0.1.0/PKG-INFO +91 -0
- dyber-0.1.0/README.md +70 -0
- dyber-0.1.0/dyber/__init__.py +19 -0
- dyber-0.1.0/dyber/backend.py +108 -0
- dyber-0.1.0/dyber/circuit.py +90 -0
- dyber-0.1.0/dyber/native.py +183 -0
- dyber-0.1.0/dyber/protocol.py +38 -0
- dyber-0.1.0/dyber/provider.py +29 -0
- dyber-0.1.0/dyber/result.py +50 -0
- dyber-0.1.0/dyber/server.py +85 -0
- dyber-0.1.0/dyber/simulator.py +123 -0
- dyber-0.1.0/dyber.egg-info/PKG-INFO +91 -0
- dyber-0.1.0/dyber.egg-info/SOURCES.txt +18 -0
- dyber-0.1.0/dyber.egg-info/dependency_links.txt +1 -0
- dyber-0.1.0/dyber.egg-info/entry_points.txt +2 -0
- dyber-0.1.0/dyber.egg-info/requires.txt +7 -0
- dyber-0.1.0/dyber.egg-info/top_level.txt +1 -0
- dyber-0.1.0/pyproject.toml +34 -0
- dyber-0.1.0/setup.cfg +4 -0
dyber-0.1.0/LICENSE
ADDED
|
@@ -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.
|
dyber-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dyber
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Dyber SDK: interact with the H-cat photonic quantum computer (simulator now, QPU later)
|
|
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.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: numpy
|
|
16
|
+
Provides-Extra: physics
|
|
17
|
+
Requires-Dist: dyberforge; extra == "physics"
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest; extra == "dev"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# Dyber SDK
|
|
23
|
+
|
|
24
|
+
Interact with the H-cat photonic quantum computer. Write a circuit once and run it on the
|
|
25
|
+
local simulator today and on the H-cat QPU later, with no change to your code. This is the
|
|
26
|
+
control interface, designed so that when the hardware exists, only the backend transport
|
|
27
|
+
changes.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install numpy
|
|
33
|
+
pip install -e . # from sdk/
|
|
34
|
+
# optional: physics-grade resource and noise models
|
|
35
|
+
pip install -e ../forge/sdk # dyberforge
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Hello, H-cat
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from dyber import Dyber, Circuit
|
|
42
|
+
|
|
43
|
+
dy = Dyber()
|
|
44
|
+
print(dy.backends()) # local_simulator (online), hcat_qpu (offline)
|
|
45
|
+
|
|
46
|
+
c = Circuit(2, "bell")
|
|
47
|
+
c.h(0); c.cx(0, 1); c.measure_all()
|
|
48
|
+
|
|
49
|
+
job = dy.backend("local_simulator").run(c, shots=1000)
|
|
50
|
+
res = job.result()
|
|
51
|
+
print(res.counts()) # {'00': ~500, '11': ~500}
|
|
52
|
+
print(res.resources) # distance, cats per logical, hw modes per logical
|
|
53
|
+
print(res.noise) # physics-informed noise summary (if enabled)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Run it over the network (the real QPU path)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
python -m dyber.server # reference control plane on 127.0.0.1:8787
|
|
60
|
+
```
|
|
61
|
+
```python
|
|
62
|
+
backend = dy.backend("remote", url="http://127.0.0.1:8787")
|
|
63
|
+
job = backend.run(c, shots=1000) # same protocol the hardware will use
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The `hcat_qpu` backend points at the production control plane and is offline until the
|
|
67
|
+
hardware exists. The moment it is online, `dy.backend("hcat_qpu").run(c)` runs on silicon.
|
|
68
|
+
|
|
69
|
+
## How it is layered
|
|
70
|
+
|
|
71
|
+
| Layer | Module | Role |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| Circuit | `circuit.py` | gate-model program you write |
|
|
74
|
+
| Lowering | `native.py` | maps gates to native H-cat ops (cat prep, hybrid fusion, parity readout); the real lowering is OpenForge |
|
|
75
|
+
| Simulator | `simulator.py` | exact statevector run, plus physics-informed noise from the resource model |
|
|
76
|
+
| Backends | `backend.py` | local simulator, remote (HTTP), and the hcat_qpu hardware backend, one interface |
|
|
77
|
+
| Protocol | `protocol.py` | the JSON job format shared by SDK and control plane |
|
|
78
|
+
| Control plane | `server.py` | reference server: today runs the simulator, later fronts the FPGA control system |
|
|
79
|
+
|
|
80
|
+
## Notes
|
|
81
|
+
|
|
82
|
+
- The simulator is exact for up to 14 qubits. Noise is a planning-grade estimate calibrated
|
|
83
|
+
to the validated H-cat loss and resource models, not a full physical simulation.
|
|
84
|
+
- Resource estimates use the v2 calibration (June 2026 circuit-level validation campaign):
|
|
85
|
+
corrected loss threshold 0.79 percent per cycle (0.898 percent uncorrected option), spec
|
|
86
|
+
operating point 0.5 percent per cycle (d=53, 5,617 cats per logical at 1e-9, 239.5
|
|
87
|
+
attempts per cat). At or above the threshold the resource report honestly returns the
|
|
88
|
+
above-threshold regime (no fault-tolerant distance) with a NISQ fallback estimate.
|
|
89
|
+
- Proprietary components (the OpenForge compiler passes, calibration, foundry recipes) are
|
|
90
|
+
not part of this SDK. The native lowering here is illustrative.
|
|
91
|
+
- Style: no em-dashes; commas, colons, periods, and hyphens for ranges.
|
dyber-0.1.0/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Dyber SDK
|
|
2
|
+
|
|
3
|
+
Interact with the H-cat photonic quantum computer. Write a circuit once and run it on the
|
|
4
|
+
local simulator today and on the H-cat QPU later, with no change to your code. This is the
|
|
5
|
+
control interface, designed so that when the hardware exists, only the backend transport
|
|
6
|
+
changes.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install numpy
|
|
12
|
+
pip install -e . # from sdk/
|
|
13
|
+
# optional: physics-grade resource and noise models
|
|
14
|
+
pip install -e ../forge/sdk # dyberforge
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Hello, H-cat
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from dyber import Dyber, Circuit
|
|
21
|
+
|
|
22
|
+
dy = Dyber()
|
|
23
|
+
print(dy.backends()) # local_simulator (online), hcat_qpu (offline)
|
|
24
|
+
|
|
25
|
+
c = Circuit(2, "bell")
|
|
26
|
+
c.h(0); c.cx(0, 1); c.measure_all()
|
|
27
|
+
|
|
28
|
+
job = dy.backend("local_simulator").run(c, shots=1000)
|
|
29
|
+
res = job.result()
|
|
30
|
+
print(res.counts()) # {'00': ~500, '11': ~500}
|
|
31
|
+
print(res.resources) # distance, cats per logical, hw modes per logical
|
|
32
|
+
print(res.noise) # physics-informed noise summary (if enabled)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Run it over the network (the real QPU path)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python -m dyber.server # reference control plane on 127.0.0.1:8787
|
|
39
|
+
```
|
|
40
|
+
```python
|
|
41
|
+
backend = dy.backend("remote", url="http://127.0.0.1:8787")
|
|
42
|
+
job = backend.run(c, shots=1000) # same protocol the hardware will use
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The `hcat_qpu` backend points at the production control plane and is offline until the
|
|
46
|
+
hardware exists. The moment it is online, `dy.backend("hcat_qpu").run(c)` runs on silicon.
|
|
47
|
+
|
|
48
|
+
## How it is layered
|
|
49
|
+
|
|
50
|
+
| Layer | Module | Role |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| Circuit | `circuit.py` | gate-model program you write |
|
|
53
|
+
| Lowering | `native.py` | maps gates to native H-cat ops (cat prep, hybrid fusion, parity readout); the real lowering is OpenForge |
|
|
54
|
+
| Simulator | `simulator.py` | exact statevector run, plus physics-informed noise from the resource model |
|
|
55
|
+
| Backends | `backend.py` | local simulator, remote (HTTP), and the hcat_qpu hardware backend, one interface |
|
|
56
|
+
| Protocol | `protocol.py` | the JSON job format shared by SDK and control plane |
|
|
57
|
+
| Control plane | `server.py` | reference server: today runs the simulator, later fronts the FPGA control system |
|
|
58
|
+
|
|
59
|
+
## Notes
|
|
60
|
+
|
|
61
|
+
- The simulator is exact for up to 14 qubits. Noise is a planning-grade estimate calibrated
|
|
62
|
+
to the validated H-cat loss and resource models, not a full physical simulation.
|
|
63
|
+
- Resource estimates use the v2 calibration (June 2026 circuit-level validation campaign):
|
|
64
|
+
corrected loss threshold 0.79 percent per cycle (0.898 percent uncorrected option), spec
|
|
65
|
+
operating point 0.5 percent per cycle (d=53, 5,617 cats per logical at 1e-9, 239.5
|
|
66
|
+
attempts per cat). At or above the threshold the resource report honestly returns the
|
|
67
|
+
above-threshold regime (no fault-tolerant distance) with a NISQ fallback estimate.
|
|
68
|
+
- Proprietary components (the OpenForge compiler passes, calibration, foundry recipes) are
|
|
69
|
+
not part of this SDK. The native lowering here is illustrative.
|
|
70
|
+
- Style: no em-dashes; commas, colons, periods, and hyphens for ranges.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Dyber SDK: interact with the H-cat photonic quantum computer.
|
|
3
|
+
|
|
4
|
+
Write a circuit once, run it on the local simulator today and on the H-cat QPU later,
|
|
5
|
+
unchanged. The simulator is physics-informed by the validated H-cat resource and loss
|
|
6
|
+
models.
|
|
7
|
+
|
|
8
|
+
from dyber import Dyber, Circuit
|
|
9
|
+
dy = Dyber()
|
|
10
|
+
c = Circuit(2); c.h(0); c.cx(0, 1); c.measure_all()
|
|
11
|
+
job = dy.backend("local_simulator").run(c, shots=1000)
|
|
12
|
+
print(job.result().counts())
|
|
13
|
+
"""
|
|
14
|
+
from .circuit import Circuit
|
|
15
|
+
from .result import Result, Job
|
|
16
|
+
from .provider import Dyber
|
|
17
|
+
|
|
18
|
+
__version__ = "0.1.0"
|
|
19
|
+
__all__ = ["Dyber", "Circuit", "Result", "Job", "__version__"]
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Dyber SDK backends. Same interface for the local simulator and the remote QPU."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
import json
|
|
4
|
+
import time
|
|
5
|
+
import urllib.request
|
|
6
|
+
import urllib.error
|
|
7
|
+
|
|
8
|
+
from . import simulator, native, protocol
|
|
9
|
+
from .circuit import Circuit
|
|
10
|
+
from .result import Result, Job
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Backend:
|
|
14
|
+
name = "backend"
|
|
15
|
+
online = True
|
|
16
|
+
def run(self, circuit, shots=1024, **options) -> Job:
|
|
17
|
+
raise NotImplementedError
|
|
18
|
+
def __repr__(self):
|
|
19
|
+
return f"<Backend {self.name!r} online={self.online}>"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class LocalSimulatorBackend(Backend):
|
|
23
|
+
name = "local_simulator"
|
|
24
|
+
online = True
|
|
25
|
+
|
|
26
|
+
def run(self, circuit, shots=1024, seed=None, **options):
|
|
27
|
+
rep = native.resource_report(
|
|
28
|
+
circuit,
|
|
29
|
+
loss_per_cycle=options.get("loss_per_cycle", 0.005),
|
|
30
|
+
target_logical_err=options.get("target_logical_err", 1e-9),
|
|
31
|
+
alpha=options.get("alpha", 2.0),
|
|
32
|
+
p_herald=options.get("p_herald"),
|
|
33
|
+
spatial=options.get("spatial", 16),
|
|
34
|
+
wavelength=options.get("wavelength", 32),
|
|
35
|
+
code=options.get("code", "surface"),
|
|
36
|
+
fault_tolerant=options.get("fault_tolerant", True),
|
|
37
|
+
corrected_threshold=options.get("corrected_threshold", True),
|
|
38
|
+
)
|
|
39
|
+
sim = simulator.run(
|
|
40
|
+
circuit, shots=shots, seed=seed,
|
|
41
|
+
loss_per_cycle=options.get("loss_per_cycle") if options.get("noise", True) else None,
|
|
42
|
+
resources=rep,
|
|
43
|
+
)
|
|
44
|
+
meta = {"resources": rep, "noise": sim["noise"],
|
|
45
|
+
"native": native.transpile(circuit)["summary"]}
|
|
46
|
+
res = Result(sim["counts"], shots, self.name, metadata=meta)
|
|
47
|
+
return Job(job_id="local-" + format(abs(hash((circuit.name, shots))) % 10**8, "08d"),
|
|
48
|
+
backend_name=self.name, result=res, status="completed")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class RemoteBackend(Backend):
|
|
52
|
+
"""Talks the job protocol over HTTP. Works against the reference control server
|
|
53
|
+
today and the real control plane later, unchanged."""
|
|
54
|
+
name = "remote"
|
|
55
|
+
|
|
56
|
+
def __init__(self, url, name=None, timeout=30):
|
|
57
|
+
self.url = url.rstrip("/")
|
|
58
|
+
self.timeout = timeout
|
|
59
|
+
if name:
|
|
60
|
+
self.name = name
|
|
61
|
+
self.online = self._ping()
|
|
62
|
+
|
|
63
|
+
def _ping(self):
|
|
64
|
+
try:
|
|
65
|
+
urllib.request.urlopen(self.url + "/health", timeout=3).read()
|
|
66
|
+
return True
|
|
67
|
+
except Exception:
|
|
68
|
+
return False
|
|
69
|
+
|
|
70
|
+
def _post(self, path, payload):
|
|
71
|
+
data = json.dumps(payload).encode()
|
|
72
|
+
req = urllib.request.Request(self.url + path, data=data,
|
|
73
|
+
headers={"Content-Type": "application/json"})
|
|
74
|
+
with urllib.request.urlopen(req, timeout=self.timeout) as r:
|
|
75
|
+
return json.loads(r.read())
|
|
76
|
+
|
|
77
|
+
def _get(self, path):
|
|
78
|
+
with urllib.request.urlopen(self.url + path, timeout=self.timeout) as r:
|
|
79
|
+
return json.loads(r.read())
|
|
80
|
+
|
|
81
|
+
def run(self, circuit, shots=1024, poll=0.3, **options):
|
|
82
|
+
if not self.online:
|
|
83
|
+
raise ConnectionError(
|
|
84
|
+
f"{self.name} is not reachable at {self.url}. The H-cat QPU is not yet "
|
|
85
|
+
"online. Use the 'local_simulator' backend, or start the reference control "
|
|
86
|
+
"server (python -m dyber.server) and point a backend at it.")
|
|
87
|
+
req = protocol.make_job_request(circuit, shots, options)
|
|
88
|
+
resp = self._post("/jobs", req)
|
|
89
|
+
job_id = resp["job_id"]
|
|
90
|
+
while resp.get("status") in ("queued", "running"):
|
|
91
|
+
time.sleep(poll)
|
|
92
|
+
resp = self._get(f"/jobs/{job_id}")
|
|
93
|
+
if resp.get("status") != "completed":
|
|
94
|
+
return Job(job_id, self.name, result=None, status=resp.get("status", "failed"))
|
|
95
|
+
payload = self._get(f"/jobs/{job_id}/result")["result"]
|
|
96
|
+
res = Result(payload["counts"], payload["shots"], self.name,
|
|
97
|
+
metadata={"resources": payload.get("resources"),
|
|
98
|
+
"noise": payload.get("noise"),
|
|
99
|
+
"native": payload.get("native")})
|
|
100
|
+
return Job(job_id, self.name, result=res, status="completed")
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class HCatQPUBackend(RemoteBackend):
|
|
104
|
+
"""The real H-cat machine, reached through the control plane. Offline until the
|
|
105
|
+
hardware exists; defaults to the production control-plane URL."""
|
|
106
|
+
name = "hcat_qpu"
|
|
107
|
+
def __init__(self, url="https://qpu.dyber.org", timeout=30):
|
|
108
|
+
super().__init__(url, name="hcat_qpu", timeout=timeout)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""Dyber SDK: the user-facing circuit model.
|
|
2
|
+
|
|
3
|
+
A small gate-model circuit you write once and run on any Dyber backend (local
|
|
4
|
+
simulator today, H-cat QPU later). Qubit 0 is the leftmost bit in result strings.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
_1Q = {"i", "x", "y", "z", "h", "s", "sdg", "t", "tdg"}
|
|
9
|
+
_1Q_PARAM = {"rx", "ry", "rz", "p"}
|
|
10
|
+
_2Q = {"cx", "cz", "swap"}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Circuit:
|
|
14
|
+
def __init__(self, num_qubits: int, name: str = "circuit"):
|
|
15
|
+
if num_qubits < 1:
|
|
16
|
+
raise ValueError("num_qubits must be >= 1")
|
|
17
|
+
self.num_qubits = int(num_qubits)
|
|
18
|
+
self.name = name
|
|
19
|
+
self.ops = [] # list of dicts: {gate, qubits, params}
|
|
20
|
+
self.measured = [] # ordered list of measured qubit indices
|
|
21
|
+
|
|
22
|
+
# ---- single-qubit gates ----
|
|
23
|
+
def _add1(self, g, q):
|
|
24
|
+
self._check(q)
|
|
25
|
+
self.ops.append({"gate": g, "qubits": [int(q)], "params": []})
|
|
26
|
+
return self
|
|
27
|
+
def i(self, q): return self._add1("i", q)
|
|
28
|
+
def x(self, q): return self._add1("x", q)
|
|
29
|
+
def y(self, q): return self._add1("y", q)
|
|
30
|
+
def z(self, q): return self._add1("z", q)
|
|
31
|
+
def h(self, q): return self._add1("h", q)
|
|
32
|
+
def s(self, q): return self._add1("s", q)
|
|
33
|
+
def sdg(self, q): return self._add1("sdg", q)
|
|
34
|
+
def t(self, q): return self._add1("t", q)
|
|
35
|
+
def tdg(self, q): return self._add1("tdg", q)
|
|
36
|
+
|
|
37
|
+
def _add1p(self, g, theta, q):
|
|
38
|
+
self._check(q)
|
|
39
|
+
self.ops.append({"gate": g, "qubits": [int(q)], "params": [float(theta)]})
|
|
40
|
+
return self
|
|
41
|
+
def rx(self, theta, q): return self._add1p("rx", theta, q)
|
|
42
|
+
def ry(self, theta, q): return self._add1p("ry", theta, q)
|
|
43
|
+
def rz(self, theta, q): return self._add1p("rz", theta, q)
|
|
44
|
+
def p(self, theta, q): return self._add1p("p", theta, q)
|
|
45
|
+
|
|
46
|
+
# ---- two-qubit gates ----
|
|
47
|
+
def _add2(self, g, a, b):
|
|
48
|
+
self._check(a); self._check(b)
|
|
49
|
+
if a == b:
|
|
50
|
+
raise ValueError("two-qubit gate needs distinct qubits")
|
|
51
|
+
self.ops.append({"gate": g, "qubits": [int(a), int(b)], "params": []})
|
|
52
|
+
return self
|
|
53
|
+
def cx(self, ctrl, tgt): return self._add2("cx", ctrl, tgt)
|
|
54
|
+
def cz(self, a, b): return self._add2("cz", a, b)
|
|
55
|
+
def swap(self, a, b): return self._add2("swap", a, b)
|
|
56
|
+
|
|
57
|
+
# ---- measurement ----
|
|
58
|
+
def measure(self, q):
|
|
59
|
+
self._check(q)
|
|
60
|
+
if q not in self.measured:
|
|
61
|
+
self.measured.append(int(q))
|
|
62
|
+
self.ops.append({"gate": "measure", "qubits": [int(q)], "params": []})
|
|
63
|
+
return self
|
|
64
|
+
def measure_all(self):
|
|
65
|
+
for q in range(self.num_qubits):
|
|
66
|
+
self.measure(q)
|
|
67
|
+
return self
|
|
68
|
+
|
|
69
|
+
def _check(self, q):
|
|
70
|
+
if not (0 <= q < self.num_qubits):
|
|
71
|
+
raise ValueError(f"qubit {q} out of range 0..{self.num_qubits-1}")
|
|
72
|
+
|
|
73
|
+
# ---- serialization (wire protocol) ----
|
|
74
|
+
def to_dict(self):
|
|
75
|
+
return {"num_qubits": self.num_qubits, "name": self.name,
|
|
76
|
+
"ops": self.ops, "measured": self.measured}
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def from_dict(cls, d):
|
|
80
|
+
c = cls(d["num_qubits"], d.get("name", "circuit"))
|
|
81
|
+
c.ops = list(d.get("ops", []))
|
|
82
|
+
c.measured = list(d.get("measured", []))
|
|
83
|
+
return c
|
|
84
|
+
|
|
85
|
+
def depth_2q(self):
|
|
86
|
+
return sum(1 for o in self.ops if o["gate"] in _2Q)
|
|
87
|
+
|
|
88
|
+
def __repr__(self):
|
|
89
|
+
return (f"Circuit(name={self.name!r}, qubits={self.num_qubits}, "
|
|
90
|
+
f"ops={len(self.ops)}, measured={self.measured})")
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"""Dyber SDK: lowering to native H-cat operations and the resource report.
|
|
2
|
+
|
|
3
|
+
transpile() maps a gate-model circuit onto native H-cat operations (cat preparation,
|
|
4
|
+
hybrid fusion, parity readout). On real hardware this lowering is performed by the
|
|
5
|
+
proprietary OpenForge back-end; here it is an illustrative mapping plus the resource
|
|
6
|
+
estimate, which also supplies the simulator's physics-informed noise rate.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
import math
|
|
10
|
+
|
|
11
|
+
# ---- v2 calibration constants ----
|
|
12
|
+
# Hardcoded so the SDK stays dependency-light.
|
|
13
|
+
#
|
|
14
|
+
# Circuit-level distance calibration:
|
|
15
|
+
# Lambda(gamma) = (p_th_circ / gamma)^1.61
|
|
16
|
+
# LER(d) = A_CIRC * Lambda^(-(d+1)/2)
|
|
17
|
+
P_TH_CIRC = 0.0079 # corrected circuit-level loss threshold per cycle
|
|
18
|
+
# (default; folds in the validated ~2.9x silent-Pauli
|
|
19
|
+
# digital-twin correction)
|
|
20
|
+
P_TH_CIRC_UNCORRECTED = 0.00898 # default-knob circuit-level threshold
|
|
21
|
+
# (bootstrap 95 percent CI 0.852-0.916 percent)
|
|
22
|
+
LAMBDA_EXP = 1.61 # margin-ladder fit exponent
|
|
23
|
+
A_CIRC = 0.30 # global prefactor, fit so the model reproduces the
|
|
24
|
+
# authoritative circuit-level points:
|
|
25
|
+
# d(1e-9) = 29 / 41 / 61 at gamma = 0.4 / 0.5 / 0.6
|
|
26
|
+
# percent with the uncorrected threshold
|
|
27
|
+
QLDPC_GAIN = 10.0
|
|
28
|
+
ALPHA0 = 1.0
|
|
29
|
+
|
|
30
|
+
# Cat production: heralded generation and breeding success, plus the multiplexing
|
|
31
|
+
# herald-collision tax at a 2 spatial x 8 wavelength architecture (231.5 -> 239.5):
|
|
32
|
+
P_GEN = 0.30
|
|
33
|
+
P_BREED = 0.24
|
|
34
|
+
MUX_ATTEMPT_FACTOR = 239.0 / 231.0
|
|
35
|
+
|
|
36
|
+
# Loss-split correction factors: exact channel measured on the bred-cat density
|
|
37
|
+
# matrix vs the Poisson closed form, ratio (measured / Poisson) for erase and pauli:
|
|
38
|
+
_SPLIT_GAMMA_GRID = (0.005, 0.010, 0.020, 0.030)
|
|
39
|
+
_SPLIT_F_ERASE = (0.9583507007766099, 0.9205203546179248,
|
|
40
|
+
0.854608265667542, 0.7994035470416974)
|
|
41
|
+
_SPLIT_F_PAULI = (3.0846032998386854, 2.919170374042666,
|
|
42
|
+
2.629331412714363, 2.384856621831815)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _split_correction(gamma):
|
|
46
|
+
"""Digital-twin correction factors (f_erase, f_pauli), linearly interpolated
|
|
47
|
+
on the measured grid gamma in [0.5, 3] percent and CLIPPED outside it
|
|
48
|
+
(constant extrapolation at the nearest measured point), exactly as the v2
|
|
49
|
+
resource model does. Below 0.5 percent the measured pauli ratio rises
|
|
50
|
+
monotonically (2.38 -> 3.08), so holding 3.08 flat is conservative."""
|
|
51
|
+
g = min(max(gamma, _SPLIT_GAMMA_GRID[0]), _SPLIT_GAMMA_GRID[-1])
|
|
52
|
+
for i in range(len(_SPLIT_GAMMA_GRID) - 1):
|
|
53
|
+
g0, g1 = _SPLIT_GAMMA_GRID[i], _SPLIT_GAMMA_GRID[i + 1]
|
|
54
|
+
if g <= g1:
|
|
55
|
+
t = (g - g0) / (g1 - g0)
|
|
56
|
+
f_e = _SPLIT_F_ERASE[i] + t * (_SPLIT_F_ERASE[i + 1] - _SPLIT_F_ERASE[i])
|
|
57
|
+
f_p = _SPLIT_F_PAULI[i] + t * (_SPLIT_F_PAULI[i + 1] - _SPLIT_F_PAULI[i])
|
|
58
|
+
return f_e, f_p
|
|
59
|
+
return _SPLIT_F_ERASE[-1], _SPLIT_F_PAULI[-1]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _loss_split(alpha, gamma):
|
|
63
|
+
"""Per-cycle loss -> (heralded erasure, unheralded Pauli), v2 calibrated:
|
|
64
|
+
Poisson closed form times the digital-twin correction factors."""
|
|
65
|
+
lam = alpha * alpha * gamma
|
|
66
|
+
p_e = max((1 - math.exp(-2 * lam)) / 2, 0.0) # heralded erasure
|
|
67
|
+
p_z = max((1 + math.exp(-2 * lam)) / 2 - math.exp(-lam), 0.0) # unheralded Pauli
|
|
68
|
+
f_e, f_p = _split_correction(gamma)
|
|
69
|
+
return p_e * f_e, p_z * f_p
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _rounds(alpha):
|
|
73
|
+
return max(0, math.ceil(2 * math.log2(alpha / ALPHA0)))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _distance(gamma, target_err, corrected_threshold=True):
|
|
77
|
+
"""v2 circuit-level distance: smallest odd d with
|
|
78
|
+
A_CIRC * Lambda^(-(d+1)/2) <= target, Lambda = (p_th_circ/gamma)^1.61.
|
|
79
|
+
Returns None at or above threshold (Lambda <= 1: increasing d makes the
|
|
80
|
+
logical error worse, as measured at gamma = 1 percent)."""
|
|
81
|
+
p_th = P_TH_CIRC if corrected_threshold else P_TH_CIRC_UNCORRECTED
|
|
82
|
+
lam = (p_th / gamma) ** LAMBDA_EXP
|
|
83
|
+
if lam <= 1.0:
|
|
84
|
+
return None
|
|
85
|
+
m = math.ceil(math.log(A_CIRC / target_err) / math.log(lam)) # = (d+1)/2
|
|
86
|
+
return max(3, 2 * m - 1)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def transpile(circuit):
|
|
90
|
+
"""Return a native H-cat program summary for the circuit."""
|
|
91
|
+
n = circuit.num_qubits
|
|
92
|
+
native = []
|
|
93
|
+
for q in range(n):
|
|
94
|
+
native.append({"op": "prepare_cat", "qubit": q})
|
|
95
|
+
fusions = 0
|
|
96
|
+
for op in circuit.ops:
|
|
97
|
+
g = op["gate"]
|
|
98
|
+
if g == "measure":
|
|
99
|
+
native.append({"op": "measure_parity", "qubit": op["qubits"][0]})
|
|
100
|
+
elif g in ("cx", "cz", "swap"):
|
|
101
|
+
native.append({"op": "hybrid_fusion", "qubits": op["qubits"]})
|
|
102
|
+
fusions += 1
|
|
103
|
+
else:
|
|
104
|
+
native.append({"op": "single_mode_op", "gate": g, "qubits": op["qubits"]})
|
|
105
|
+
summary = {"cat_preparations": n, "hybrid_fusions": fusions,
|
|
106
|
+
"parity_measurements": len(circuit.measured) or n,
|
|
107
|
+
"native_op_count": len(native)}
|
|
108
|
+
return {"native": native, "summary": summary}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def resource_report(circuit, loss_per_cycle=0.005, target_logical_err=1e-9,
|
|
112
|
+
alpha=2.0, p_herald=None, spatial=16, wavelength=32,
|
|
113
|
+
code="surface", fault_tolerant=True, corrected_threshold=True,
|
|
114
|
+
p_gen=P_GEN, p_breed=P_BREED):
|
|
115
|
+
"""Device-level resource estimate for running this circuit, plus the effective
|
|
116
|
+
error rate the simulator uses for physics-informed noise.
|
|
117
|
+
|
|
118
|
+
v2 calibrated. The default operating
|
|
119
|
+
point is the 0.5 percent per-cycle loss spec (d=53, 5,617 cats per logical at
|
|
120
|
+
1e-9 with the corrected 0.79 percent circuit-level threshold; pass
|
|
121
|
+
corrected_threshold=False for the uncorrected 0.898 percent calibration,
|
|
122
|
+
d=41 / 3,361). At 1 percent loss the model honestly reports the
|
|
123
|
+
above-threshold regime: no code distance reaches a fault-tolerant target,
|
|
124
|
+
and the NISQ / error-detected estimate is returned instead.
|
|
125
|
+
|
|
126
|
+
p_herald, if given, overrides both p_gen and p_breed (legacy single-knob
|
|
127
|
+
behavior). The mux herald-collision tax (239/231) is always applied.
|
|
128
|
+
"""
|
|
129
|
+
gamma = loss_per_cycle
|
|
130
|
+
p_e, p_z = _loss_split(alpha, gamma)
|
|
131
|
+
if p_herald is not None:
|
|
132
|
+
p_gen = p_breed = p_herald
|
|
133
|
+
att = (2.0 / p_breed) ** _rounds(alpha) / p_gen * MUX_ATTEMPT_FACTOR
|
|
134
|
+
|
|
135
|
+
rep = {"loss_per_cycle": gamma, "alpha": alpha, "p_erase": p_e, "p_pauli": p_z,
|
|
136
|
+
"attempts_per_cat": att, "breeding_rounds": _rounds(alpha),
|
|
137
|
+
"outer_code": code if fault_tolerant else "none"}
|
|
138
|
+
|
|
139
|
+
# ops touching each qubit (for NISQ noise accumulation)
|
|
140
|
+
nq = circuit.num_qubits
|
|
141
|
+
touch = [0] * nq
|
|
142
|
+
for op in circuit.ops:
|
|
143
|
+
if op["gate"] == "measure":
|
|
144
|
+
continue
|
|
145
|
+
for q in op["qubits"]:
|
|
146
|
+
touch[q] += 1
|
|
147
|
+
avg_ops = sum(touch) / max(nq, 1)
|
|
148
|
+
|
|
149
|
+
# NISQ / physical-regime error accumulation (also the honest fallback when
|
|
150
|
+
# the operating point is above the circuit-level threshold)
|
|
151
|
+
p_nisq = min(1.0 - (1.0 - p_z) ** max(avg_ops, 1), 0.5)
|
|
152
|
+
|
|
153
|
+
if not fault_tolerant or target_logical_err >= 0.01:
|
|
154
|
+
# NISQ / physical regime: unheralded Pauli accumulates over the circuit
|
|
155
|
+
rep.update({"regime": "nisq", "distance": 1, "cats_per_logical": 1,
|
|
156
|
+
"hw_modes_per_logical": spatial,
|
|
157
|
+
"logical_error_estimate": p_nisq})
|
|
158
|
+
else:
|
|
159
|
+
d = _distance(gamma, target_logical_err, corrected_threshold)
|
|
160
|
+
if d is None:
|
|
161
|
+
# Above the circuit-level threshold: no code distance reaches the
|
|
162
|
+
# target (increasing d makes the logical error worse). Report the
|
|
163
|
+
# NISQ / error-detected estimate so the simulator still has an
|
|
164
|
+
# honest physics-informed noise rate.
|
|
165
|
+
p_th = P_TH_CIRC if corrected_threshold else P_TH_CIRC_UNCORRECTED
|
|
166
|
+
rep.update({"regime": "above-threshold", "distance": None,
|
|
167
|
+
"cats_per_logical": None, "hw_modes_per_logical": None,
|
|
168
|
+
"logical_error_estimate": p_nisq,
|
|
169
|
+
"note": ("per-cycle loss exceeds the circuit-level "
|
|
170
|
+
"threshold ({:.3g} percent); no fault-tolerant "
|
|
171
|
+
"distance exists, NISQ / error-detected regime "
|
|
172
|
+
"reported instead").format(p_th * 100)})
|
|
173
|
+
else:
|
|
174
|
+
cpl = 2 * d * d - 1
|
|
175
|
+
hw = spatial * cpl
|
|
176
|
+
if code == "qldpc":
|
|
177
|
+
hw = max(1, round(hw / QLDPC_GAIN))
|
|
178
|
+
# below threshold: logical error is approximately the target
|
|
179
|
+
rep.update({"regime": "fault-tolerant", "distance": d,
|
|
180
|
+
"cats_per_logical": cpl, "hw_modes_per_logical": hw,
|
|
181
|
+
"logical_error_estimate": float(target_logical_err)})
|
|
182
|
+
rep["throughput_per_logical"] = att * (rep.get("cats_per_logical") or 1)
|
|
183
|
+
return rep
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Dyber QPU job protocol: the wire format shared by the SDK and the control plane.
|
|
2
|
+
|
|
3
|
+
A job is JSON. Today the control server executes it on the simulator; on hardware the
|
|
4
|
+
same JSON is consumed by the FPGA control system. Keeping one schema means the SDK does
|
|
5
|
+
not change when the backend becomes real silicon.
|
|
6
|
+
|
|
7
|
+
Job request (POST /jobs):
|
|
8
|
+
{
|
|
9
|
+
"program": <circuit.to_dict()>, # gate-model circuit
|
|
10
|
+
"shots": 1024,
|
|
11
|
+
"options": { "loss_per_cycle": 0.005, "target_logical_err": 1e-9,
|
|
12
|
+
"alpha": 2.0, "code": "surface", "fault_tolerant": true }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Job response (GET /jobs/{id} and /jobs/{id}/result):
|
|
16
|
+
{
|
|
17
|
+
"job_id": "...", "status": "queued|running|completed|failed",
|
|
18
|
+
"result": { "counts": {...}, "shots": N,
|
|
19
|
+
"resources": {...}, "noise": {...|null} }
|
|
20
|
+
}
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
PROTOCOL_VERSION = "1.0"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def make_job_request(circuit, shots, options=None):
|
|
28
|
+
return {"protocol": PROTOCOL_VERSION,
|
|
29
|
+
"program": circuit.to_dict(),
|
|
30
|
+
"shots": int(shots),
|
|
31
|
+
"options": dict(options or {})}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def make_result_payload(result):
|
|
35
|
+
return {"counts": result.counts(), "shots": result.shots,
|
|
36
|
+
"resources": result.metadata.get("resources"),
|
|
37
|
+
"noise": result.metadata.get("noise"),
|
|
38
|
+
"native": result.metadata.get("native")}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Dyber provider: the entry point. dy = Dyber(); dy.backend('local_simulator')."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from .backend import LocalSimulatorBackend, RemoteBackend, HCatQPUBackend
|
|
4
|
+
|
|
5
|
+
_BUILTIN = {"local_simulator", "hcat_qpu"}
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Dyber:
|
|
9
|
+
def __init__(self, token=None):
|
|
10
|
+
self.token = token
|
|
11
|
+
|
|
12
|
+
def backends(self):
|
|
13
|
+
sim = LocalSimulatorBackend()
|
|
14
|
+
try:
|
|
15
|
+
qpu = HCatQPUBackend()
|
|
16
|
+
qstatus = "online" if qpu.online else "offline (hardware not yet available)"
|
|
17
|
+
except Exception:
|
|
18
|
+
qstatus = "offline"
|
|
19
|
+
return [{"name": "local_simulator", "status": "online"},
|
|
20
|
+
{"name": "hcat_qpu", "status": qstatus}]
|
|
21
|
+
|
|
22
|
+
def backend(self, name="local_simulator", **kw):
|
|
23
|
+
if name == "local_simulator":
|
|
24
|
+
return LocalSimulatorBackend()
|
|
25
|
+
if name == "hcat_qpu":
|
|
26
|
+
return HCatQPUBackend(url=kw.get("url", "https://qpu.dyber.org"))
|
|
27
|
+
if name == "remote":
|
|
28
|
+
return RemoteBackend(url=kw["url"], name=kw.get("label"))
|
|
29
|
+
raise ValueError(f"unknown backend {name!r}; try 'local_simulator' or 'hcat_qpu'")
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Dyber SDK: Job and Result objects."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Result:
|
|
6
|
+
def __init__(self, counts, shots, backend, metadata=None):
|
|
7
|
+
self._counts = counts
|
|
8
|
+
self.shots = shots
|
|
9
|
+
self.backend = backend
|
|
10
|
+
self.metadata = metadata or {}
|
|
11
|
+
|
|
12
|
+
def counts(self):
|
|
13
|
+
return dict(self._counts)
|
|
14
|
+
|
|
15
|
+
get_counts = counts
|
|
16
|
+
|
|
17
|
+
def probabilities(self):
|
|
18
|
+
return {k: v / self.shots for k, v in self._counts.items()}
|
|
19
|
+
|
|
20
|
+
def most_frequent(self):
|
|
21
|
+
return max(self._counts, key=self._counts.get) if self._counts else None
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def resources(self):
|
|
25
|
+
return self.metadata.get("resources")
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def noise(self):
|
|
29
|
+
return self.metadata.get("noise")
|
|
30
|
+
|
|
31
|
+
def __repr__(self):
|
|
32
|
+
return f"Result(backend={self.backend!r}, shots={self.shots}, outcomes={len(self._counts)})"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Job:
|
|
36
|
+
"""Base job. Local jobs are completed on creation; remote jobs poll."""
|
|
37
|
+
def __init__(self, job_id, backend_name, result=None, status="completed"):
|
|
38
|
+
self.job_id = job_id
|
|
39
|
+
self.backend_name = backend_name
|
|
40
|
+
self._result = result
|
|
41
|
+
self._status = status
|
|
42
|
+
|
|
43
|
+
def status(self):
|
|
44
|
+
return self._status
|
|
45
|
+
|
|
46
|
+
def result(self):
|
|
47
|
+
return self._result
|
|
48
|
+
|
|
49
|
+
def __repr__(self):
|
|
50
|
+
return f"Job(id={self.job_id!r}, backend={self.backend_name!r}, status={self._status!r})"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Dyber reference control server.
|
|
2
|
+
|
|
3
|
+
A minimal control plane that speaks the job protocol over HTTP and executes jobs on the
|
|
4
|
+
local simulator. This is the stand-in for the real H-cat control system: when the FPGA
|
|
5
|
+
control plane exists, it implements these same endpoints and the SDK does not change.
|
|
6
|
+
|
|
7
|
+
Run: python -m dyber.server (listens on 127.0.0.1:8787)
|
|
8
|
+
Then: dy.backend("remote", url="http://127.0.0.1:8787").run(circuit)
|
|
9
|
+
|
|
10
|
+
Stdlib only, no external dependencies.
|
|
11
|
+
"""
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
import json
|
|
14
|
+
import uuid
|
|
15
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
16
|
+
|
|
17
|
+
from .circuit import Circuit
|
|
18
|
+
from .backend import LocalSimulatorBackend
|
|
19
|
+
from .protocol import make_result_payload
|
|
20
|
+
|
|
21
|
+
_JOBS = {} # job_id -> {"status":..., "result": payload}
|
|
22
|
+
_BACKEND = LocalSimulatorBackend()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _execute(req):
|
|
26
|
+
circ = Circuit.from_dict(req["program"])
|
|
27
|
+
job = _BACKEND.run(circ, shots=req.get("shots", 1024), **(req.get("options") or {}))
|
|
28
|
+
return make_result_payload(job.result())
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Handler(BaseHTTPRequestHandler):
|
|
32
|
+
def _send(self, code, obj):
|
|
33
|
+
body = json.dumps(obj).encode()
|
|
34
|
+
self.send_response(code)
|
|
35
|
+
self.send_header("Content-Type", "application/json")
|
|
36
|
+
self.send_header("Content-Length", str(len(body)))
|
|
37
|
+
self.end_headers()
|
|
38
|
+
self.wfile.write(body)
|
|
39
|
+
|
|
40
|
+
def do_GET(self):
|
|
41
|
+
if self.path == "/health":
|
|
42
|
+
return self._send(200, {"status": "ok", "engine": "local_simulator",
|
|
43
|
+
"note": "reference control plane; simulator backend"})
|
|
44
|
+
if self.path.startswith("/jobs/"):
|
|
45
|
+
parts = self.path.strip("/").split("/")
|
|
46
|
+
jid = parts[1]
|
|
47
|
+
job = _JOBS.get(jid)
|
|
48
|
+
if not job:
|
|
49
|
+
return self._send(404, {"error": "no such job"})
|
|
50
|
+
if len(parts) == 3 and parts[2] == "result":
|
|
51
|
+
return self._send(200, {"job_id": jid, "status": job["status"],
|
|
52
|
+
"result": job["result"]})
|
|
53
|
+
return self._send(200, {"job_id": jid, "status": job["status"]})
|
|
54
|
+
return self._send(404, {"error": "not found"})
|
|
55
|
+
|
|
56
|
+
def do_POST(self):
|
|
57
|
+
if self.path != "/jobs":
|
|
58
|
+
return self._send(404, {"error": "not found"})
|
|
59
|
+
n = int(self.headers.get("Content-Length", 0))
|
|
60
|
+
req = json.loads(self.rfile.read(n) or b"{}")
|
|
61
|
+
jid = uuid.uuid4().hex[:12]
|
|
62
|
+
try:
|
|
63
|
+
payload = _execute(req) # synchronous execution
|
|
64
|
+
_JOBS[jid] = {"status": "completed", "result": payload}
|
|
65
|
+
return self._send(200, {"job_id": jid, "status": "completed"})
|
|
66
|
+
except Exception as e:
|
|
67
|
+
_JOBS[jid] = {"status": "failed", "result": None}
|
|
68
|
+
return self._send(200, {"job_id": jid, "status": "failed", "error": str(e)})
|
|
69
|
+
|
|
70
|
+
def log_message(self, *a):
|
|
71
|
+
pass
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def serve(host="127.0.0.1", port=8787):
|
|
75
|
+
srv = ThreadingHTTPServer((host, port), Handler)
|
|
76
|
+
print(f"Dyber control plane (reference) on http://{host}:{port} [simulator engine]")
|
|
77
|
+
print("Endpoints: GET /health, POST /jobs, GET /jobs/{id}, GET /jobs/{id}/result")
|
|
78
|
+
try:
|
|
79
|
+
srv.serve_forever()
|
|
80
|
+
except KeyboardInterrupt:
|
|
81
|
+
srv.shutdown()
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
serve()
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Dyber SDK: local statevector simulator with optional physics-informed noise.
|
|
2
|
+
|
|
3
|
+
Exact for small circuits. The noise model is a planning-grade estimate: it takes the
|
|
4
|
+
effective logical error per qubit from the validated H-cat resource model and applies it
|
|
5
|
+
as output bit flips, and reports the heralded-erasure fraction. It is not a full physical
|
|
6
|
+
H-cat simulation (that lives in the research repo); it is enough to interact with circuits
|
|
7
|
+
and see realistic, loss-dependent results.
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
import numpy as np
|
|
11
|
+
|
|
12
|
+
I = np.array([[1, 0], [0, 1]], complex)
|
|
13
|
+
X = np.array([[0, 1], [1, 0]], complex)
|
|
14
|
+
Y = np.array([[0, -1j], [1j, 0]], complex)
|
|
15
|
+
Z = np.array([[1, 0], [0, -1]], complex)
|
|
16
|
+
H = np.array([[1, 1], [1, -1]], complex) / np.sqrt(2)
|
|
17
|
+
S = np.array([[1, 0], [0, 1j]], complex)
|
|
18
|
+
SDG = np.array([[1, 0], [0, -1j]], complex)
|
|
19
|
+
T = np.array([[1, 0], [0, np.exp(1j * np.pi / 4)]], complex)
|
|
20
|
+
TDG = np.array([[1, 0], [0, np.exp(-1j * np.pi / 4)]], complex)
|
|
21
|
+
P0 = np.array([[1, 0], [0, 0]], complex)
|
|
22
|
+
P1 = np.array([[0, 0], [0, 1]], complex)
|
|
23
|
+
_1Q = {"i": I, "x": X, "y": Y, "z": Z, "h": H, "s": S, "sdg": SDG, "t": T, "tdg": TDG}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _rot(g, th):
|
|
27
|
+
c, s = np.cos(th / 2), np.sin(th / 2)
|
|
28
|
+
if g == "rx": return np.array([[c, -1j * s], [-1j * s, c]], complex)
|
|
29
|
+
if g == "ry": return np.array([[c, -s], [s, c]], complex)
|
|
30
|
+
if g == "rz": return np.array([[np.exp(-1j * th / 2), 0], [0, np.exp(1j * th / 2)]], complex)
|
|
31
|
+
if g == "p": return np.array([[1, 0], [0, np.exp(1j * th)]], complex)
|
|
32
|
+
raise ValueError(g)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _op_on(n, factors):
|
|
36
|
+
"""Full 2^n operator: factors maps qubit index -> 2x2, default identity.
|
|
37
|
+
Qubit 0 is the most significant tensor factor."""
|
|
38
|
+
mats = [factors.get(q, I) for q in range(n)]
|
|
39
|
+
out = mats[0]
|
|
40
|
+
for m in mats[1:]:
|
|
41
|
+
out = np.kron(out, m)
|
|
42
|
+
return out
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _gate_matrix(n, op):
|
|
46
|
+
g, qs = op["gate"], op["qubits"]
|
|
47
|
+
if g in _1Q:
|
|
48
|
+
return _op_on(n, {qs[0]: _1Q[g]})
|
|
49
|
+
if g in ("rx", "ry", "rz", "p"):
|
|
50
|
+
return _op_on(n, {qs[0]: _rot(g, op["params"][0])})
|
|
51
|
+
if g == "cx":
|
|
52
|
+
c, t = qs
|
|
53
|
+
return _op_on(n, {c: P0}) + _op_on(n, {c: P1, t: X})
|
|
54
|
+
if g == "cz":
|
|
55
|
+
c, t = qs
|
|
56
|
+
return _op_on(n, {c: P0}) + _op_on(n, {c: P1, t: Z})
|
|
57
|
+
if g == "swap":
|
|
58
|
+
a, b = qs
|
|
59
|
+
lo_hi = np.array([[0, 1], [0, 0]], complex) # |0><1|
|
|
60
|
+
hi_lo = np.array([[0, 0], [1, 0]], complex) # |1><0|
|
|
61
|
+
return (_op_on(n, {a: P0, b: P0}) + _op_on(n, {a: P1, b: P1})
|
|
62
|
+
+ _op_on(n, {a: lo_hi, b: hi_lo}) + _op_on(n, {a: hi_lo, b: lo_hi}))
|
|
63
|
+
raise ValueError(f"unknown gate {g}")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def statevector(circuit):
|
|
67
|
+
n = circuit.num_qubits
|
|
68
|
+
if n > 14:
|
|
69
|
+
raise ValueError("local simulator supports up to 14 qubits")
|
|
70
|
+
psi = np.zeros(1 << n, complex); psi[0] = 1.0
|
|
71
|
+
for op in circuit.ops:
|
|
72
|
+
if op["gate"] == "measure":
|
|
73
|
+
continue
|
|
74
|
+
psi = _gate_matrix(n, op) @ psi
|
|
75
|
+
return psi
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _bits(idx, n):
|
|
79
|
+
return format(idx, "0" + str(n) + "b")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def run(circuit, shots=1024, seed=None, loss_per_cycle=None, resources=None):
|
|
83
|
+
"""Return a dict: counts, probabilities, and optional noise summary."""
|
|
84
|
+
rng = np.random.default_rng(seed)
|
|
85
|
+
n = circuit.num_qubits
|
|
86
|
+
psi = statevector(circuit)
|
|
87
|
+
probs = np.abs(psi) ** 2
|
|
88
|
+
probs = probs / probs.sum()
|
|
89
|
+
meas = circuit.measured if circuit.measured else list(range(n))
|
|
90
|
+
|
|
91
|
+
# sample full-register outcomes, then project onto measured qubits
|
|
92
|
+
draws = rng.choice(len(probs), size=shots, p=probs)
|
|
93
|
+
out_bits = []
|
|
94
|
+
for idx in draws:
|
|
95
|
+
full = _bits(int(idx), n)
|
|
96
|
+
out_bits.append("".join(full[q] for q in meas))
|
|
97
|
+
|
|
98
|
+
noise = None
|
|
99
|
+
if loss_per_cycle is not None and resources is not None:
|
|
100
|
+
# effective logical error per logical qubit for this operating point
|
|
101
|
+
p_log = resources.get("logical_error_estimate")
|
|
102
|
+
p_erase = resources.get("p_erase", 0.0)
|
|
103
|
+
if p_log:
|
|
104
|
+
flipped = []
|
|
105
|
+
for bs in out_bits:
|
|
106
|
+
b = list(bs)
|
|
107
|
+
for i in range(len(b)):
|
|
108
|
+
if rng.random() < p_log:
|
|
109
|
+
b[i] = "1" if b[i] == "0" else "0"
|
|
110
|
+
flipped.append("".join(b))
|
|
111
|
+
out_bits = flipped
|
|
112
|
+
# heralded-erasure shots (flagged, not discarded here)
|
|
113
|
+
erased = int(sum(1 for _ in range(shots) if rng.random() < p_erase))
|
|
114
|
+
noise = {"loss_per_cycle": loss_per_cycle,
|
|
115
|
+
"logical_error_per_qubit": p_log,
|
|
116
|
+
"heralded_erasure_fraction": round(erased / shots, 4)}
|
|
117
|
+
|
|
118
|
+
counts = {}
|
|
119
|
+
for bs in out_bits:
|
|
120
|
+
counts[bs] = counts.get(bs, 0) + 1
|
|
121
|
+
return {"counts": counts, "probabilities": {_bits(i, n): float(probs[i])
|
|
122
|
+
for i in range(len(probs)) if probs[i] > 1e-12},
|
|
123
|
+
"measured": meas, "noise": noise}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dyber
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Dyber SDK: interact with the H-cat photonic quantum computer (simulator now, QPU later)
|
|
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.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: numpy
|
|
16
|
+
Provides-Extra: physics
|
|
17
|
+
Requires-Dist: dyberforge; extra == "physics"
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest; extra == "dev"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# Dyber SDK
|
|
23
|
+
|
|
24
|
+
Interact with the H-cat photonic quantum computer. Write a circuit once and run it on the
|
|
25
|
+
local simulator today and on the H-cat QPU later, with no change to your code. This is the
|
|
26
|
+
control interface, designed so that when the hardware exists, only the backend transport
|
|
27
|
+
changes.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install numpy
|
|
33
|
+
pip install -e . # from sdk/
|
|
34
|
+
# optional: physics-grade resource and noise models
|
|
35
|
+
pip install -e ../forge/sdk # dyberforge
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Hello, H-cat
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from dyber import Dyber, Circuit
|
|
42
|
+
|
|
43
|
+
dy = Dyber()
|
|
44
|
+
print(dy.backends()) # local_simulator (online), hcat_qpu (offline)
|
|
45
|
+
|
|
46
|
+
c = Circuit(2, "bell")
|
|
47
|
+
c.h(0); c.cx(0, 1); c.measure_all()
|
|
48
|
+
|
|
49
|
+
job = dy.backend("local_simulator").run(c, shots=1000)
|
|
50
|
+
res = job.result()
|
|
51
|
+
print(res.counts()) # {'00': ~500, '11': ~500}
|
|
52
|
+
print(res.resources) # distance, cats per logical, hw modes per logical
|
|
53
|
+
print(res.noise) # physics-informed noise summary (if enabled)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Run it over the network (the real QPU path)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
python -m dyber.server # reference control plane on 127.0.0.1:8787
|
|
60
|
+
```
|
|
61
|
+
```python
|
|
62
|
+
backend = dy.backend("remote", url="http://127.0.0.1:8787")
|
|
63
|
+
job = backend.run(c, shots=1000) # same protocol the hardware will use
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The `hcat_qpu` backend points at the production control plane and is offline until the
|
|
67
|
+
hardware exists. The moment it is online, `dy.backend("hcat_qpu").run(c)` runs on silicon.
|
|
68
|
+
|
|
69
|
+
## How it is layered
|
|
70
|
+
|
|
71
|
+
| Layer | Module | Role |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| Circuit | `circuit.py` | gate-model program you write |
|
|
74
|
+
| Lowering | `native.py` | maps gates to native H-cat ops (cat prep, hybrid fusion, parity readout); the real lowering is OpenForge |
|
|
75
|
+
| Simulator | `simulator.py` | exact statevector run, plus physics-informed noise from the resource model |
|
|
76
|
+
| Backends | `backend.py` | local simulator, remote (HTTP), and the hcat_qpu hardware backend, one interface |
|
|
77
|
+
| Protocol | `protocol.py` | the JSON job format shared by SDK and control plane |
|
|
78
|
+
| Control plane | `server.py` | reference server: today runs the simulator, later fronts the FPGA control system |
|
|
79
|
+
|
|
80
|
+
## Notes
|
|
81
|
+
|
|
82
|
+
- The simulator is exact for up to 14 qubits. Noise is a planning-grade estimate calibrated
|
|
83
|
+
to the validated H-cat loss and resource models, not a full physical simulation.
|
|
84
|
+
- Resource estimates use the v2 calibration (June 2026 circuit-level validation campaign):
|
|
85
|
+
corrected loss threshold 0.79 percent per cycle (0.898 percent uncorrected option), spec
|
|
86
|
+
operating point 0.5 percent per cycle (d=53, 5,617 cats per logical at 1e-9, 239.5
|
|
87
|
+
attempts per cat). At or above the threshold the resource report honestly returns the
|
|
88
|
+
above-threshold regime (no fault-tolerant distance) with a NISQ fallback estimate.
|
|
89
|
+
- Proprietary components (the OpenForge compiler passes, calibration, foundry recipes) are
|
|
90
|
+
not part of this SDK. The native lowering here is illustrative.
|
|
91
|
+
- Style: no em-dashes; commas, colons, periods, and hyphens for ranges.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
dyber/__init__.py
|
|
5
|
+
dyber/backend.py
|
|
6
|
+
dyber/circuit.py
|
|
7
|
+
dyber/native.py
|
|
8
|
+
dyber/protocol.py
|
|
9
|
+
dyber/provider.py
|
|
10
|
+
dyber/result.py
|
|
11
|
+
dyber/server.py
|
|
12
|
+
dyber/simulator.py
|
|
13
|
+
dyber.egg-info/PKG-INFO
|
|
14
|
+
dyber.egg-info/SOURCES.txt
|
|
15
|
+
dyber.egg-info/dependency_links.txt
|
|
16
|
+
dyber.egg-info/entry_points.txt
|
|
17
|
+
dyber.egg-info/requires.txt
|
|
18
|
+
dyber.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dyber
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dyber"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Dyber SDK: interact with the H-cat photonic quantum computer (simulator now, QPU later)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "Apache-2.0" }
|
|
12
|
+
authors = [{ name = "Dyber, Inc." }]
|
|
13
|
+
dependencies = ["numpy"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"License :: OSI Approved :: Apache Software License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
# physics-grade noise and resource models from the research SDK
|
|
23
|
+
physics = ["dyberforge"]
|
|
24
|
+
dev = ["pytest"]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
dyber-server = "dyber.server:serve"
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://quantaforge.dyber.org"
|
|
31
|
+
|
|
32
|
+
[tool.setuptools]
|
|
33
|
+
packages = ["dyber"]
|
|
34
|
+
license-files = ["LICENSE"]
|
dyber-0.1.0/setup.cfg
ADDED