classiq 0.54.0__py3-none-any.whl → 0.55.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.
- classiq/interface/_version.py +1 -1
- classiq/interface/generator/functions/builtins/internal_operators.py +9 -1
- classiq/interface/generator/generated_circuit_data.py +0 -1
- classiq/interface/generator/model/preferences/preferences.py +4 -0
- classiq/interface/generator/types/compilation_metadata.py +5 -0
- classiq/interface/ide/visual_model.py +3 -1
- classiq/interface/model/control.py +22 -1
- classiq/interface/model/model.py +4 -0
- classiq/interface/model/native_function_definition.py +1 -1
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +2 -26
- classiq/interface/model/quantum_statement.py +3 -0
- classiq/model_expansions/closure.py +74 -11
- classiq/model_expansions/function_builder.py +0 -6
- classiq/model_expansions/generative_functions.py +2 -2
- classiq/model_expansions/interpreter.py +22 -25
- classiq/model_expansions/quantum_operations/control.py +79 -20
- classiq/model_expansions/quantum_operations/emitter.py +24 -8
- classiq/model_expansions/quantum_operations/expression_operation.py +25 -1
- classiq/model_expansions/quantum_operations/quantum_assignment_operation.py +3 -26
- classiq/model_expansions/quantum_operations/quantum_function_call.py +2 -32
- classiq/model_expansions/quantum_operations/within_apply.py +0 -16
- classiq/model_expansions/scope_initialization.py +0 -1
- classiq/qmod/builtins/operations.py +113 -17
- classiq/qmod/create_model_function.py +10 -12
- classiq/qmod/model_state_container.py +5 -1
- classiq/qmod/native/pretty_printer.py +6 -1
- classiq/qmod/pretty_print/pretty_printer.py +25 -11
- classiq/qmod/quantum_function.py +25 -19
- classiq/qmod/synthesize_separately.py +1 -2
- {classiq-0.54.0.dist-info → classiq-0.55.0.dist-info}/METADATA +1 -1
- {classiq-0.54.0.dist-info → classiq-0.55.0.dist-info}/RECORD +32 -32
- classiq/model_expansions/call_to_model_converter.py +0 -190
- {classiq-0.54.0.dist-info → classiq-0.55.0.dist-info}/WHEEL +0 -0
classiq/qmod/quantum_function.py
CHANGED
@@ -9,9 +9,9 @@ from classiq.interface.exceptions import ClassiqError
|
|
9
9
|
from classiq.interface.executor.execution_preferences import ExecutionPreferences
|
10
10
|
from classiq.interface.generator.model.constraints import Constraints
|
11
11
|
from classiq.interface.generator.model.preferences.preferences import Preferences
|
12
|
+
from classiq.interface.generator.types.compilation_metadata import CompilationMetadata
|
12
13
|
from classiq.interface.model.model import Model
|
13
14
|
from classiq.interface.model.native_function_definition import (
|
14
|
-
FunctionSynthesisData,
|
15
15
|
NativeFunctionDefinition,
|
16
16
|
)
|
17
17
|
from classiq.interface.model.quantum_function_declaration import (
|
@@ -35,7 +35,7 @@ class QFunc(QExpandable):
|
|
35
35
|
_validate_no_gen_params(py_callable.__annotations__)
|
36
36
|
super().__init__(py_callable)
|
37
37
|
functools.update_wrapper(self, py_callable)
|
38
|
-
self.
|
38
|
+
self.compilation_metadata: Optional[CompilationMetadata] = None
|
39
39
|
|
40
40
|
@property
|
41
41
|
def func_decl(self) -> NamedParamsQuantumFunctionDeclaration:
|
@@ -45,12 +45,19 @@ class QFunc(QExpandable):
|
|
45
45
|
)
|
46
46
|
|
47
47
|
@property
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
def should_synthesize_separately(self) -> bool:
|
49
|
+
if self.compilation_metadata is None:
|
50
|
+
return False
|
51
|
+
return self.compilation_metadata.should_synthesize_separately
|
52
|
+
|
53
|
+
@should_synthesize_separately.setter
|
54
|
+
def should_synthesize_separately(self, value: bool) -> None:
|
55
|
+
if self.compilation_metadata is None:
|
56
|
+
self.compilation_metadata = CompilationMetadata(
|
57
|
+
should_synthesize_separately=value
|
58
|
+
)
|
59
|
+
else:
|
60
|
+
self.compilation_metadata.should_synthesize_separately = value
|
54
61
|
|
55
62
|
def __call__(self, *args: Any, **kwargs: Any) -> None:
|
56
63
|
super().__call__(*args, **kwargs)
|
@@ -62,12 +69,16 @@ class QFunc(QExpandable):
|
|
62
69
|
execution_preferences: Optional[ExecutionPreferences] = None,
|
63
70
|
preferences: Optional[Preferences] = None,
|
64
71
|
classical_execution_function: Optional[CFunc] = None,
|
72
|
+
functions_compilation_metadata: Optional[dict[str, CompilationMetadata]] = None,
|
65
73
|
) -> Model:
|
74
|
+
if functions_compilation_metadata is None:
|
75
|
+
functions_compilation_metadata = dict()
|
66
76
|
self._qmodule.enum_decls = dict()
|
67
77
|
self._qmodule.type_decls = dict()
|
68
78
|
self._qmodule.qstruct_decls = dict()
|
69
79
|
self._qmodule.native_defs = dict()
|
70
80
|
self._qmodule.constants = dict()
|
81
|
+
self._qmodule.functions_compilation_metadata = functions_compilation_metadata
|
71
82
|
QConstant.set_current_model(self._qmodule)
|
72
83
|
self.expand()
|
73
84
|
model_extra_settings: list[tuple[str, Any]] = [
|
@@ -86,6 +97,7 @@ class QFunc(QExpandable):
|
|
86
97
|
enums=list(self._qmodule.enum_decls.values()),
|
87
98
|
types=list(self._qmodule.type_decls.values()),
|
88
99
|
qstructs=list(self._qmodule.qstruct_decls.values()),
|
100
|
+
functions_compilation_metadata=self._qmodule.functions_compilation_metadata,
|
89
101
|
**{key: value for key, value in model_extra_settings if value},
|
90
102
|
)
|
91
103
|
|
@@ -94,18 +106,12 @@ class QFunc(QExpandable):
|
|
94
106
|
return
|
95
107
|
super().expand()
|
96
108
|
self._qmodule.native_defs[self.func_decl.name] = NativeFunctionDefinition(
|
97
|
-
**{
|
98
|
-
**self.func_decl.model_dump(),
|
99
|
-
**{
|
100
|
-
"body": self.body,
|
101
|
-
"synthesis_data": (
|
102
|
-
self.synthesis_data
|
103
|
-
if self.synthesis_data is not None
|
104
|
-
else FunctionSynthesisData()
|
105
|
-
),
|
106
|
-
},
|
107
|
-
},
|
109
|
+
**{**self.func_decl.model_dump(), **{"body": self.body}}
|
108
110
|
)
|
111
|
+
if self.compilation_metadata is not None:
|
112
|
+
self._qmodule.functions_compilation_metadata[self.func_decl.name] = (
|
113
|
+
self.compilation_metadata
|
114
|
+
)
|
109
115
|
|
110
116
|
def _add_constants_from_classical_code(
|
111
117
|
self, classical_execution_function: CFunc
|
@@ -1,14 +1,13 @@
|
|
1
1
|
from typing import Union
|
2
2
|
|
3
3
|
from classiq.interface.exceptions import ClassiqError
|
4
|
-
from classiq.interface.model.native_function_definition import FunctionSynthesisData
|
5
4
|
|
6
5
|
from classiq.qmod.quantum_function import ExternalQFunc, GenerativeQFunc, QFunc
|
7
6
|
|
8
7
|
|
9
8
|
def synthesize_separately(qfunc: Union[QFunc, GenerativeQFunc, ExternalQFunc]) -> QFunc:
|
10
9
|
if isinstance(qfunc, QFunc):
|
11
|
-
qfunc.
|
10
|
+
qfunc.should_synthesize_separately = True
|
12
11
|
return qfunc
|
13
12
|
if isinstance(qfunc, GenerativeQFunc):
|
14
13
|
raise ClassiqError("Generative functions can not be synthesized separately")
|
@@ -95,7 +95,7 @@ classiq/execution/qaoa.py,sha256=IiicS_L41FeR_9kDcqLKnbuBuWj5ABuuGKqyC6SVsHk,300
|
|
95
95
|
classiq/execution/qnn.py,sha256=6lAKO0TpSEkcY_EwbJfVqNeqCeOegmkBQC1AzUrWxy0,2333
|
96
96
|
classiq/executor.py,sha256=TbGAu6p70kNWMWvq3d9YldAd6LZqBJ2xl915vg8rM2Y,2602
|
97
97
|
classiq/interface/__init__.py,sha256=cg7hD_XVu1_jJ1fgwmT0rMIoZHopNVeB8xtlmMx-E_A,83
|
98
|
-
classiq/interface/_version.py,sha256=
|
98
|
+
classiq/interface/_version.py,sha256=B4yVM1xxHwW2CmQIp3jXSwkGMdgCuo2EvzL4Yr5qeFY,197
|
99
99
|
classiq/interface/analyzer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
100
100
|
classiq/interface/analyzer/analysis_params.py,sha256=dM5rwSks798cxk4FWe4_X5ToRYtgZQh34F1u0XrFkK8,3881
|
101
101
|
classiq/interface/analyzer/cytoscape_graph.py,sha256=MpeRBIYS1TfwYwiFpgTO51IE0KoxhY510pmEM3S0rbw,2361
|
@@ -242,7 +242,7 @@ classiq/interface/generator/function_param_list_without_self_reference.py,sha256
|
|
242
242
|
classiq/interface/generator/function_params.py,sha256=qo0JrN5nbNmh3nB2WUMftMS-c4o-oCh6KnljLBe7bLg,9677
|
243
243
|
classiq/interface/generator/functions/__init__.py,sha256=HXHq8Fw2zHG3AYuRXrDEQdJ-CEFX7ibsNCp8czuCmmM,73
|
244
244
|
classiq/interface/generator/functions/builtins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
245
|
-
classiq/interface/generator/functions/builtins/internal_operators.py,sha256=
|
245
|
+
classiq/interface/generator/functions/builtins/internal_operators.py,sha256=BjTxQiNCJfaITrnk69HFTjCDpwIGXwUAb9TP6KR8WD0,417
|
246
246
|
classiq/interface/generator/functions/classical_function_declaration.py,sha256=zgZj1Zbvu7Hsz6qaPQOyJnExFcbeCrRczalfD1wzfOs,1275
|
247
247
|
classiq/interface/generator/functions/classical_type.py,sha256=XC33c4Zl9ZweiGGUPUh4BeUa1GgapvBOHeEsLJ4cS58,4180
|
248
248
|
classiq/interface/generator/functions/concrete_types.py,sha256=odTCFSdBXx2vjRxGcJd7oj2JShlicAdgdWLTl2uErr8,1333
|
@@ -250,7 +250,7 @@ classiq/interface/generator/functions/function_declaration.py,sha256=G0kjoaQeW_O
|
|
250
250
|
classiq/interface/generator/functions/port_declaration.py,sha256=ESJE_19jOg_zS1reFN5dq0xgobZ6J3C3DsIs6EME1c4,1100
|
251
251
|
classiq/interface/generator/functions/qmod_python_interface.py,sha256=x8GA4Cr6YyfC6prGXv0A0I9G9GSnLHNito2nfN1GZDI,93
|
252
252
|
classiq/interface/generator/functions/type_name.py,sha256=7qM4O_6pQTmaBopIxLMMwaOcbFdzjepXj2KS9rOrJ74,2611
|
253
|
-
classiq/interface/generator/generated_circuit_data.py,sha256=
|
253
|
+
classiq/interface/generator/generated_circuit_data.py,sha256=5AtQw3wESi_tzQMpKAYy3P92c6yFs7DhjiudOfxiWH8,6509
|
254
254
|
classiq/interface/generator/grover_diffuser.py,sha256=c52p2_hpjBO0qUDsqFMQ_xffBIDPJlrfz3kIy2Mh2Gk,3750
|
255
255
|
classiq/interface/generator/grover_operator.py,sha256=_VzBJ3qO0O0MJzsHf8LF7_ooXnsz1p_I5rjQQFf1Ptg,4119
|
256
256
|
classiq/interface/generator/hadamard_transform.py,sha256=NI4oZBpDCGfaw2OTb5SL3iSGI_nDtyUgElTCO4pEKnk,673
|
@@ -273,7 +273,7 @@ classiq/interface/generator/model/__init__.py,sha256=sLQXMrkAbpmNwrfcCGdSTMNrlBN
|
|
273
273
|
classiq/interface/generator/model/constraints.py,sha256=8LM-2NT8jARIzehBLmR2Z1hHwpQT-TwezWvnt82tTBE,2575
|
274
274
|
classiq/interface/generator/model/model.py,sha256=VoAHk_wnL0GHd9BV2yjqGQR_fyDaCp5vlZOe7QJXtaE,2466
|
275
275
|
classiq/interface/generator/model/preferences/__init__.py,sha256=KTNkU8hK3cpqzXvw_C1maxhBRTm1H53WUen1jJwZ0fQ,256
|
276
|
-
classiq/interface/generator/model/preferences/preferences.py,sha256=
|
276
|
+
classiq/interface/generator/model/preferences/preferences.py,sha256=gV0RWDsi92yCDR6i105X_sKWYZW8Guw3gtTT9KgeWfo,11136
|
277
277
|
classiq/interface/generator/model/preferences/randomness.py,sha256=nAI8Fu9NQ0uJxuwIQCUDspJKMCQVHBbvPNqCTtrBEos,248
|
278
278
|
classiq/interface/generator/model/quantum_register.py,sha256=5YeeO2LEaEQW9pIKU7Wmdd74qOgcPbLLu1HuYZA7nxw,8026
|
279
279
|
classiq/interface/generator/noise_properties.py,sha256=onvXd_FeBznwu1AcOpAkL7-fo9Dc6tPcAIiL5Qxs2Ok,425
|
@@ -321,6 +321,7 @@ classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py,sha25
|
|
321
321
|
classiq/interface/generator/transpiler_basis_gates.py,sha256=4MHl6uI3Fa8bl1w_kGQC_2y_CQGxnKXbWSp5ezaw-w0,2397
|
322
322
|
classiq/interface/generator/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
323
323
|
classiq/interface/generator/types/builtin_enum_declarations.py,sha256=_FW45QH1LgXfXP83ZNhc74-BZTzjwARngTlA6YKATlk,2315
|
324
|
+
classiq/interface/generator/types/compilation_metadata.py,sha256=2LJUeGWxuW3Yu_PYvN1Vk9MBDfNDd-blApP-iDst574,140
|
324
325
|
classiq/interface/generator/types/enum_declaration.py,sha256=NLSkIANe33qubSDGmxROhNFZNuIDcJjRA-ZRuKhiZ5g,1712
|
325
326
|
classiq/interface/generator/types/qstruct_declaration.py,sha256=Qw6cHW_elZmrs4UO0z7lgS7TWb0hEUEJ5Ur-Ko0bCR4,485
|
326
327
|
classiq/interface/generator/types/struct_declaration.py,sha256=2qKVV-pdqeUGiwKh2-5W2Ci4z0aQG4TG91MuQ82fa_A,959
|
@@ -346,31 +347,31 @@ classiq/interface/helpers/validation_helpers.py,sha256=Jt0xs5EZeEQZOBEZPRmKctHmA
|
|
346
347
|
classiq/interface/helpers/versioned_model.py,sha256=kBgEghNdSidohb0-p_EjRFZLs7LAmLZ_uKIHZFSZ8cQ,159
|
347
348
|
classiq/interface/ide/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
348
349
|
classiq/interface/ide/ide_data.py,sha256=TtFsBttR7L34DeRx4NaswpdyMqEyAuguEWSvGXfZtZs,2504
|
349
|
-
classiq/interface/ide/visual_model.py,sha256=
|
350
|
+
classiq/interface/ide/visual_model.py,sha256=jf4MlIz7ON7osxb65F_ZkNyK7fc3Opxz6IxLHad0jLw,3123
|
350
351
|
classiq/interface/interface_version.py,sha256=hXglUKVBx98E8bY6pZCVyjOHpoouaIe8o1uvb1RQXyY,24
|
351
352
|
classiq/interface/jobs.py,sha256=i8hrBR2qtptCbxNI-PVYZedH_EDehOe2i09JbJUlD1g,2339
|
352
353
|
classiq/interface/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
353
354
|
classiq/interface/model/bind_operation.py,sha256=J0E6u8KOSB-vRcdpsukYpk1oc8efRohyX-PwLKh98Dc,1869
|
354
355
|
classiq/interface/model/classical_if.py,sha256=Qr726EEiim47PexMd8lTRfHLziUoiTUitnHrM3-oSgI,432
|
355
356
|
classiq/interface/model/classical_parameter_declaration.py,sha256=tcAw-knjFqeHg_snv7qBJuJDrUhmL0v1-Q_YfVgRnEc,1261
|
356
|
-
classiq/interface/model/control.py,sha256=
|
357
|
+
classiq/interface/model/control.py,sha256=1q_CjIGSGmqmvfT1RAN6VmIj2DZIio2wMOCT6HNniBw,1356
|
357
358
|
classiq/interface/model/handle_binding.py,sha256=QHH4wCb0He3k5rOjOR7M2IMh2CjBRq26sRD1BeWnE6A,7557
|
358
359
|
classiq/interface/model/inplace_binary_operation.py,sha256=Q2CmF42Y975SOJ7gsZfGyRA5Jn9MKzyNle0sopCyCh4,1494
|
359
360
|
classiq/interface/model/invert.py,sha256=9gN0vmy4892_ItwPxKc0lTjjagyKUX6mEer2vINdL5o,294
|
360
|
-
classiq/interface/model/model.py,sha256=
|
361
|
-
classiq/interface/model/native_function_definition.py,sha256=
|
361
|
+
classiq/interface/model/model.py,sha256=aQJEZIi8DO-zeLTQ5M_h7y5iGujoXxzSaUPz8FqKru4,6834
|
362
|
+
classiq/interface/model/native_function_definition.py,sha256=BPB_JfwPL6ftKlf9ceGdYOT27Fw87VbvTMDVrXJZPVI,1016
|
362
363
|
classiq/interface/model/parameter.py,sha256=otI4w5Oc4EPAALfZxDf-QxBlMSXP_CtKaUa7STMdaiw,333
|
363
364
|
classiq/interface/model/phase_operation.py,sha256=sZh00h1wOkZLiwdv_-vqJRtYJxZzmsNqCjGm2z3aXRQ,323
|
364
365
|
classiq/interface/model/port_declaration.py,sha256=wN2t9s2vUcUe4iKKHhSov14ndjkl3eJyM3aE08Kf8os,1650
|
365
366
|
classiq/interface/model/power.py,sha256=3C2NOkq_t8AafvYsN51hmgMIJB0pic_DvZxYbID9WX4,388
|
366
367
|
classiq/interface/model/quantum_expressions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
367
368
|
classiq/interface/model/quantum_expressions/amplitude_loading_operation.py,sha256=9vo9duieNmLwGoUn6Ey4C0YSqYymbt3Tb6eo80qATIs,2449
|
368
|
-
classiq/interface/model/quantum_expressions/arithmetic_operation.py,sha256=
|
369
|
+
classiq/interface/model/quantum_expressions/arithmetic_operation.py,sha256=kqABvyr-niat293lHqBmPhV0Ks3WUgHJ3mevmyD1zD8,2732
|
369
370
|
classiq/interface/model/quantum_expressions/quantum_expression.py,sha256=f_QrCf130IsVs_Nswwmr0_XYOJzvyx4hY8rWxE5lOA4,2133
|
370
371
|
classiq/interface/model/quantum_function_call.py,sha256=Rhx0-6gxKt2r3UXupoF8H9_zqkGKQdSqf1sI3xgyb84,7150
|
371
372
|
classiq/interface/model/quantum_function_declaration.py,sha256=GhUDg_cuF1ehcyfWAsXeOzLsPlp5RS_Uf8ejiO3pLmg,8118
|
372
373
|
classiq/interface/model/quantum_lambda_function.py,sha256=McokIgBUEJIPlsQvnXWQnlXH_4qTh2g5QY5K-_WDlcQ,1685
|
373
|
-
classiq/interface/model/quantum_statement.py,sha256=
|
374
|
+
classiq/interface/model/quantum_statement.py,sha256=WUtXVAaZ-DJhIfvnfDzUpP4XlTUpcCTBDgTVdHrQWxs,2740
|
374
375
|
classiq/interface/model/quantum_type.py,sha256=xQzwcgegZVwDuHOfPTVbSv3MZKPu6xBq7ZcDhS2EAZU,8296
|
375
376
|
classiq/interface/model/quantum_variable_declaration.py,sha256=Vmx-aHnss8E_ghqX_wi4Njp-dEtYK-WwYHtHAwmGZxk,229
|
376
377
|
classiq/interface/model/repeat.py,sha256=pSq0rzSDUVQqyzlv-mV1k-Jx57KyjqjZ1KgScGFOQgE,408
|
@@ -389,12 +390,11 @@ classiq/interface/server/routes.py,sha256=UqQ3BrPbGKMn3BdTo836fTVnOBI99KSPUIBwa0
|
|
389
390
|
classiq/interface/source_reference.py,sha256=a-4Vdc511ux-0lDPDTRGAzouRWWtu4A3MPAfiZe_YPE,1764
|
390
391
|
classiq/model_expansions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
391
392
|
classiq/model_expansions/atomic_expression_functions_defs.py,sha256=-P19ErGfCylg_V8mnAh_zFA4h88_FWPHXLGQaFHCvJ0,8443
|
392
|
-
classiq/model_expansions/call_to_model_converter.py,sha256=BAufH_tbLgyYxvq7nrZH1hlIHNSjPQMvVX2EVviFarQ,7160
|
393
393
|
classiq/model_expansions/capturing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
394
394
|
classiq/model_expansions/capturing/captured_var_manager.py,sha256=t-3EM-MfNlSGhx9-wzdwNAUM0aaEqDSboMBSe48QpVo,1790
|
395
395
|
classiq/model_expansions/capturing/mangling_utils.py,sha256=3pZdaebPOFQrD-psaZLdkMmRyZUvhWBxbwg_Z3IrvgI,501
|
396
396
|
classiq/model_expansions/capturing/propagated_var_stack.py,sha256=ZvNpSz7jPnKaRXimebZ8esOOmcBohv8YJFfJRjDaGVA,7063
|
397
|
-
classiq/model_expansions/closure.py,sha256=
|
397
|
+
classiq/model_expansions/closure.py,sha256=yhUMZeiGiU7GABSeMHwBkxdO96SybBCBejoNfiHz8k8,8224
|
398
398
|
classiq/model_expansions/debug_flag.py,sha256=JWzl9FFq2CLcvTg_sh-K8Dp_xXvewsTuFKhPjTCrsrs,107
|
399
399
|
classiq/model_expansions/evaluators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
400
400
|
classiq/model_expansions/evaluators/arg_type_match.py,sha256=ovN41FwUYr0-t_PbTrtUnzqO3ZKw9y7_VBZmZFRN8aM,6135
|
@@ -406,27 +406,27 @@ classiq/model_expansions/evaluators/quantum_type_utils.py,sha256=qKsntBUV_HYGsys
|
|
406
406
|
classiq/model_expansions/evaluators/type_type_match.py,sha256=3akZR86TAFKUyM5c5knCPSlraI3LQeWZXxXMTtmu0BI,3220
|
407
407
|
classiq/model_expansions/expression_evaluator.py,sha256=viOhH1X3gLAn77FkXzJ4BUHOg2i28LsNOmcpvM_R9-0,4338
|
408
408
|
classiq/model_expansions/expression_renamer.py,sha256=rtAf-vvJhlwh-KCs2WgxdW4lP3UjA0vUtZeHcIoTwUM,2692
|
409
|
-
classiq/model_expansions/function_builder.py,sha256=
|
410
|
-
classiq/model_expansions/generative_functions.py,sha256=
|
411
|
-
classiq/model_expansions/interpreter.py,sha256=
|
409
|
+
classiq/model_expansions/function_builder.py,sha256=7q7_RGHt9TiZyTHfM9btIrZxIG_xvbgjyRiXT5yPdeU,6697
|
410
|
+
classiq/model_expansions/generative_functions.py,sha256=bw3KbNCrq72H-jSDZx9npdxha0Po8lV4cqSjneW2Xlo,8465
|
411
|
+
classiq/model_expansions/interpreter.py,sha256=9JudZ_lu1_XTm5yklmGAIZ9IXvXv0tt0fS2ikg4BHAc,15208
|
412
412
|
classiq/model_expansions/model_tables.py,sha256=C0ZhCF1GAmgCqkm6iTNO9-cj_YdwGpE8etKvVxWx1w8,3585
|
413
413
|
classiq/model_expansions/quantum_operations/__init__.py,sha256=BMruLYFsir2nU9Du9PZBcQzQsgIc-4Zpkx8CJmvbL14,1040
|
414
414
|
classiq/model_expansions/quantum_operations/bind.py,sha256=QsrNMtDXHFcG2TWO7wbk4yml7kpPys1YCmL-bNrrZ_I,2606
|
415
415
|
classiq/model_expansions/quantum_operations/classicalif.py,sha256=gbRbGXtM5ep1HPGps4OSZQ07Rjgyehzgx3hsbx2ZK9Y,2160
|
416
|
-
classiq/model_expansions/quantum_operations/control.py,sha256=
|
417
|
-
classiq/model_expansions/quantum_operations/emitter.py,sha256=
|
418
|
-
classiq/model_expansions/quantum_operations/expression_operation.py,sha256=
|
416
|
+
classiq/model_expansions/quantum_operations/control.py,sha256=KJHj5T_iPWkRa9LI5nZbqMGxupKd92PCD9fUsBUQZmo,12346
|
417
|
+
classiq/model_expansions/quantum_operations/emitter.py,sha256=T1bqsSTvB5V81M5-yz4KGaR3eqAKMdtP9AyDoZMAEno,12667
|
418
|
+
classiq/model_expansions/quantum_operations/expression_operation.py,sha256=ON3B3gBTlboXsfTgnxpNF3Y6WkN4pjeHLYl5imQzaDQ,8756
|
419
419
|
classiq/model_expansions/quantum_operations/inplace_binary_operation.py,sha256=RHSNil7KGaWJWDVWYX5_bTU8RTuyp2KDN5c2asPzKdA,17036
|
420
420
|
classiq/model_expansions/quantum_operations/invert.py,sha256=2lGBaGR6XuMPkMXSx9_LlVI_Y--XYaEDyofCYUgin14,1667
|
421
421
|
classiq/model_expansions/quantum_operations/phase.py,sha256=LUk33JP9o7V-TaAhSeZci0LhNiP3EY0_PxWxVqjkQLE,7227
|
422
422
|
classiq/model_expansions/quantum_operations/power.py,sha256=7ICUvE4_mXqiCdRNi0fbxsfs_MpNFLUk4d2NF2plZXQ,2667
|
423
|
-
classiq/model_expansions/quantum_operations/quantum_assignment_operation.py,sha256=
|
424
|
-
classiq/model_expansions/quantum_operations/quantum_function_call.py,sha256=
|
423
|
+
classiq/model_expansions/quantum_operations/quantum_assignment_operation.py,sha256=Z90yAKJlC6q3yNegYsf17KzjgvCCbMIeWmky7BumGBE,9755
|
424
|
+
classiq/model_expansions/quantum_operations/quantum_function_call.py,sha256=HVU92szD_SzmtB3XJ2hY66iZazUaw5XT6o0Byw-jlNs,993
|
425
425
|
classiq/model_expansions/quantum_operations/repeat.py,sha256=nnqNQHCMJLCesMrc2ko3ficFBpWr9j2ied8TIgLfnZ0,2035
|
426
426
|
classiq/model_expansions/quantum_operations/variable_decleration.py,sha256=DdlkwMbVknd_rvZXaXelF0p1YDy6cYHStAzLJVbnV9w,1208
|
427
|
-
classiq/model_expansions/quantum_operations/within_apply.py,sha256=
|
427
|
+
classiq/model_expansions/quantum_operations/within_apply.py,sha256=dehZPxM-z2x_pdjKplml293viBtrhXNtJDEm99TbEqY,1746
|
428
428
|
classiq/model_expansions/scope.py,sha256=kcqvA-aL8HnyzR6hT-ptxt01lQAT7z_rLXHzxh99AQk,7624
|
429
|
-
classiq/model_expansions/scope_initialization.py,sha256=
|
429
|
+
classiq/model_expansions/scope_initialization.py,sha256=xIdjoGofOAatHWZU-UAQhtnoXqO1MLAA_cs8M4GlASI,5680
|
430
430
|
classiq/model_expansions/sympy_conversion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
431
431
|
classiq/model_expansions/sympy_conversion/arithmetics.py,sha256=7ZKg1C92wUdxtFhrT4VuI9mNvH2a1z1R8lbWYFhYczc,1116
|
432
432
|
classiq/model_expansions/sympy_conversion/expression_to_sympy.py,sha256=JvjhM68m6OinhJ0fR0gSUn3RqoEniD7vLAL0FO4C6R0,5634
|
@@ -466,22 +466,22 @@ classiq/qmod/builtins/functions/state_preparation.py,sha256=UMCwqXgelnfoVIfq0YDW
|
|
466
466
|
classiq/qmod/builtins/functions/swap_test.py,sha256=a6Vuby3Yn_bi7D5RLW-1SkWaqMim-UNFoRq39Zeu15g,1277
|
467
467
|
classiq/qmod/builtins/functions/utility_functions.py,sha256=lkxTPhI4jenoBWYJePPF-pMDBNBmUT9KdEVS3QrmSjw,1180
|
468
468
|
classiq/qmod/builtins/functions/variational.py,sha256=LtMZnaJY9xYsBtFnr-Wn5i5kNaL0gHW8QaBnbEzuMQY,1806
|
469
|
-
classiq/qmod/builtins/operations.py,sha256=
|
469
|
+
classiq/qmod/builtins/operations.py,sha256=CDfgbA6s7GLxAZv3pAn-z5UQ6E609iDCJH6W5hEC2eg,14436
|
470
470
|
classiq/qmod/builtins/structs.py,sha256=pdjNKFAhxLNzVdz4bhONO4PwvfI_W7Z7Skjgqt47mxw,2913
|
471
471
|
classiq/qmod/cfunc.py,sha256=e3zWNEloBBPy-wJaGI1K5cdNFbd3oq0o4TUY2YDr6ks,1087
|
472
472
|
classiq/qmod/classical_function.py,sha256=iHm6T719PUZQPwuNSkouaMA8J9yHrrHUpP-2AQjsA5g,1088
|
473
473
|
classiq/qmod/cparam.py,sha256=wai8PyfS6QCJ8_WLck2nRZrtuEXYg1cogj4CQ_EZKP4,1182
|
474
|
-
classiq/qmod/create_model_function.py,sha256=
|
474
|
+
classiq/qmod/create_model_function.py,sha256=Srmt954JHsl2QR5vRmFsMbAjCDL4vlpY0Ta804nRU4g,7778
|
475
475
|
classiq/qmod/declaration_inferrer.py,sha256=Z6TKHz-3ZoNAmIlxX5muxvAb7UyhihWx-s4a1yGK18w,6995
|
476
476
|
classiq/qmod/expression_query.py,sha256=24gsE5hJ1o9ZuqPILH7aaoOzKRQY2RZtvIK35xuubGA,1629
|
477
477
|
classiq/qmod/generative.py,sha256=3hFrDhAu-WZovuK28f7abVS4lSX7i5aK2GEvrkEqOv4,1588
|
478
|
-
classiq/qmod/model_state_container.py,sha256=
|
478
|
+
classiq/qmod/model_state_container.py,sha256=hODhsBvwgH6u6G2dPLyxrJQVx0hKuoc0aFdOkfXtqQ4,844
|
479
479
|
classiq/qmod/native/__init__.py,sha256=gm0L3ew0KAy0eSqaMQrvpnKWx85HoA1p9ADaAlyejdA,126
|
480
480
|
classiq/qmod/native/expression_to_qmod.py,sha256=a33dDr7BGWl7YhsFjpfAuI9Ys7amJjMo4DImSrD4NZg,7143
|
481
|
-
classiq/qmod/native/pretty_printer.py,sha256=
|
481
|
+
classiq/qmod/native/pretty_printer.py,sha256=8XMy-wBr9ZbEccpTUlrrY70_QauWsW6WoUVbacvlnoc,15529
|
482
482
|
classiq/qmod/pretty_print/__init__.py,sha256=jhR0cpXumOJnyb-zWnvMLpEuUOYPnnJ7DJmV-Zxpy1I,132
|
483
483
|
classiq/qmod/pretty_print/expression_to_python.py,sha256=QoRP817CFEp3Ad3Q3hxWW-hbVzWQbHQIGUHjZkpZDm8,7480
|
484
|
-
classiq/qmod/pretty_print/pretty_printer.py,sha256=
|
484
|
+
classiq/qmod/pretty_print/pretty_printer.py,sha256=JvRRqvrPROCpRwteLiEMetJabnEo7ZQCVaj-pTOzFbo,22286
|
485
485
|
classiq/qmod/python_classical_type.py,sha256=S_CbuxMHmYDgYcT31kCIy1xjhWvnAHHVJNWZ6lUPV8w,2513
|
486
486
|
classiq/qmod/qfunc.py,sha256=JGQdOOUkQaZdp4VbU_hQDiNIA5B0oOppK5Y5wKjcEIo,1298
|
487
487
|
classiq/qmod/qmod_constant.py,sha256=ZGYhlN4sN4opm91LGFxN7eShcj5mTlDH3DJXpazW-Zk,3857
|
@@ -489,7 +489,7 @@ classiq/qmod/qmod_parameter.py,sha256=PpK4rzY0Hszgbzr_lclROcZ7JPqnhDJBYsSQkUjkcs
|
|
489
489
|
classiq/qmod/qmod_variable.py,sha256=T53o_GQWXPCIfW6bTIvNUTHoE3bodIHec8r6a_YJXfU,24105
|
490
490
|
classiq/qmod/quantum_callable.py,sha256=sthlH5UJyJsdOxpCW3_EW3JFIYd0r1K3Zec1CDbC2-0,2451
|
491
491
|
classiq/qmod/quantum_expandable.py,sha256=ZRg_NWpqM86rp8hhvRXGJytBJfWdwiw930ODq6Er3xY,16450
|
492
|
-
classiq/qmod/quantum_function.py,sha256=
|
492
|
+
classiq/qmod/quantum_function.py,sha256=78WTZwI3LHj93mUdZCg_YUocgMAOco96_ozg57xXo64,8941
|
493
493
|
classiq/qmod/semantics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
494
494
|
classiq/qmod/semantics/annotation.py,sha256=0IeRymMK20sPHzbs7EzGoqhZICQmR6-gXR3SS9sr9OE,1255
|
495
495
|
classiq/qmod/semantics/error_manager.py,sha256=KAnNaQE0YarkXTQ0du3mvCqGCbbH-d81sv2Ti-NpkL4,2783
|
@@ -503,11 +503,11 @@ classiq/qmod/semantics/validation/types_validation.py,sha256=DBtpqUR1Ua3t-AVUAdJ
|
|
503
503
|
classiq/qmod/symbolic.py,sha256=-pfC93Rfa685vBN0Z5ij8AaQB0aTfVNOrtaMyPykkLg,7607
|
504
504
|
classiq/qmod/symbolic_expr.py,sha256=LJoa9c6puMvUu4d5oU0SNzc7VXzSFBUNLf19ADzktLs,6133
|
505
505
|
classiq/qmod/symbolic_type.py,sha256=ded7bVfWmHFw8MoyivVDJsG5vZZVRQontOZYb1kCrTQ,162
|
506
|
-
classiq/qmod/synthesize_separately.py,sha256=
|
506
|
+
classiq/qmod/synthesize_separately.py,sha256=pORY__n4kd1vXX3b3Q_qMW1yREbwzuMEe4VMG1SC3p4,608
|
507
507
|
classiq/qmod/type_attribute_remover.py,sha256=NZmTXAsngWqthXjE8n-n6yE72fiWTFM12-TXXJ1kJ-Q,1242
|
508
508
|
classiq/qmod/utilities.py,sha256=z_VnIRmOYTWjJp2UlOcWK0rQRtMqysmP_Gr6WYY_nak,2734
|
509
509
|
classiq/qmod/write_qmod.py,sha256=x4K4N9XPQqGTett1vCZd-D2yVAo_DmXTJ_TyEm0fff8,1800
|
510
510
|
classiq/synthesis.py,sha256=kh2BZECSw1tYWMyVXtSvXvVpZR6rSn0JkG8xQ1uTaJQ,8029
|
511
|
-
classiq-0.
|
512
|
-
classiq-0.
|
513
|
-
classiq-0.
|
511
|
+
classiq-0.55.0.dist-info/METADATA,sha256=tbqPYmsNL4KUeAEcr-rKqcoe6NOpFYVG2zbpYIQb-vA,3508
|
512
|
+
classiq-0.55.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
513
|
+
classiq-0.55.0.dist-info/RECORD,,
|
@@ -1,190 +0,0 @@
|
|
1
|
-
import dataclasses
|
2
|
-
import json
|
3
|
-
from collections.abc import Iterator, Sequence
|
4
|
-
from functools import cached_property
|
5
|
-
from typing import Any, Union
|
6
|
-
|
7
|
-
from typing_extensions import Self
|
8
|
-
|
9
|
-
from classiq.interface.exceptions import ClassiqExpansionError
|
10
|
-
from classiq.interface.generator.expressions.expression import Expression
|
11
|
-
from classiq.interface.generator.functions.port_declaration import (
|
12
|
-
PortDeclarationDirection,
|
13
|
-
)
|
14
|
-
from classiq.interface.model.handle_binding import HandleBinding
|
15
|
-
from classiq.interface.model.model import MAIN_FUNCTION_NAME, Model
|
16
|
-
from classiq.interface.model.native_function_definition import NativeFunctionDefinition
|
17
|
-
from classiq.interface.model.port_declaration import PortDeclaration
|
18
|
-
from classiq.interface.model.quantum_function_call import ArgValue, QuantumFunctionCall
|
19
|
-
from classiq.interface.model.quantum_function_declaration import (
|
20
|
-
PositionalArg,
|
21
|
-
QuantumOperandDeclaration,
|
22
|
-
)
|
23
|
-
from classiq.interface.model.quantum_type import QuantumType
|
24
|
-
|
25
|
-
from classiq import ClassicalParameterDeclaration
|
26
|
-
from classiq.model_expansions.scope import Evaluated, QuantumSymbol, evaluated_to_str
|
27
|
-
|
28
|
-
|
29
|
-
@dataclasses.dataclass(frozen=False)
|
30
|
-
class BlockFunctionInfo:
|
31
|
-
block_id: str
|
32
|
-
model: Model
|
33
|
-
inputs: set[str]
|
34
|
-
outputs: set[str]
|
35
|
-
inouts: set[str]
|
36
|
-
calls: set[str] = dataclasses.field(default_factory=set)
|
37
|
-
|
38
|
-
@classmethod
|
39
|
-
def from_call_converter(cls, call_converter: "CallToModelConverter") -> Self:
|
40
|
-
return cls(
|
41
|
-
block_id=call_converter.block_id,
|
42
|
-
model=call_converter.convert(),
|
43
|
-
inputs=set(call_converter.call.wiring_inputs),
|
44
|
-
outputs=set(call_converter.call.wiring_outputs),
|
45
|
-
inouts=set(call_converter.call.wiring_inouts),
|
46
|
-
)
|
47
|
-
|
48
|
-
|
49
|
-
class CallToModelConverter:
|
50
|
-
|
51
|
-
def __init__(
|
52
|
-
self,
|
53
|
-
call: QuantumFunctionCall,
|
54
|
-
positional_arg_declarations: Sequence[PositionalArg],
|
55
|
-
evaluated_arg: dict[str, Evaluated],
|
56
|
-
model: Model,
|
57
|
-
) -> None:
|
58
|
-
self.call = call
|
59
|
-
self._positional_arg_declarations = positional_arg_declarations
|
60
|
-
self._evaluated_arg = evaluated_arg
|
61
|
-
|
62
|
-
self._model = model
|
63
|
-
|
64
|
-
@cached_property
|
65
|
-
def block_id(self) -> str:
|
66
|
-
args_signature: dict = {}
|
67
|
-
for arg_declaration, evaluated_arg in zip(
|
68
|
-
self._positional_arg_declarations,
|
69
|
-
self._evaluated_arg.values(),
|
70
|
-
):
|
71
|
-
args_signature |= _get_arg_signature(arg_declaration, evaluated_arg)
|
72
|
-
return f"{self.call.func_name}__{json.dumps(args_signature)}"
|
73
|
-
|
74
|
-
def convert(self) -> Model:
|
75
|
-
return self._model.model_copy(
|
76
|
-
update={"functions": self._update_model_functions()}
|
77
|
-
)
|
78
|
-
|
79
|
-
def _update_model_functions(self) -> list[NativeFunctionDefinition]:
|
80
|
-
return [
|
81
|
-
(
|
82
|
-
self._create_new_main_function()
|
83
|
-
if function.name == MAIN_FUNCTION_NAME
|
84
|
-
else (
|
85
|
-
function.model_copy(update={"synthesis_data": None})
|
86
|
-
if function.name == self.call.function
|
87
|
-
else function
|
88
|
-
)
|
89
|
-
)
|
90
|
-
for function in self._model.functions
|
91
|
-
]
|
92
|
-
|
93
|
-
def _create_new_main_function(self) -> NativeFunctionDefinition:
|
94
|
-
return NativeFunctionDefinition(
|
95
|
-
name=MAIN_FUNCTION_NAME,
|
96
|
-
positional_arg_declarations=self._make_all_ports_outputs(),
|
97
|
-
body=[*self._allocate_ports(), self._update_call()],
|
98
|
-
)
|
99
|
-
|
100
|
-
def _make_all_ports_outputs(self) -> list[PortDeclaration]:
|
101
|
-
return [
|
102
|
-
_convert_port_to_output(port_declaration)
|
103
|
-
for port_declaration in self._positional_arg_declarations
|
104
|
-
if isinstance(port_declaration, PortDeclaration)
|
105
|
-
]
|
106
|
-
|
107
|
-
def _allocate_ports(self) -> Iterator[QuantumFunctionCall]:
|
108
|
-
return (
|
109
|
-
QuantumFunctionCall(
|
110
|
-
function="allocate",
|
111
|
-
positional_args=[
|
112
|
-
self._get_allocation_size(port_declaration.name),
|
113
|
-
HandleBinding(name=port_declaration.name),
|
114
|
-
],
|
115
|
-
)
|
116
|
-
for port_declaration in self._positional_arg_declarations
|
117
|
-
if isinstance(port_declaration, PortDeclaration)
|
118
|
-
and port_declaration.direction != PortDeclarationDirection.Output
|
119
|
-
)
|
120
|
-
|
121
|
-
def _get_allocation_size(self, port_declara_name: str) -> Expression:
|
122
|
-
port_value = self._evaluated_arg[port_declara_name].value
|
123
|
-
return Expression(expr=_get_reg_size(port_value, port_declara_name))
|
124
|
-
|
125
|
-
def _update_call(self) -> QuantumFunctionCall:
|
126
|
-
return self.call.model_copy(
|
127
|
-
update={"positional_args": self._evaluate_positional_args()}
|
128
|
-
)
|
129
|
-
|
130
|
-
def _evaluate_positional_args(self) -> list[ArgValue]:
|
131
|
-
return [
|
132
|
-
_get_positional_arg(arg, evaluated_arg)
|
133
|
-
for arg, evaluated_arg in zip(
|
134
|
-
self._positional_arg_declarations,
|
135
|
-
self._evaluated_arg.values(),
|
136
|
-
)
|
137
|
-
]
|
138
|
-
|
139
|
-
|
140
|
-
def _validate_quantum_type(port: Any, port_declara_name: str) -> QuantumType:
|
141
|
-
if not isinstance(port, QuantumSymbol):
|
142
|
-
raise ClassiqExpansionError(f"Port {port_declara_name!r} has incorrect type")
|
143
|
-
return port.quantum_type
|
144
|
-
|
145
|
-
|
146
|
-
def _get_reg_size(port: Any, port_declara_name: str) -> str:
|
147
|
-
quantum_type = _validate_quantum_type(port, port_declara_name)
|
148
|
-
return str(quantum_type.size_in_bits)
|
149
|
-
|
150
|
-
|
151
|
-
def _get_arg_signature(
|
152
|
-
arg_declaration: PositionalArg, evaluated_arg: Evaluated
|
153
|
-
) -> dict[str, str]:
|
154
|
-
arg_value = evaluated_arg.value
|
155
|
-
arg_name = arg_declaration.name
|
156
|
-
if isinstance(arg_declaration, ClassicalParameterDeclaration):
|
157
|
-
return {arg_name: evaluated_to_str(arg_value)}
|
158
|
-
if isinstance(arg_declaration, PortDeclaration):
|
159
|
-
quantum_type = _validate_quantum_type(arg_value, arg_name)
|
160
|
-
return {
|
161
|
-
arg_name: quantum_type.model_dump_json(exclude_none=True, exclude={"name"})
|
162
|
-
}
|
163
|
-
if isinstance(arg_declaration, QuantumOperandDeclaration):
|
164
|
-
raise NotImplementedError(
|
165
|
-
f"Synthesize separately does not support input operand: {arg_declaration.name!r}"
|
166
|
-
)
|
167
|
-
|
168
|
-
|
169
|
-
def _get_positional_arg(
|
170
|
-
arg_declaration: PositionalArg, evaluated_arg: Evaluated
|
171
|
-
) -> Union[Expression, HandleBinding]:
|
172
|
-
if isinstance(arg_declaration, ClassicalParameterDeclaration):
|
173
|
-
return Expression(expr=evaluated_to_str(evaluated_arg.value))
|
174
|
-
if isinstance(arg_declaration, PortDeclaration):
|
175
|
-
return HandleBinding(name=arg_declaration.name)
|
176
|
-
if isinstance(arg_declaration, QuantumOperandDeclaration):
|
177
|
-
raise NotImplementedError(
|
178
|
-
f"Synthesize separately does not support input operand: {arg_declaration.name!r}"
|
179
|
-
)
|
180
|
-
|
181
|
-
|
182
|
-
def _convert_port_to_output(port: PortDeclaration) -> PortDeclaration:
|
183
|
-
if port.direction == PortDeclarationDirection.Output:
|
184
|
-
return port
|
185
|
-
elif port.direction == PortDeclarationDirection.Inout:
|
186
|
-
return port.model_copy(update={"direction": PortDeclarationDirection.Output})
|
187
|
-
else:
|
188
|
-
raise NotImplementedError(
|
189
|
-
f"Synthesize separately does not support input ports: {port.name!r}"
|
190
|
-
)
|
File without changes
|