oracq 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. oracq/__init__.py +240 -0
  2. oracq/__main__.py +212 -0
  3. oracq/_compat.py +127 -0
  4. oracq/algorithms/__init__.py +1 -0
  5. oracq/algorithms/basics/__init__.py +1 -0
  6. oracq/algorithms/basics/number_theory.py +131 -0
  7. oracq/algorithms/basics/oracle_algorithms.py +169 -0
  8. oracq/algorithms/common/__init__.py +1 -0
  9. oracq/algorithms/common/arithmetic.py +768 -0
  10. oracq/algorithms/common/estimation.py +203 -0
  11. oracq/algorithms/common/fourier.py +85 -0
  12. oracq/algorithms/common/hamiltonian.py +438 -0
  13. oracq/algorithms/common/integration.py +343 -0
  14. oracq/algorithms/common/prepare_select.py +459 -0
  15. oracq/algorithms/common/qsvt.py +836 -0
  16. oracq/algorithms/common/search.py +170 -0
  17. oracq/algorithms/common/spectral_synthesis.py +225 -0
  18. oracq/algorithms/common/state_preparation.py +118 -0
  19. oracq/algorithms/common/transforms.py +107 -0
  20. oracq/algorithms/common/walks.py +37 -0
  21. oracq/algorithms/input_model/__init__.py +1 -0
  22. oracq/algorithms/input_model/block_encoding.py +299 -0
  23. oracq/algorithms/input_model/contracts.py +664 -0
  24. oracq/algorithms/input_model/data_loading.py +295 -0
  25. oracq/algorithms/input_model/density.py +810 -0
  26. oracq/algorithms/input_model/graph_walks.py +505 -0
  27. oracq/algorithms/input_model/interfaces.py +289 -0
  28. oracq/algorithms/input_model/lowrank.py +501 -0
  29. oracq/algorithms/input_model/operators.py +296 -0
  30. oracq/algorithms/input_model/oracles.py +1070 -0
  31. oracq/algorithms/input_model/qdata.py +454 -0
  32. oracq/algorithms/input_model/qham.py +706 -0
  33. oracq/algorithms/input_model/sparse.py +437 -0
  34. oracq/algorithms/input_model/spectral.py +324 -0
  35. oracq/algorithms/optimization/__init__.py +1 -0
  36. oracq/algorithms/optimization/dqi.py +370 -0
  37. oracq/algorithms/optimization/gradient.py +351 -0
  38. oracq/algorithms/optimization/variational.py +165 -0
  39. oracq/algorithms/qec/__init__.py +1 -0
  40. oracq/algorithms/qec/error_correction.py +62 -0
  41. oracq/algorithms/qlss/__init__.py +1 -0
  42. oracq/algorithms/qlss/qlss.py +1068 -0
  43. oracq/algorithms/qlss/vtaa_cks.py +598 -0
  44. oracq/algorithms/qml/__init__.py +1 -0
  45. oracq/algorithms/qml/qcnn.py +312 -0
  46. oracq/algorithms/qml/qcnn_layer.py +436 -0
  47. oracq/algorithms/qml/qpca.py +230 -0
  48. oracq/algorithms/qml/qsdp.py +396 -0
  49. oracq/algorithms/qml/recommendation.py +244 -0
  50. oracq/algorithms/qnlss/__init__.py +1 -0
  51. oracq/algorithms/qnlss/carleman.py +277 -0
  52. oracq/algorithms/qnlss/newton.py +443 -0
  53. oracq/algorithms/qode/__init__.py +1 -0
  54. oracq/algorithms/qode/_dynamics.py +84 -0
  55. oracq/algorithms/qode/cbmd.py +187 -0
  56. oracq/algorithms/qode/lchs.py +114 -0
  57. oracq/algorithms/qode/legacy.py +94 -0
  58. oracq/algorithms/qode/ode.py +344 -0
  59. oracq/algorithms/qode/ode_models.py +72 -0
  60. oracq/algorithms/qode/schrodingerization.py +169 -0
  61. oracq/algorithms/qode/sde.py +420 -0
  62. oracq/algorithms/qpde/__init__.py +1 -0
  63. oracq/algorithms/qpde/pde.py +85 -0
  64. oracq/applications/__init__.py +3 -0
  65. oracq/applications/catalog.py +606 -0
  66. oracq/applications/flow_data.py +316 -0
  67. oracq/applications/gallery.py +191 -0
  68. oracq/applications/legacy.py +399 -0
  69. oracq/applications/oracle_study.py +68 -0
  70. oracq/applications/qfvm.py +676 -0
  71. oracq/applications/qfvm_qmem.py +352 -0
  72. oracq/applications/qham/__init__.py +108 -0
  73. oracq/applications/qham/__main__.py +58 -0
  74. oracq/applications/qham/examples.py +51 -0
  75. oracq/applications/qham/linearization.py +517 -0
  76. oracq/applications/qham/pde.py +558 -0
  77. oracq/applications/qham/reference.py +739 -0
  78. oracq/applications/qham/report.py +180 -0
  79. oracq/applications/qham/stencils.py +420 -0
  80. oracq/applications/roe.py +283 -0
  81. oracq/applications/roe_formulas.py +163 -0
  82. oracq/infrastructure/__init__.py +1 -0
  83. oracq/infrastructure/backends/__init__.py +18 -0
  84. oracq/infrastructure/backends/basis.py +194 -0
  85. oracq/infrastructure/backends/originir.py +432 -0
  86. oracq/infrastructure/backends/pysparq.py +280 -0
  87. oracq/infrastructure/backends/quantikz.py +378 -0
  88. oracq/infrastructure/backends/strict.py +155 -0
  89. oracq/infrastructure/builder.py +431 -0
  90. oracq/infrastructure/estimate.py +593 -0
  91. oracq/infrastructure/execution.py +568 -0
  92. oracq/infrastructure/ir.py +367 -0
  93. oracq/infrastructure/layout.py +36 -0
  94. oracq/infrastructure/linking.py +518 -0
  95. oracq/infrastructure/mathfunc/__init__.py +96 -0
  96. oracq/infrastructure/mathfunc/frontend.py +874 -0
  97. oracq/infrastructure/mathfunc/graph.py +362 -0
  98. oracq/infrastructure/mathfunc/lowering.py +244 -0
  99. oracq/infrastructure/mathfunc/numeric.py +776 -0
  100. oracq/infrastructure/native.py +223 -0
  101. oracq/infrastructure/qmem.py +348 -0
  102. oracq/infrastructure/qram_schema.py +182 -0
  103. oracq/infrastructure/readout.py +66 -0
  104. oracq/infrastructure/serialization.py +250 -0
  105. oracq/infrastructure/validation.py +383 -0
  106. oracq/py.typed +0 -0
  107. oracq/qham/__init__.py +3 -0
  108. oracq/qham/__main__.py +6 -0
  109. oracq-0.1.0.dist-info/METADATA +201 -0
  110. oracq-0.1.0.dist-info/RECORD +114 -0
  111. oracq-0.1.0.dist-info/WHEEL +5 -0
  112. oracq-0.1.0.dist-info/entry_points.txt +2 -0
  113. oracq-0.1.0.dist-info/licenses/LICENSE +21 -0
  114. oracq-0.1.0.dist-info/top_level.txt +1 -0
oracq/__init__.py ADDED
@@ -0,0 +1,240 @@
1
+ "oracq: Python generators and a modular register-level IR."
2
+
3
+ from oracq.algorithms.common.arithmetic import (
4
+ FixedFormat,
5
+ arithmetic_native_registry,
6
+ fixed_arithmetic,
7
+ )
8
+ from oracq.algorithms.input_model.contracts import (
9
+ AlgorithmContract,
10
+ ContractError,
11
+ ContractIssue,
12
+ ContractReport,
13
+ InputRequirement,
14
+ OracleCapabilities,
15
+ OracleSpec,
16
+ ProtocolContract,
17
+ ResolvedInputs,
18
+ describe_oracle,
19
+ requires,
20
+ )
21
+ from oracq.algorithms.input_model.operators import (
22
+ BlockEncoding,
23
+ Generator,
24
+ block_encoding,
25
+ identity,
26
+ linear_combination,
27
+ pauli_x,
28
+ product,
29
+ scale,
30
+ zero,
31
+ )
32
+ from oracq.algorithms.input_model.oracles import declare
33
+ from oracq.algorithms.input_model.qdata import QMatrix, QVector
34
+ from oracq.algorithms.qlss.qlss import (
35
+ BlockSystem,
36
+ LinearSystem,
37
+ QLSSProtocol,
38
+ QLSSSolver,
39
+ SolveResult,
40
+ SparseSystem,
41
+ SpectralPromise,
42
+ )
43
+ from oracq.algorithms.qml.recommendation import (
44
+ KPRecommendationConfig,
45
+ RecommendationResult,
46
+ kp_recommendation,
47
+ sigma_from_phase,
48
+ )
49
+ from oracq.algorithms.qode.ode import QODEProblem, QODEProtocol, QODESolver
50
+ from oracq.infrastructure.backends import (
51
+ OriginIRArtifact,
52
+ StrictArtifact,
53
+ export_originir,
54
+ export_strict,
55
+ quantikz,
56
+ run_originir,
57
+ )
58
+ from oracq.infrastructure.backends.basis import export_toffoli_u3_cz
59
+ from oracq.infrastructure.backends.pysparq import run_pysparq, run_pysparq_rir
60
+ from oracq.infrastructure.builder import Builder, Operation
61
+ from oracq.infrastructure.estimate import (
62
+ OracleCall,
63
+ ResourceEstimate,
64
+ RotationCounts,
65
+ estimate_resources,
66
+ )
67
+ from oracq.infrastructure.execution import RegisterState, simulate
68
+ from oracq.infrastructure.ir import (
69
+ QRAM,
70
+ VERSION,
71
+ Adjoint,
72
+ Bits,
73
+ Call,
74
+ Control,
75
+ Load,
76
+ Module,
77
+ Primitive,
78
+ Program,
79
+ Rational,
80
+ Ref,
81
+ Register,
82
+ RegType,
83
+ Repeat,
84
+ Resource,
85
+ SInt,
86
+ Span,
87
+ Store,
88
+ UInt,
89
+ ValidationError,
90
+ fuse,
91
+ )
92
+ from oracq.infrastructure.linking import (
93
+ Binding,
94
+ BindingError,
95
+ BindingReport,
96
+ BindingResult,
97
+ OracleRequirement,
98
+ bind,
99
+ bind_with_report,
100
+ capabilities,
101
+ unresolved,
102
+ )
103
+ from oracq.infrastructure.mathfunc import (
104
+ CompiledFunction,
105
+ FunctionCompileError,
106
+ Index,
107
+ MathConfig,
108
+ MathProgram,
109
+ compile_function,
110
+ lower_math_ir,
111
+ )
112
+ from oracq.infrastructure.native import DynamicCppFactory, NativeRegistry
113
+ from oracq.infrastructure.qmem import QMem, QPtr
114
+ from oracq.infrastructure.qram_schema import dump_qram_yaml, load_qram_yaml
115
+ from oracq.infrastructure.serialization import dumps, loads
116
+ from oracq.infrastructure.validation import validate
117
+
118
+ from ._compat import install as _install_compatibility
119
+
120
+ __all__ = [
121
+ "VERSION",
122
+ "Adjoint",
123
+ "Bits",
124
+ "BlockEncoding",
125
+ "Builder",
126
+ "Call",
127
+ "Control",
128
+ "Generator",
129
+ "Load",
130
+ "Module",
131
+ "Operation",
132
+ "OriginIRArtifact",
133
+ "QMem",
134
+ "QPtr",
135
+ "ResourceEstimate",
136
+ "StrictArtifact",
137
+ "Primitive",
138
+ "Program",
139
+ "QRAM",
140
+ "Rational",
141
+ "Ref",
142
+ "Register",
143
+ "RegisterState",
144
+ "RegType",
145
+ "Repeat",
146
+ "Resource",
147
+ "SInt",
148
+ "Span",
149
+ "Store",
150
+ "UInt",
151
+ "ValidationError",
152
+ "block_encoding",
153
+ "dump_qram_yaml",
154
+ "dumps",
155
+ "estimate_resources",
156
+ "export_originir",
157
+ "export_strict",
158
+ "fuse",
159
+ "identity",
160
+ "linear_combination",
161
+ "load_qram_yaml",
162
+ "loads",
163
+ "pauli_x",
164
+ "product",
165
+ "quantikz",
166
+ "run_originir",
167
+ "run_pysparq",
168
+ "run_pysparq_rir",
169
+ "scale",
170
+ "simulate",
171
+ "validate",
172
+ "zero",
173
+ ]
174
+
175
+
176
+ __all__ += ["Binding", "OracleRequirement", "bind", "capabilities", "declare", "unresolved"]
177
+ __all__ += ["BindingError", "BindingReport", "BindingResult", "bind_with_report", "OracleCall", "RotationCounts"]
178
+
179
+
180
+ __all__ += [
181
+ "FixedFormat",
182
+ "arithmetic_native_registry",
183
+ "fixed_arithmetic",
184
+ "export_toffoli_u3_cz",
185
+ "DynamicCppFactory",
186
+ "NativeRegistry",
187
+ ]
188
+
189
+ __all__ += [
190
+ "CompiledFunction",
191
+ "FunctionCompileError",
192
+ "Index",
193
+ "MathConfig",
194
+ "MathProgram",
195
+ "compile_function",
196
+ "lower_math_ir",
197
+ ]
198
+
199
+ __all__ += [
200
+ "BlockSystem",
201
+ "LinearSystem",
202
+ "QLSSProtocol",
203
+ "SolveResult",
204
+ "SparseSystem",
205
+ "SpectralPromise",
206
+ ]
207
+
208
+ __all__ += [
209
+ "AlgorithmContract",
210
+ "ResolvedInputs",
211
+ "QLSSSolver",
212
+ "QODESolver",
213
+ "ContractError",
214
+ "ContractIssue",
215
+ "ContractReport",
216
+ "InputRequirement",
217
+ "OracleCapabilities",
218
+ "OracleSpec",
219
+ "ProtocolContract",
220
+ "describe_oracle",
221
+ "QODEProblem",
222
+ "QODEProtocol",
223
+ ]
224
+
225
+
226
+ __all__ += ["QMatrix", "QVector"]
227
+
228
+
229
+ __all__ += [
230
+ "KPRecommendationConfig",
231
+ "RecommendationResult",
232
+ "kp_recommendation",
233
+ "sigma_from_phase",
234
+ ]
235
+
236
+ __all__ += ["requires"]
237
+
238
+
239
+ _install_compatibility()
240
+ del _install_compatibility
oracq/__main__.py ADDED
@@ -0,0 +1,212 @@
1
+ "Validation, backend export and small-scale execution of serialized RIR."
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ from dataclasses import asdict
8
+ from pathlib import Path
9
+
10
+ from oracq import (
11
+ Binding,
12
+ Operation,
13
+ RegisterState,
14
+ bind_with_report,
15
+ describe_oracle,
16
+ dumps,
17
+ estimate_resources,
18
+ export_originir,
19
+ load_qram_yaml,
20
+ loads,
21
+ run_originir,
22
+ run_pysparq,
23
+ simulate,
24
+ unresolved,
25
+ )
26
+
27
+
28
+ def main() -> None:
29
+ """Command-line entry point: validate, inspect, canonicalize, export or execute serialized RIR per subcommand.
30
+
31
+ Subcommands include validate, inspect, canonicalize, emit, run, requirements,
32
+ bind and compile-function; input and value errors are uniformly reported
33
+ through ``parser.exit`` with exit code 2.
34
+ """
35
+ parser = argparse.ArgumentParser(prog="oracq")
36
+ parser.add_argument(
37
+ "command",
38
+ choices=[
39
+ "validate",
40
+ "inspect",
41
+ "canonicalize",
42
+ "emit",
43
+ "run",
44
+ "requirements",
45
+ "bind",
46
+ "compile-function",
47
+ "estimate",
48
+ ],
49
+ )
50
+ parser.add_argument("input", type=Path)
51
+ parser.add_argument("-o", "--output", type=Path)
52
+ parser.add_argument("--format", choices=["yaml", "json"], default="yaml", help="RIR output text format")
53
+ parser.add_argument("--memory", type=Path)
54
+ parser.add_argument("--bindings", type=Path)
55
+ parser.add_argument("--report", type=Path, help="JSON path for the binding diagnostic report")
56
+ parser.add_argument("--allow-open", action="store_true", help="keep the call ledger of unimplemented oracles in resource analysis")
57
+ parser.add_argument(
58
+ "--backend", choices=["reference", "originir", "pysparq"], default="reference"
59
+ )
60
+ parser.add_argument("--basis", choices=["default", "toffoli-u3-cz"], default="default")
61
+ parser.add_argument("--native-arithmetic", action="store_true")
62
+ parser.add_argument("--native-cache", default="out/native-cache")
63
+ parser.add_argument("--function")
64
+ parser.add_argument("--width", type=int, default=12)
65
+ parser.add_argument("--fraction", type=int, default=6)
66
+ parser.add_argument("--degree", type=int, default=6)
67
+ parser.add_argument("--constants", default="{}", help="JSON object of generation-time constants")
68
+ parser.add_argument("--inputs", help="JSON object of input types")
69
+ parser.add_argument("--mir-output", type=Path)
70
+ args = parser.parse_args()
71
+ try:
72
+ if args.command == "compile-function":
73
+ from oracq.algorithms.common.arithmetic import FixedFormat
74
+ from oracq.infrastructure.mathfunc import Index, MathConfig, compile_function
75
+
76
+ inputs = json.loads(args.inputs) if args.inputs else None
77
+ if inputs is not None and not isinstance(inputs, dict):
78
+ raise ValueError("--inputs must be a JSON object")
79
+ if inputs is not None:
80
+ if any(isinstance(v, dict) and set(v) != {"index"} for v in inputs.values()):
81
+ raise ValueError("index types require an index bit width")
82
+ inputs = {
83
+ k: Index(v["index"]) if isinstance(v, dict) else v for k, v in inputs.items()
84
+ }
85
+ constants = json.loads(args.constants)
86
+ if not isinstance(constants, dict):
87
+ raise ValueError("--constants must be a JSON object")
88
+ compiled = compile_function(
89
+ args.input.read_text(),
90
+ entry=args.function,
91
+ fmt=FixedFormat(args.width, args.fraction),
92
+ config=MathConfig(degree=args.degree),
93
+ constants=constants,
94
+ inputs=inputs,
95
+ )
96
+ if args.mir_output:
97
+ args.mir_output.write_text(compiled.math_ir.dumps())
98
+ if args.output:
99
+ args.output.write_text(dumps(compiled.program(), format=args.format))
100
+ else:
101
+ print(dumps(compiled.program(), format=args.format), end="")
102
+ return
103
+ program = loads(args.input.read_text())
104
+ if args.command == "inspect":
105
+ result = (
106
+ json.dumps(
107
+ describe_oracle(Operation.from_program(program)).to_dict(),
108
+ ensure_ascii=False,
109
+ indent=2,
110
+ )
111
+ + "\n"
112
+ )
113
+ elif args.command == "validate":
114
+ missing = unresolved(program)
115
+ # state is a status description string in the validate branch and the final execution state in the run branch.
116
+ state: str | RegisterState = (
117
+ f"open ({len(missing)} unresolved oracles)" if missing else "closed"
118
+ )
119
+ result = f"RIR {program.version}: {len(program.modules)} modules; valid; {state}\n"
120
+ elif args.command == "requirements":
121
+ result = (
122
+ json.dumps(
123
+ [asdict(item) for item in unresolved(program)], ensure_ascii=False, indent=2
124
+ )
125
+ + "\n"
126
+ )
127
+ elif args.command == "bind":
128
+ if args.bindings is None:
129
+ raise ValueError("bind requires a --bindings JSON manifest")
130
+ manifest = json.loads(args.bindings.read_text())
131
+ bindings: dict[str, Binding | Operation] = {}
132
+ for name, item in manifest.items():
133
+ path = args.bindings.parent / item["program"]
134
+ implementation = loads(path.read_text())
135
+ op = Operation(
136
+ implementation.main,
137
+ tuple(m for m in implementation.modules if m.name != implementation.entry),
138
+ )
139
+ bindings[name] = Binding(op, item.get("resources", {}))
140
+ linked = bind_with_report(program, bindings)
141
+ if args.report:
142
+ args.report.write_text(json.dumps(linked.report.to_dict(), ensure_ascii=False, indent=2) + "\n")
143
+ result = dumps(linked.require(), format=args.format)
144
+ elif args.command == "estimate":
145
+ result = json.dumps(
146
+ estimate_resources(program, require_closed=not args.allow_open).to_dict(),
147
+ ensure_ascii=False, indent=2,
148
+ ) + "\n"
149
+ elif args.command == "canonicalize":
150
+ result = dumps(program, format=args.format)
151
+ elif args.command == "emit":
152
+ from oracq.infrastructure.backends.basis import export_toffoli_u3_cz
153
+
154
+ exporter = export_toffoli_u3_cz if args.basis == "toffoli-u3-cz" else export_originir
155
+ result = exporter(program).text
156
+ else:
157
+ memory = load_qram_yaml(args.memory) if args.memory else None
158
+ if args.backend == "originir":
159
+ vector = run_originir(program, memory)
160
+ amplitudes = {
161
+ str(i): [complex(v).real, complex(v).imag]
162
+ for i, v in enumerate(vector)
163
+ if abs(v) > 1e-14
164
+ }
165
+ result = (
166
+ json.dumps(
167
+ {"basis": "qubit_index_lsb_first", "amplitudes": amplitudes}, indent=2
168
+ )
169
+ + "\n"
170
+ )
171
+ else:
172
+ runner = simulate if args.backend == "reference" else run_pysparq
173
+ options: dict[str, object]
174
+ report: dict[str, int | list[str] | str]
175
+ options, report = {}, {}
176
+ if args.native_arithmetic:
177
+ if args.backend != "pysparq":
178
+ raise ValueError("--native-arithmetic requires --backend pysparq")
179
+ from oracq.algorithms.common.arithmetic import arithmetic_native_registry
180
+
181
+ options = {
182
+ "native_registry": arithmetic_native_registry(
183
+ program, cache_dir=args.native_cache
184
+ ),
185
+ "report": report,
186
+ }
187
+ # runner is chosen dynamically by backend; **options is a heterogeneous keyword pack that cannot be statically verified.
188
+ state = runner(program, memory, **options) # type: ignore[arg-type]
189
+ result = (
190
+ json.dumps(
191
+ {
192
+ "execution": report,
193
+ "registers": [r.name for r in state.registers],
194
+ "amplitudes": [
195
+ {"values": list(key), "real": value.real, "imag": value.imag}
196
+ for key, value in sorted(state.amplitudes.items())
197
+ ],
198
+ },
199
+ indent=2,
200
+ )
201
+ + "\n"
202
+ )
203
+ if args.output:
204
+ args.output.write_text(result)
205
+ else:
206
+ print(result, end="")
207
+ except (ValueError, OSError) as exc:
208
+ parser.exit(2, f"oracq: {exc}\n")
209
+
210
+
211
+ if __name__ == "__main__":
212
+ main()
oracq/_compat.py ADDED
@@ -0,0 +1,127 @@
1
+ "Central compatibility table for 0.7 import paths; in-repo code uses only the canonical paths."
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import sys
7
+ from types import ModuleType
8
+
9
+ ALIASES = {
10
+ "oracq.ir": "oracq.infrastructure.ir",
11
+ "oracq.builder": "oracq.infrastructure.builder",
12
+ "oracq.validation": "oracq.infrastructure.validation",
13
+ "oracq.serialization": "oracq.infrastructure.serialization",
14
+ "oracq.linking": "oracq.infrastructure.linking",
15
+ "oracq.execution": "oracq.infrastructure.execution",
16
+ "oracq.native": "oracq.infrastructure.native",
17
+ "oracq.layout": "oracq.infrastructure.layout",
18
+ "oracq.readout": "oracq.infrastructure.readout",
19
+ "oracq.backends.originir": "oracq.infrastructure.backends.originir",
20
+ "oracq.backends": "oracq.infrastructure.backends",
21
+ "oracq.backends.pysparq": "oracq.infrastructure.backends.pysparq",
22
+ "oracq.backends.basis": "oracq.infrastructure.backends.basis",
23
+ "oracq.mathfunc.graph": "oracq.infrastructure.mathfunc.graph",
24
+ "oracq.mathfunc.frontend": "oracq.infrastructure.mathfunc.frontend",
25
+ "oracq.mathfunc.numeric": "oracq.infrastructure.mathfunc.numeric",
26
+ "oracq.mathfunc.lowering": "oracq.infrastructure.mathfunc.lowering",
27
+ "oracq.mathfunc": "oracq.infrastructure.mathfunc",
28
+ "oracq.mathfunc.roe_formulas": "oracq.applications.roe_formulas",
29
+ "oracq.library": "oracq.algorithms.input_model.operators",
30
+ "oracq.combinators": "oracq.algorithms.input_model.block_encoding",
31
+ "oracq.contracts": "oracq.algorithms.input_model.contracts",
32
+ "oracq.oracles": "oracq.algorithms.input_model.oracles",
33
+ "oracq.arithmetic": "oracq.algorithms.common.arithmetic",
34
+ "oracq.sparse_models": "oracq.algorithms.input_model.sparse",
35
+ "oracq.access": "oracq.algorithms.input_model.sparse",
36
+ "oracq.qlss": "oracq.algorithms.qlss.qlss",
37
+ "oracq.algorithms.costa": "oracq.algorithms.qlss.qlss",
38
+ "oracq.algorithms.cks": "oracq.algorithms.qlss.qlss",
39
+ "oracq.qode": "oracq.algorithms.qode.ode",
40
+ "oracq.qfvm": "oracq.applications.qfvm",
41
+ "oracq.qfvm_sparse": "oracq.applications.qfvm",
42
+ "oracq.flow_data": "oracq.applications.flow_data",
43
+ "oracq.roe": "oracq.applications.roe",
44
+ "oracq.workloads": "oracq.applications.catalog",
45
+ "oracq.qham.pde": "oracq.applications.qham.pde",
46
+ "oracq.qham.linearization": "oracq.applications.qham.linearization",
47
+ "oracq.qham.reference": "oracq.applications.qham.reference",
48
+ "oracq.qham.quantum": "oracq.algorithms.input_model.qham",
49
+ "oracq.qham.examples": "oracq.applications.qham.examples",
50
+ "oracq.qham.report": "oracq.applications.qham.report",
51
+ "oracq.qham.stencils": "oracq.applications.qham.stencils",
52
+ }
53
+ SPLIT_EXPORTS = {
54
+ "oracq.algorithms.elementary": {
55
+ "deutsch_jozsa": ("oracq.algorithms.basics.oracle_algorithms", "deutsch_jozsa"),
56
+ "grover": ("oracq.algorithms.common.search", "grover"),
57
+ "phase_from_database": ("oracq.algorithms.common.search", "phase_from_database"),
58
+ "qft": ("oracq.algorithms.common.fourier", "qft"),
59
+ "phase_estimation": ("oracq.algorithms.common.estimation", "phase_estimation"),
60
+ "qubitization_walk": ("oracq.algorithms.common.transforms", "qubitization_walk"),
61
+ "qsvt_sequence": ("oracq.algorithms.common.transforms", "qsvt_sequence"),
62
+ "oblivious_amplification": ("oracq.algorithms.common.transforms", "oblivious_amplification"),
63
+ },
64
+ "oracq.algorithms.differential": {
65
+ "tagged": ("oracq.algorithms.qode._dynamics", "tagged"),
66
+ "_lcu_dynamics": ("oracq.algorithms.qode._dynamics", "_lcu_dynamics"),
67
+ "HermitianParts": ("oracq.algorithms.qode.ode_models", "HermitianParts"),
68
+ "LinearODE": ("oracq.algorithms.qode.ode_models", "LinearODE"),
69
+ "QuadraturePlan": ("oracq.algorithms.qode.lchs", "QuadraturePlan"),
70
+ "lchs_qode": ("oracq.algorithms.qode.lchs", "lchs_qode"),
71
+ "ContourPlan": ("oracq.algorithms.qode.cbmd", "ContourPlan"),
72
+ "cbmd_qode": ("oracq.algorithms.qode.cbmd", "cbmd_qode"),
73
+ "cbmd_function": ("oracq.algorithms.qode.cbmd", "cbmd_function"),
74
+ "taylor_hamiltonian": ("oracq.algorithms.common.hamiltonian", "taylor_hamiltonian"),
75
+ "qft": ("oracq.algorithms.common.fourier", "qft_with_work"),
76
+ "fourier_momentum": ("oracq.algorithms.qode.schrodingerization", "fourier_momentum"),
77
+ "SchrodingerPlan": ("oracq.algorithms.qode.schrodingerization", "SchrodingerPlan"),
78
+ "schrodinger_qode": ("oracq.algorithms.qode.schrodingerization", "schrodinger_qode"),
79
+ "PolynomialODE": ("oracq.algorithms.qnlss.carleman", "PolynomialODE"),
80
+ "_carleman_term": ("oracq.algorithms.qnlss.carleman", "_carleman_term"),
81
+ "carleman_lift": ("oracq.algorithms.qnlss.carleman", "carleman_lift"),
82
+ "carleman_initial": ("oracq.algorithms.qnlss.carleman", "carleman_initial"),
83
+ "carleman_qode": ("oracq.algorithms.qnlss.carleman", "carleman_qode"),
84
+ "linear_qode": ("oracq.algorithms.qode.ode", "linear_qode"),
85
+ "PDEInput": ("oracq.algorithms.qpde.pde", "PDEInput"),
86
+ "qpde_solver": ("oracq.algorithms.qpde.pde", "qpde_solver"),
87
+ },
88
+ "oracq.algorithms.solvers": {
89
+ "extend_initial": ("oracq.algorithms.common.state_preparation", "extend_initial"),
90
+ "select_subspace": ("oracq.algorithms.common.state_preparation", "select_subspace"),
91
+ "apply_be_to_state": ("oracq.algorithms.common.state_preparation", "apply_be_to_state"),
92
+ "make_euler_history_qode": ("oracq.algorithms.qode.ode", "make_euler_history_qode"),
93
+ "DiscretePDE": ("oracq.algorithms.qpde.pde", "DiscretePDE"),
94
+ "make_qpde": ("oracq.algorithms.qpde.pde", "make_qpde"),
95
+ "make_lchs_qode": ("oracq.algorithms.qode.legacy", "make_lchs_qode"),
96
+ "make_schrodingerisation_qode": (
97
+ "oracq.algorithms.qode.legacy",
98
+ "make_schrodingerisation_qode",
99
+ ),
100
+ "trotter_hamsim": ("oracq.algorithms.common.hamiltonian", "trotter_hamsim"),
101
+ },
102
+ }
103
+
104
+
105
+ def install() -> None:
106
+ """Install the legacy 0.7 import paths as canonical modules and attach them to their parent packages.
107
+
108
+ Legacy paths in ``ALIASES`` directly reuse the corresponding canonical module
109
+ objects; legacy packages in ``SPLIT_EXPORTS`` are synthesized as forwarding
110
+ modules from their canonical owner modules per the export manifest.
111
+ """
112
+ for old, new in ALIASES.items():
113
+ module = importlib.import_module(new)
114
+ sys.modules[old] = module
115
+ for old, exports in SPLIT_EXPORTS.items():
116
+ module = ModuleType(old)
117
+ module.__package__ = old.rpartition(".")[0]
118
+ for name, (owner, symbol) in exports.items():
119
+ setattr(module, name, getattr(importlib.import_module(owner), symbol))
120
+ # typeshed does not declare __all__ as assignable on ModuleType; dynamically synthesized modules need it.
121
+ module.__all__ = [n for n in exports if not n.startswith("_")] # type: ignore[attr-defined]
122
+ sys.modules[old] = module
123
+ for old in (*ALIASES, *SPLIT_EXPORTS):
124
+ parent, _, leaf = old.rpartition(".")
125
+ # owner is bound to module path strings in the unpacking loop above and carries module objects here.
126
+ owner = sys.modules.get(parent) or importlib.import_module(parent) # type: ignore[assignment]
127
+ setattr(owner, leaf, sys.modules[old])
@@ -0,0 +1 @@
1
+ "Algorithm generators organized into ten categories: input_model, common, qlss, qnlss, qode, qpde, qml, optimization, basics, and qec."
@@ -0,0 +1 @@
1
+ "Basic example algorithms: query algorithms (Deutsch–Jozsa, Bernstein–Vazirani, Simon) and number theory (quantum order finding)."