oraql-atoms 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.
@@ -0,0 +1,10 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ __marimo__/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ *.egg-info/
8
+ .DS_Store
9
+ third_party/papers/
10
+ docs/notes/*.bbl
@@ -0,0 +1,204 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 The oraql-stack Authors.
190
+
191
+ For a list of copyright holders, see the AUTHORS file at the root of
192
+ this repository.
193
+
194
+ Licensed under the Apache License, Version 2.0 (the "License");
195
+ you may not use this file except in compliance with the License.
196
+ You may obtain a copy of the License at
197
+
198
+ http://www.apache.org/licenses/LICENSE-2.0
199
+
200
+ Unless required by applicable law or agreed to in writing, software
201
+ distributed under the License is distributed on an "AS IS" BASIS,
202
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
203
+ See the License for the specific language governing permissions and
204
+ limitations under the License.
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.5
2
+ Name: oraql-atoms
3
+ Version: 0.1.0
4
+ Summary: Neutral-atom device profiles (L1) and pulse-level noise models with Pauli twirling (L2)
5
+ Project-URL: Repository, https://github.com/oraql-stack/oraql-stack
6
+ Project-URL: Documentation, https://github.com/oraql-stack/oraql-stack/blob/main/docs/modularity.md
7
+ Author: The oraql-stack Authors
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Scientific/Engineering :: Physics
14
+ Requires-Python: >=3.12
15
+ Requires-Dist: numpy>=2.2
16
+ Requires-Dist: scipy>=1.18
17
+ Provides-Extra: atomic-data
18
+ Requires-Dist: arc-alkali-rydberg-calculator>=3.10; extra == 'atomic-data'
19
+ Requires-Dist: pulser-core>=1.9; extra == 'atomic-data'
20
+ Description-Content-Type: text/markdown
21
+
22
+ # oraql-atoms
23
+
24
+ Neutral-atom device profiles (L1) and pulse-level noise models with Pauli twirling (L2).
25
+
26
+ L1: published device profiles with units and provenance (`oraql.physical`). L2: a four-level atom Lindblad model of the native gates, twirled to Pauli and loss channels, and calibration updates (`oraql.pulse`). Produces `PhysicalParameters` and `CalibrationRecord` documents.
27
+
28
+ Import as `oraql.physical, oraql.pulse`. Part of [oraql-stack](https://github.com/oraql-stack/oraql-stack), a layered software stack for neutral-atom quantum computers; the packages exchange only the contract documents of `oraql-contracts` and share one version. Apache-2.0.
@@ -0,0 +1,7 @@
1
+ # oraql-atoms
2
+
3
+ Neutral-atom device profiles (L1) and pulse-level noise models with Pauli twirling (L2).
4
+
5
+ L1: published device profiles with units and provenance (`oraql.physical`). L2: a four-level atom Lindblad model of the native gates, twirled to Pauli and loss channels, and calibration updates (`oraql.pulse`). Produces `PhysicalParameters` and `CalibrationRecord` documents.
6
+
7
+ Import as `oraql.physical, oraql.pulse`. Part of [oraql-stack](https://github.com/oraql-stack/oraql-stack), a layered software stack for neutral-atom quantum computers; the packages exchange only the contract documents of `oraql-contracts` and share one version. Apache-2.0.
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "oraql-atoms"
3
+ version = "0.1.0" # one version for every oraql package (docs/releasing.md)
4
+ description = "Neutral-atom device profiles (L1) and pulse-level noise models with Pauli twirling (L2)"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.12"
9
+ authors = [{ name = "The oraql-stack Authors" }]
10
+ classifiers = [
11
+ "Development Status :: 3 - Alpha",
12
+ "Intended Audience :: Science/Research",
13
+ "Programming Language :: Python :: 3",
14
+ "Topic :: Scientific/Engineering :: Physics",
15
+ ]
16
+ dependencies = [
17
+ "numpy>=2.2",
18
+ "scipy>=1.18",
19
+ ]
20
+
21
+ [project.optional-dependencies]
22
+ # only to regenerate oraql/physical/data/atomic_data.json
23
+ atomic-data = ["ARC-Alkali-Rydberg-Calculator>=3.10", "pulser-core>=1.9"]
24
+
25
+ [project.urls]
26
+ Repository = "https://github.com/oraql-stack/oraql-stack"
27
+ Documentation = "https://github.com/oraql-stack/oraql-stack/blob/main/docs/modularity.md"
28
+
29
+ [build-system]
30
+ requires = ["hatchling>=1.27"]
31
+ build-backend = "hatchling.build"
32
+
33
+ [tool.hatch.build.targets.wheel]
34
+ packages = ["src/oraql"] # PEP 420 namespace: no oraql/__init__.py
File without changes
@@ -0,0 +1,76 @@
1
+ """Atomic data from ARC (survey row 15) for the Rydberg and intermediate states of every L1 profile.
2
+
3
+ `python -m oraql.physical.atomic_data` writes oraql/physical/data/atomic_data.json (package data, read by oraql.physical.profiles for `computed` entries)
4
+ and design/atomic_data.log (ARC value next to the cited value). ARC is only needed to regenerate the JSON.
5
+ Sign convention: ARC returns C6 with V(R) = -C6/R^6; we store C6 with V(R) = +C6/R^6 (repulsive > 0).
6
+ """
7
+ from __future__ import annotations
8
+ import json
9
+ from importlib.resources import files
10
+
11
+ DATA = files("oraql.physical") / "data" / "atomic_data.json"
12
+
13
+ # state per profile: atom class, Rydberg (n, l, j, mj), intermediate (n, l, j), temperature
14
+ STATES = {
15
+ "Rb87_53S": dict(atom="Rubidium87", ryd=(53, 0, 0.5, 0.5), inter=(6, 1, 1.5), T=300.0),
16
+ "Cs133_69S": dict(atom="Caesium", ryd=(69, 0, 0.5, -0.5), inter=(7, 1, 0.5), T=300.0),
17
+ }
18
+
19
+ # cited value to compare with: (quantity, value, source)
20
+ CITED = {
21
+ "Rb87_53S": {"c6_ghz_um6": (28.8, "arXiv:2304.05420 p.10, derived from V(2 um) = 450 MHz"),
22
+ "rydberg_lifetime_us": (88.0, "arXiv:2304.05420 Ext. Data Fig. 3a, measured T1 minus 1013 scattering"),
23
+ "rydberg_lifetime_rad_us": (170.0, "arXiv:2304.05420 Ext. Data Fig. 3a, rescaled to n=53"),
24
+ "intermediate_lifetime_ns": (110.0, "arXiv:2304.05420 Ext. Data Fig. 3a, value used in simulation")},
25
+ "Cs133_69S": {"c6_ghz_um6": (10.3e-3 * 6 ** 6, "arXiv:2408.08288 p.5, derived from V = 10.3 MHz at 6 um")},
26
+ }
27
+
28
+
29
+ def compute() -> dict:
30
+ import arc
31
+ from arc import PairStateInteractions
32
+ out = {"arc_version": arc.__version__, "states": {}}
33
+ for key, s in STATES.items():
34
+ atom = getattr(arc, s["atom"])()
35
+ n, l, j, mj = s["ryd"]
36
+ ni, li, ji = s["inter"]
37
+ c6 = PairStateInteractions(atom, n, l, j, n, l, j, mj, mj).getC6perturbatively(0, 0, 5, 25e9)
38
+ d = {
39
+ "c6_ghz_um6": {"value": -float(c6), "method": f"ARC {arc.__version__} PairStateInteractions({s['atom']},{n},{l},{j},{n},{l},{j},{mj},{mj}).getC6perturbatively(0,0,5,25e9), sign flipped to V=+C6/r^6"},
40
+ "rydberg_lifetime_us": {"value": atom.getStateLifetime(n, l, j, temperature=s["T"], includeLevelsUpTo=n + 30) * 1e6,
41
+ "method": f"ARC {arc.__version__} {s['atom']}.getStateLifetime({n},{l},{j},temperature={s['T']:g},includeLevelsUpTo={n + 30})"},
42
+ "rydberg_lifetime_rad_us": {"value": atom.getStateLifetime(n, l, j, temperature=0) * 1e6,
43
+ "method": f"ARC {arc.__version__} {s['atom']}.getStateLifetime({n},{l},{j},temperature=0)"},
44
+ "intermediate_lifetime_ns": {"value": atom.getStateLifetime(ni, li, ji) * 1e9,
45
+ "method": f"ARC {arc.__version__} {s['atom']}.getStateLifetime({ni},{li},{ji})"},
46
+ }
47
+ out["states"][key] = d
48
+ out["pulser"] = pulser_c6(arc)
49
+ return out
50
+
51
+
52
+ def pulser_c6(arc) -> list[dict]:
53
+ """Pulser device C6 (interaction_coeff, rad/us um^6) against ARC for the same Rb nS state."""
54
+ try:
55
+ import importlib.metadata as md
56
+ from pulser.devices import AnalogDevice, DigitalAnalogDevice
57
+ from arc import PairStateInteractions
58
+ except ImportError:
59
+ return []
60
+ rows = []
61
+ for dev in (AnalogDevice, DigitalAnalogDevice):
62
+ n = dev.rydberg_level
63
+ c6_arc = -PairStateInteractions(arc.Rubidium87(), n, 0, 0.5, n, 0, 0.5, 0.5, 0.5).getC6perturbatively(0, 0, 5, 25e9)
64
+ c6_p = dev.interaction_coeff / (2 * 3.141592653589793) / 1e3 # rad/us um^6 -> GHz um^6
65
+ rows.append({"device": f"pulser-core {md.version('pulser-core')} {dev.name}", "n": n, "c6_pulser_ghz_um6": c6_p,
66
+ "c6_arc_ghz_um6": float(c6_arc), "min_atom_distance_um": dev.min_atom_distance})
67
+ return rows
68
+
69
+
70
+ def load() -> dict:
71
+ return json.loads(DATA.read_text())
72
+
73
+
74
+ def value(state: str, qty: str) -> tuple[float, str]:
75
+ e = load()["states"][state][qty]
76
+ return e["value"], e["method"]
@@ -0,0 +1,57 @@
1
+ {
2
+ "arc_version": "3.10.2",
3
+ "states": {
4
+ "Rb87_53S": {
5
+ "c6_ghz_um6": {
6
+ "value": 31.269203001890368,
7
+ "method": "ARC 3.10.2 PairStateInteractions(Rubidium87,53,0,0.5,53,0,0.5,0.5,0.5).getC6perturbatively(0,0,5,25e9), sign flipped to V=+C6/r^6"
8
+ },
9
+ "rydberg_lifetime_us": {
10
+ "value": 72.5936324889618,
11
+ "method": "ARC 3.10.2 Rubidium87.getStateLifetime(53,0,0.5,temperature=300,includeLevelsUpTo=83)"
12
+ },
13
+ "rydberg_lifetime_rad_us": {
14
+ "value": 155.04886242543142,
15
+ "method": "ARC 3.10.2 Rubidium87.getStateLifetime(53,0,0.5,temperature=0)"
16
+ },
17
+ "intermediate_lifetime_ns": {
18
+ "value": 118.14274517914511,
19
+ "method": "ARC 3.10.2 Rubidium87.getStateLifetime(6,1,1.5)"
20
+ }
21
+ },
22
+ "Cs133_69S": {
23
+ "c6_ghz_um6": {
24
+ "value": 538.0115284047206,
25
+ "method": "ARC 3.10.2 PairStateInteractions(Caesium,69,0,0.5,69,0,0.5,-0.5,-0.5).getC6perturbatively(0,0,5,25e9), sign flipped to V=+C6/r^6"
26
+ },
27
+ "rydberg_lifetime_us": {
28
+ "value": 134.3744320195675,
29
+ "method": "ARC 3.10.2 Caesium.getStateLifetime(69,0,0.5,temperature=300,includeLevelsUpTo=99)"
30
+ },
31
+ "rydberg_lifetime_rad_us": {
32
+ "value": 328.6203010400251,
33
+ "method": "ARC 3.10.2 Caesium.getStateLifetime(69,0,0.5,temperature=0)"
34
+ },
35
+ "intermediate_lifetime_ns": {
36
+ "value": 154.36819436296378,
37
+ "method": "ARC 3.10.2 Caesium.getStateLifetime(7,1,0.5)"
38
+ }
39
+ }
40
+ },
41
+ "pulser": [
42
+ {
43
+ "device": "pulser-core 1.9.1 AnalogDevice",
44
+ "n": 60,
45
+ "c6_pulser_ghz_um6": 137.78409798144378,
46
+ "c6_arc_ghz_um6": 138.88273417699025,
47
+ "min_atom_distance_um": 5
48
+ },
49
+ {
50
+ "device": "pulser-core 1.9.1 DigitalAnalogDevice",
51
+ "n": 70,
52
+ "c6_pulser_ghz_um6": 862.6450223912011,
53
+ "c6_arc_ghz_um6": 862.7244161203786,
54
+ "min_atom_distance_um": 4
55
+ }
56
+ ]
57
+ }
@@ -0,0 +1,213 @@
1
+ """L1 physical parameter store: named device profiles with units and provenance.
2
+
3
+ Profiles live in packages/oraql-atoms/src/oraql/physical/profiles/ (one module per published device). Every entry has a unit and a source in
4
+ {citation, computed, assumed, calibrated}. `load(profile)` returns an immutable `Params`; every function takes it as
5
+ `params` (None: the default profile, rb87_evered2023). There is no module state: a calibration update returns a new
6
+ `Params` (`Params.replace`, `oraql.pulse.calibration.apply_updates`).
7
+ `python -m oraql.physical.physical` checks every profile, prints the C6/r^6 evaluation and writes
8
+ packages/oraql-contracts/src/oraql/contracts/data/schemas/examples/PhysicalParameters_<profile>.json (the default also as PhysicalParameters_rb87.json).
9
+ """
10
+ from __future__ import annotations
11
+ import dataclasses, functools, json, math, hashlib
12
+ from oraql.physical.profiles._entry import P
13
+ from oraql.physical import profiles as _profiles
14
+
15
+ # names the twirl, calibration and scheduler read; every profile must define all of them
16
+ CORE = [
17
+ "hyperfine_splitting_mhz", "atom_mass_amu", "rydberg_n",
18
+ "c6_ghz_um6", "gate_spacing_um", "rabi_two_photon_mhz", "rabi_lower_mhz", "rabi_upper_mhz", "intermediate_detuning_ghz",
19
+ "t2_ground_us", "t2star_ground_us", "t1_ground_us", "t2star_rydberg_us", "rydberg_lifetime_us", "intermediate_lifetime_ns",
20
+ "rabi_rel_sigma", "laser_linewidth_khz",
21
+ "rydberg_branch_loss", "rydberg_branch_to_1", "rydberg_branch_to_0",
22
+ "intermediate_branch_loss", "intermediate_branch_to_1", "intermediate_branch_to_0", "leak_trapped_fraction", "leak_reads_one",
23
+ "rydberg_branch_bbr_fraction", "rydberg_ejection_us",
24
+ "trap_lifetime_s", "trap_depth_mk",
25
+ "atom_temperature_uk", "move_duration_us", "move_loss_prob", "move_heating_quanta", "move_heating_kappa", "reset_recools_motion", "feedforward_latency_us",
26
+ "position_sigma_um",
27
+ "global_pulse_duration_us", "local_pulse_duration_us", "single_qubit_depol_error", "raman_scattering_error",
28
+ "readout_duration_us", "readout_fidelity", "readout_flip_0to1", "readout_flip_1to0", "readout_loss_prob", "reset_error",
29
+ "local_imaging_dephasing", "cz_fidelity_measured",
30
+ ]
31
+ SOURCES = ("citation", "computed", "assumed", "calibrated")
32
+
33
+ PROFILES = {m.PROFILE_ID: m for m in _profiles.MODULES}
34
+ DEFAULT = _profiles.DEFAULT
35
+ TABLES = {pid: m.table() for pid, m in PROFILES.items()}
36
+
37
+
38
+
39
+ @dataclasses.dataclass(frozen=True, eq=False)
40
+ class Params:
41
+ """One profile's parameter entries. Immutable: `replace` and `calibrated` return new objects. Equal and hashable by
42
+ profile id and values, so it can key caches."""
43
+ profile_id: str
44
+ entries: tuple
45
+ species: str = ""
46
+
47
+ def __post_init__(self):
48
+ object.__setattr__(self, "_by", {p.name: p for p in self.entries})
49
+
50
+ def get(self, name: str) -> float:
51
+ return self._by[name].value
52
+
53
+ def entry(self, name: str) -> P:
54
+ return dataclasses.replace(self._by[name])
55
+
56
+ def replace(self, source: str | None = None, **values) -> "Params":
57
+ """Copy with `values` ({name: value}) changed; `source` also sets their source (e.g. "calibrated")."""
58
+ unknown = set(values) - set(self._by)
59
+ if unknown:
60
+ raise KeyError(f"not in profile {self.profile_id}: {sorted(unknown)}")
61
+ new = tuple(dataclasses.replace(p, value=values[p.name], **({"source": source} if source else {})) if p.name in values else p
62
+ for p in self.entries)
63
+ return Params(self.profile_id, new, self.species)
64
+
65
+ def key(self) -> tuple:
66
+ return (self.profile_id,) + tuple((p.name, p.value, p.source) for p in self.entries)
67
+
68
+ def __eq__(self, other):
69
+ return isinstance(other, Params) and self.key() == other.key()
70
+
71
+ def __hash__(self):
72
+ return hash(self.key())
73
+
74
+
75
+ @functools.cache
76
+ def _load(profile: str) -> Params:
77
+ return Params(profile, tuple(dataclasses.replace(p) for p in TABLES[profile]), PROFILES[profile].SPECIES)
78
+
79
+
80
+ DERIVED = ("blockade_radius_um",) # in PhysicalParameters documents, computed from the entries, never read back
81
+ ADDED = ("leak_trapped_fraction", "leak_reads_one", # CORE names added after 0.1.0; from_document fills them in
82
+ "rydberg_branch_bbr_fraction", "rydberg_ejection_us")
83
+
84
+
85
+ def from_document(doc: dict) -> Params:
86
+ """Parameters from a PhysicalParameters document (e.g. a lab's measured values under its own profile id). Every
87
+ CORE name must be present; derived entries are skipped. Validate the document against its schema first
88
+ (oraql.contracts.schema)."""
89
+ fields = {f.name for f in dataclasses.fields(P)}
90
+ entries = tuple(P(**{k: v for k, v in e.items() if k in fields}) for e in doc["parameters"] if e["name"] not in DERIVED)
91
+ have = {e.name for e in entries}
92
+ if any(n not in have for n in ADDED): # documents written before these names existed
93
+ base = next((pid for pid, m in PROFILES.items() if m.SPECIES == doc.get("species")), DEFAULT)
94
+ entries += tuple(dataclasses.replace(load(base).entry(n), source="assumed",
95
+ note=f"absent from the document; value of profile {base}")
96
+ for n in ADDED if n not in have)
97
+ missing = [n for n in CORE if n not in {e.name for e in entries}]
98
+ if missing:
99
+ raise KeyError(f"PhysicalParameters document {doc.get('profile_id')!r} lacks {missing}")
100
+ return Params(doc["profile_id"], entries, doc.get("species", ""))
101
+
102
+
103
+ def load(profile: str | None = None) -> Params:
104
+ """Parameters of `profile` (default DEFAULT)."""
105
+ return _load(profile or DEFAULT)
106
+
107
+
108
+ def resolve(params: Params | str | None) -> Params:
109
+ """`params` as a Params: None is the default profile, a string a profile id."""
110
+ return params if isinstance(params, Params) else load(params)
111
+
112
+
113
+ def get(name: str, params: Params | None = None) -> float:
114
+ return resolve(params).get(name)
115
+
116
+
117
+ # ---------------------------------------------------------------- derived quantities
118
+ def interaction_mhz(r_um: float, c6_ghz_um6: float | None = None, params: Params | None = None) -> float:
119
+ """V(r)/2pi = C6/2pi / r^6 in MHz (C6 given in GHz um^6)."""
120
+ c6 = get("c6_ghz_um6", params) if c6_ghz_um6 is None else c6_ghz_um6
121
+ return c6 * 1e3 / r_um ** 6
122
+
123
+
124
+ def blockade_radius_um(c6_ghz_um6: float | None = None, omega_mhz: float | None = None, params: Params | None = None) -> float:
125
+ """R_b = (C6/Omega)^(1/6), definition V(R_b) = Omega."""
126
+ c6 = get("c6_ghz_um6", params) if c6_ghz_um6 is None else c6_ghz_um6
127
+ om = get("rabi_two_photon_mhz", params) if omega_mhz is None else omega_mhz
128
+ return (c6 * 1e3 / om) ** (1 / 6)
129
+
130
+
131
+ def rates(params: Params | None = None) -> dict:
132
+ """Effective rates in 1/us derived from the profile (used by oraql.pulse.twirl)."""
133
+ get = resolve(params).get
134
+ d = {}
135
+ d["gamma_r"] = 1.0 / get("rydberg_lifetime_us")
136
+ d["gamma_phi_r"] = 1.0 / get("t2star_rydberg_us") # exponential stand-in for quasi-static noise
137
+ tau_e = get("intermediate_lifetime_ns") * 1e-3
138
+ D = get("intermediate_detuning_ghz") * 1e3
139
+ d["gamma_sc_1"] = (get("rabi_lower_mhz") / (2 * D)) ** 2 / tau_e # bright-state admixture x Gamma_e, 1/us
140
+ d["gamma_sc_r"] = (get("rabi_upper_mhz") / (2 * D)) ** 2 / tau_e
141
+ d["gamma_phi_g"] = 1.0 / get("t2_ground_us")
142
+ d["gamma_1_g"] = 1.0 / get("t1_ground_us")
143
+ d["gamma_laser"] = 2 * math.pi * get("laser_linewidth_khz") * 1e-3 # white frequency noise, FWHM -> |r> dephasing rate
144
+ d["omega_rad_us"] = 2 * math.pi * get("rabi_two_photon_mhz")
145
+ d["V_rad_us"] = 2 * math.pi * interaction_mhz(get("gate_spacing_um"), get("c6_ghz_um6"))
146
+ return d
147
+
148
+
149
+ def _entry(p: P) -> dict:
150
+ e = {"name": p.name, "value": p.value, "unit": p.unit, "source": p.source}
151
+ for k in ("citation", "method", "locator", "note"):
152
+ if getattr(p, k):
153
+ e[k] = getattr(p, k)
154
+ if p.valid_lo is not None: e["valid_lo"] = p.valid_lo
155
+ if p.valid_hi is not None: e["valid_hi"] = p.valid_hi
156
+ return e
157
+
158
+
159
+ def to_document(sites=None, params: Params | str | None = None) -> dict:
160
+ """The `PhysicalParameters` contract document of `params` (a Params, a profile id or None for the default)."""
161
+ pr = resolve(params)
162
+ s = pr.get("gate_spacing_um")
163
+ sites = sites or [{"id": 0, "x": 0.0, "y": 0.0, "zone": "entangling", "trap": "tweezer_array"},
164
+ {"id": 1, "x": s, "y": 0.0, "zone": "entangling", "trap": "tweezer_array"}]
165
+ ents = [_entry(p) for p in pr.entries]
166
+ rb = P("blockade_radius_um", round(blockade_radius_um(params=pr), 4), "um", "computed", note="derived, never stored: V(R_b) = Omega",
167
+ valid_lo=1, valid_hi=20, method="oraql.physical.physical.blockade_radius_um: (C6/Omega)^(1/6)")
168
+ ents.append(_entry(rb))
169
+ return {"schema_version": "0.1.0", "profile_id": pr.profile_id, "species": pr.species or (PROFILES[pr.profile_id].SPECIES if pr.profile_id in PROFILES else ""), "sites": sites, "parameters": ents}
170
+
171
+
172
+ def doc_hash(doc: dict) -> str:
173
+ return hashlib.sha256(json.dumps(doc, sort_keys=True).encode()).hexdigest()
174
+
175
+
176
+ def counts(profile: str | None = None) -> dict:
177
+ t = TABLES[profile or DEFAULT]
178
+ return {s: sum(p.source == s for p in t) for s in SOURCES} | {"entries": len(t)}
179
+
180
+
181
+ def markdown_table(profile: str | None = None) -> str:
182
+ """One row per entry of to_document(), including the derived blockade radius."""
183
+ rows = ["| Name | Value | Unit | Source | Citation or method, locator, note |", "|---|---|---|---|---|"]
184
+ for e in to_document(params=profile)["parameters"]:
185
+ ref = e.get("citation", "") if e["source"] == "citation" else e.get("method", "")
186
+ loc = f" ({e['locator']})" if e.get("locator") else ""
187
+ c = (ref + loc + (". " if ref and e.get("note") else "") + e.get("note", "")).replace("|", "/")
188
+ rows.append(f"| `{e['name']}` | {e['value']:g} | {e['unit']} | {e['source']} | {c} |")
189
+ return "\n".join(rows)
190
+
191
+
192
+ def check(profile: str) -> list[str]:
193
+ """Rule checks for one profile; returns failure messages (empty = pass)."""
194
+ bad = []
195
+ t = TABLES[profile]
196
+ names = [p.name for p in t]
197
+ bad += [f"missing core name {n}" for n in CORE if n not in names]
198
+ bad += [f"unexpected name {n}" for n in names if n not in CORE]
199
+ bad += [f"duplicate name {n}" for n in set(names) if names.count(n) > 1]
200
+ for p in t:
201
+ if not p.unit: bad.append(f"{p.name}: no unit")
202
+ if p.source not in SOURCES: bad.append(f"{p.name}: source {p.source}")
203
+ if p.source == "citation" and not p.citation: bad.append(f"{p.name}: citation missing")
204
+ if p.source == "computed" and not p.method: bad.append(f"{p.name}: method missing")
205
+ if p.source == "assumed" and not p.note: bad.append(f"{p.name}: assumed without a reason")
206
+ if p.valid_lo is not None and not (p.valid_lo <= p.value <= p.valid_hi): bad.append(f"{p.name}: {p.value} outside [{p.valid_lo}, {p.valid_hi}]")
207
+ get = load(profile).get
208
+ for pre in ("rydberg", "intermediate"):
209
+ s = sum(get(f"{pre}_branch_{k}") for k in ("loss", "to_1", "to_0"))
210
+ if abs(s - 1) > 1e-3: bad.append(f"{pre} branching sums to {s}")
211
+ f = get("readout_fidelity"); fl = get("readout_flip_0to1") + get("readout_flip_1to0")
212
+ if abs((1 - f) - fl) > 1e-6: bad.append(f"readout flips {fl} != 1 - F = {1 - f}")
213
+ return bad
@@ -0,0 +1,5 @@
1
+ """Named L1 device profiles. Each module defines PROFILE_ID, SPECIES, TITLE, REFERENCES and table()."""
2
+ from oraql.physical.profiles import rb87_evered2023, rb87_bluvstein2024, cs133_radnaev2024
3
+
4
+ MODULES = [rb87_evered2023, rb87_bluvstein2024, cs133_radnaev2024]
5
+ DEFAULT = rb87_evered2023.PROFILE_ID