classiq 0.57.0__py3-none-any.whl → 0.58.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/applications/combinatorial_helpers/encoding_utils.py +1 -0
- classiq/applications/combinatorial_helpers/transformations/encoding.py +3 -1
- classiq/execution/jobs.py +8 -1
- classiq/interface/_version.py +1 -1
- classiq/interface/backend/backend_preferences.py +27 -5
- classiq/interface/backend/pydantic_backend.py +0 -1
- classiq/interface/execution/jobs.py +4 -1
- classiq/interface/executor/execution_request.py +14 -0
- classiq/interface/generator/functions/type_name.py +7 -9
- classiq/model_expansions/evaluators/parameter_types.py +1 -2
- classiq/model_expansions/evaluators/quantum_type_utils.py +0 -7
- classiq/model_expansions/function_builder.py +13 -0
- classiq/model_expansions/interpreter.py +9 -14
- classiq/qmod/native/pretty_printer.py +19 -4
- classiq/qmod/semantics/qstruct_annotator.py +23 -0
- classiq/qmod/semantics/static_semantics_visitor.py +4 -1
- classiq/qmod/write_qmod.py +3 -1
- {classiq-0.57.0.dist-info → classiq-0.58.0.dist-info}/METADATA +1 -1
- {classiq-0.57.0.dist-info → classiq-0.58.0.dist-info}/RECORD +20 -19
- {classiq-0.57.0.dist-info → classiq-0.58.0.dist-info}/WHEEL +0 -0
@@ -85,7 +85,9 @@ class ModelEncoder:
|
|
85
85
|
encoding_expr = self._get_encoding_expr(var_data, encoding_vars)
|
86
86
|
|
87
87
|
self._add_expr_constraint(
|
88
|
-
constraint_name=var_data.name
|
88
|
+
constraint_name=var_data.name
|
89
|
+
+ encoding_utils.ENCODED_SUFFIX
|
90
|
+
+ encoding_utils.CONSTRAINT_SUFFIX,
|
89
91
|
expr=EqualityExpression(args=[var_data, encoding_expr]),
|
90
92
|
)
|
91
93
|
|
classiq/execution/jobs.py
CHANGED
@@ -8,7 +8,7 @@ from classiq.interface.exceptions import (
|
|
8
8
|
ClassiqError,
|
9
9
|
)
|
10
10
|
from classiq.interface.execution.jobs import ExecutionJobDetailsV1
|
11
|
-
from classiq.interface.executor.execution_request import ExecutionJobDetails
|
11
|
+
from classiq.interface.executor.execution_request import ExecutionJobDetails, JobCost
|
12
12
|
from classiq.interface.executor.execution_result import ResultsCollection
|
13
13
|
from classiq.interface.executor.result import (
|
14
14
|
EstimationResult,
|
@@ -92,6 +92,13 @@ class ExecutionJob:
|
|
92
92
|
else:
|
93
93
|
return f"{class_name}(name={self.name!r}, id={self.id!r})"
|
94
94
|
|
95
|
+
def cost(self, *, verbose: bool = False) -> Union[str, JobCost]:
|
96
|
+
if self._details.cost is None:
|
97
|
+
self._details.cost = JobCost()
|
98
|
+
if verbose:
|
99
|
+
return self._details.cost
|
100
|
+
return f"{self._details.cost.total_cost} {self._details.cost.currency_code}"
|
101
|
+
|
95
102
|
@classmethod
|
96
103
|
async def from_id_async(cls, id: str) -> "ExecutionJob":
|
97
104
|
details = await ApiWrapper.call_get_execution_job_details(JobID(job_id=id))
|
classiq/interface/_version.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
import warnings
|
3
4
|
from collections.abc import Iterable
|
4
5
|
from typing import Any, Optional, Union
|
5
6
|
|
@@ -21,7 +22,7 @@ from classiq.interface.backend.quantum_backend_providers import (
|
|
21
22
|
ProviderTypeVendor,
|
22
23
|
ProviderVendor,
|
23
24
|
)
|
24
|
-
from classiq.interface.exceptions import ClassiqValueError
|
25
|
+
from classiq.interface.exceptions import ClassiqDeprecationWarning, ClassiqValueError
|
25
26
|
from classiq.interface.hardware import Provider
|
26
27
|
|
27
28
|
|
@@ -117,8 +118,8 @@ class AliceBobBackendPreferences(BackendPreferences):
|
|
117
118
|
average_nb_photons: Optional[float] = pydantic.Field(
|
118
119
|
default=None, description="Average number of photons"
|
119
120
|
)
|
120
|
-
api_key: pydantic_backend.PydanticAliceBobApiKeyType = pydantic.Field(
|
121
|
-
|
121
|
+
api_key: Optional[pydantic_backend.PydanticAliceBobApiKeyType] = pydantic.Field(
|
122
|
+
default=None, description="AliceBob API key"
|
122
123
|
)
|
123
124
|
|
124
125
|
@property
|
@@ -131,6 +132,17 @@ class AliceBobBackendPreferences(BackendPreferences):
|
|
131
132
|
}
|
132
133
|
return {k: v for k, v in parameters.items() if v is not None}
|
133
134
|
|
135
|
+
@pydantic.field_validator("api_key", mode="after")
|
136
|
+
@classmethod
|
137
|
+
def _validate_api_key(cls, api_key: Optional[str]) -> Optional[str]:
|
138
|
+
if api_key is not None:
|
139
|
+
warnings.warn(
|
140
|
+
"API key is no longer required for Alice&Bob backends.",
|
141
|
+
ClassiqDeprecationWarning,
|
142
|
+
stacklevel=2,
|
143
|
+
)
|
144
|
+
return api_key
|
145
|
+
|
134
146
|
|
135
147
|
class ClassiqBackendPreferences(BackendPreferences):
|
136
148
|
"""
|
@@ -230,6 +242,7 @@ class IBMBackendPreferences(BackendPreferences):
|
|
230
242
|
access_token (Optional[str]): The IBM Quantum access token to be used with IBM Quantum hosted backends. Defaults to `None`.
|
231
243
|
provider (IBMBackendProvider): Specifications for identifying a single IBM Quantum provider. Defaults to a new `IBMBackendProvider`.
|
232
244
|
qctrl_api_key (Optional[str]): QCTRL API key to access QCTRL optimization abilities.
|
245
|
+
run_through_classiq (bool): Run through Classiq's credentials. Defaults to `False`.
|
233
246
|
|
234
247
|
See examples in the [IBM Quantum Backend Documentation](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/ibm-backends/?h=).
|
235
248
|
"""
|
@@ -250,6 +263,10 @@ class IBMBackendPreferences(BackendPreferences):
|
|
250
263
|
default=None,
|
251
264
|
description="QCTRL API key to access QCTRL optimization abilities",
|
252
265
|
)
|
266
|
+
run_through_classiq: bool = pydantic.Field(
|
267
|
+
default=False,
|
268
|
+
description="Run through Classiq's credentials",
|
269
|
+
)
|
253
270
|
|
254
271
|
|
255
272
|
class AzureCredential(BaseSettings):
|
@@ -341,6 +358,7 @@ class IonqBackendPreferences(BackendPreferences):
|
|
341
358
|
backend_service_provider (ProviderTypeVendor.IONQ): Indicates the backend service provider as IonQ.
|
342
359
|
api_key (PydanticIonQApiKeyType): The IonQ API key required for accessing IonQ's quantum computing services.
|
343
360
|
error_mitigation (bool): A configuration option to enable or disable error mitigation during execution. Defaults to `False`.
|
361
|
+
run_through_classiq (bool): Running through Classiq's credentials while using user's allocated budget.
|
344
362
|
|
345
363
|
See examples in the [IonQ Backend Documentation](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/ionq-backends/?h=).
|
346
364
|
"""
|
@@ -348,13 +366,17 @@ class IonqBackendPreferences(BackendPreferences):
|
|
348
366
|
backend_service_provider: ProviderTypeVendor.IONQ = pydantic.Field(
|
349
367
|
default=ProviderVendor.IONQ
|
350
368
|
)
|
351
|
-
api_key: pydantic_backend.PydanticIonQApiKeyType = pydantic.Field(
|
352
|
-
|
369
|
+
api_key: Optional[pydantic_backend.PydanticIonQApiKeyType] = pydantic.Field(
|
370
|
+
default=None, description="IonQ API key"
|
353
371
|
)
|
354
372
|
error_mitigation: bool = pydantic.Field(
|
355
373
|
default=False,
|
356
374
|
description="Error mitigation configuration.",
|
357
375
|
)
|
376
|
+
run_through_classiq: bool = pydantic.Field(
|
377
|
+
default=False,
|
378
|
+
description="Running through Classiq's credentials while using user's allocated budget.",
|
379
|
+
)
|
358
380
|
|
359
381
|
|
360
382
|
class GCPBackendPreferences(BackendPreferences):
|
@@ -7,7 +7,6 @@ AZURE_QUANTUM_RESOURCE_ID_REGEX = r"^/subscriptions/([a-fA-F0-9-]*)/resourceGrou
|
|
7
7
|
_IONQ_API_KEY_LENGTH: int = 32
|
8
8
|
_ALICE_BOB_API_KEY_LENGTH: int = 72
|
9
9
|
INVALID_API_KEY: str = _IONQ_API_KEY_LENGTH * "a"
|
10
|
-
INVALID_API_KEY_ALICE_BOB: str = _ALICE_BOB_API_KEY_LENGTH * "a"
|
11
10
|
INVALID_EMAIL_OQC: str = "aa@aa.aa"
|
12
11
|
INVALID_PASSWORD_OQC: str = "Aa1!Aa1!"
|
13
12
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
from datetime import datetime
|
2
2
|
from typing import Optional
|
3
3
|
|
4
|
-
from pydantic import BaseModel
|
4
|
+
from pydantic import BaseModel, Field
|
5
5
|
|
6
|
+
from classiq.interface.executor.execution_request import JobCost
|
6
7
|
from classiq.interface.jobs import JobStatus
|
7
8
|
|
8
9
|
|
@@ -23,6 +24,8 @@ class ExecutionJobDetailsV1(BaseModel, extra="ignore"):
|
|
23
24
|
|
24
25
|
error: Optional[str] = None
|
25
26
|
|
27
|
+
cost: Optional[JobCost] = Field(default=None)
|
28
|
+
|
26
29
|
|
27
30
|
class ExecutionJobsQueryResultsV1(BaseModel, extra="ignore"):
|
28
31
|
results: list[ExecutionJobDetailsV1]
|
@@ -43,6 +43,18 @@ class QuantumProgramExecutionRequest(ExecutionRequest):
|
|
43
43
|
execution_payload: QuantumCodeExecution
|
44
44
|
|
45
45
|
|
46
|
+
class ProviderJobs(BaseModel):
|
47
|
+
provider_job_id: str = Field(default="DUMMY")
|
48
|
+
cost: float = Field(default=0)
|
49
|
+
|
50
|
+
|
51
|
+
class JobCost(BaseModel):
|
52
|
+
total_cost: float = Field(default=0)
|
53
|
+
currency_code: str = Field(default="USD")
|
54
|
+
organization: Optional[str] = Field(default=None)
|
55
|
+
jobs: list[ProviderJobs] = Field(default=[])
|
56
|
+
|
57
|
+
|
46
58
|
class ExecutionJobDetails(VersionedModel):
|
47
59
|
id: str
|
48
60
|
|
@@ -60,6 +72,8 @@ class ExecutionJobDetails(VersionedModel):
|
|
60
72
|
|
61
73
|
error: Optional[str] = Field(default=None)
|
62
74
|
|
75
|
+
cost: Optional[JobCost] = Field(default=None)
|
76
|
+
|
63
77
|
|
64
78
|
class ExecutionJobsQueryResults(VersionedModel):
|
65
79
|
results: list[ExecutionJobDetails]
|
@@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, Any, Literal, Optional
|
|
3
3
|
|
4
4
|
import pydantic
|
5
5
|
|
6
|
+
from classiq.interface.exceptions import ClassiqInternalError
|
6
7
|
from classiq.interface.generator.expressions.qmod_qstruct_proxy import QmodQStructProxy
|
7
8
|
from classiq.interface.generator.functions.classical_type import (
|
8
9
|
ClassicalType,
|
@@ -57,18 +58,15 @@ class TypeName(ClassicalType, QuantumType):
|
|
57
58
|
|
58
59
|
@property
|
59
60
|
def fields(self) -> Mapping[str, "ConcreteQuantumType"]:
|
60
|
-
from classiq.qmod.model_state_container import QMODULE
|
61
|
-
|
62
61
|
if self._assigned_fields is None:
|
63
|
-
|
64
|
-
self._assigned_fields = {
|
65
|
-
field_name: field_type.model_copy()
|
66
|
-
for field_name, field_type in qstruct_fields.items()
|
67
|
-
}
|
68
|
-
|
62
|
+
raise ClassiqInternalError("Fields not set")
|
69
63
|
return self._assigned_fields
|
70
64
|
|
71
|
-
|
65
|
+
@property
|
66
|
+
def has_fields(self) -> bool:
|
67
|
+
return self._assigned_fields is not None
|
68
|
+
|
69
|
+
def set_fields(self, fields: Mapping[str, "ConcreteQuantumType"]) -> None:
|
72
70
|
self._assigned_fields = fields
|
73
71
|
|
74
72
|
|
@@ -35,7 +35,6 @@ from classiq.model_expansions.evaluators.quantum_type_utils import (
|
|
35
35
|
set_is_signed,
|
36
36
|
set_length,
|
37
37
|
set_size,
|
38
|
-
set_struct_fields,
|
39
38
|
)
|
40
39
|
from classiq.model_expansions.scope import Evaluated, QuantumSymbol, Scope
|
41
40
|
|
@@ -198,7 +197,7 @@ def _evaluate_qstruct_in_quantum_symbol(
|
|
198
197
|
field_name: evaluate_type_in_quantum_symbol(field_type, scope, param_name)
|
199
198
|
for field_name, field_type in type_to_update.fields.items()
|
200
199
|
}
|
201
|
-
|
200
|
+
type_to_update.set_fields(new_fields)
|
202
201
|
return type_to_update
|
203
202
|
|
204
203
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
from collections.abc import Mapping
|
2
1
|
from typing import Optional
|
3
2
|
|
4
3
|
from classiq.interface.exceptions import (
|
@@ -157,12 +156,6 @@ def set_element_type(
|
|
157
156
|
quantum_array.element_type = element_type
|
158
157
|
|
159
158
|
|
160
|
-
def set_struct_fields(
|
161
|
-
quantum_struct: TypeName, fields: Mapping[str, ConcreteQuantumType]
|
162
|
-
) -> None:
|
163
|
-
quantum_struct._set_fields(fields)
|
164
|
-
|
165
|
-
|
166
159
|
def set_length(quantum_array: QuantumBitvector, length: int) -> None:
|
167
160
|
quantum_array.length = Expression(expr=str(length))
|
168
161
|
|
@@ -26,6 +26,7 @@ from classiq.interface.model.quantum_function_declaration import (
|
|
26
26
|
PositionalArg,
|
27
27
|
)
|
28
28
|
from classiq.interface.model.quantum_statement import QuantumStatement
|
29
|
+
from classiq.interface.source_reference import SourceReference
|
29
30
|
|
30
31
|
from classiq.model_expansions.capturing.captured_var_manager import update_captured_vars
|
31
32
|
from classiq.model_expansions.capturing.mangling_utils import demangle_name
|
@@ -82,6 +83,7 @@ class OperationBuilder:
|
|
82
83
|
self._operations: list[OperationContext] = []
|
83
84
|
self._blocks: list[str] = []
|
84
85
|
self._functions_scope = functions_scope
|
86
|
+
self._current_source_ref: Optional[SourceReference] = None
|
85
87
|
|
86
88
|
@property
|
87
89
|
def current_operation(self) -> Closure:
|
@@ -99,6 +101,8 @@ class OperationBuilder:
|
|
99
101
|
return self._operations[-1].blocks[self._blocks[-1]].statements
|
100
102
|
|
101
103
|
def emit_statement(self, statement: QuantumStatement) -> None:
|
104
|
+
if self._current_source_ref is not None:
|
105
|
+
statement.source_ref = self._current_source_ref
|
102
106
|
self._current_statements.append(statement)
|
103
107
|
|
104
108
|
@property
|
@@ -131,6 +135,15 @@ class OperationBuilder:
|
|
131
135
|
self._update_captured_vars()
|
132
136
|
self._operations.pop()
|
133
137
|
|
138
|
+
@contextmanager
|
139
|
+
def source_ref_context(
|
140
|
+
self, source_ref: Optional[SourceReference]
|
141
|
+
) -> Iterator[None]:
|
142
|
+
previous_source_ref = self._current_source_ref
|
143
|
+
self._current_source_ref = source_ref
|
144
|
+
yield
|
145
|
+
self._current_source_ref = previous_source_ref
|
146
|
+
|
134
147
|
def _update_captured_vars(self) -> None:
|
135
148
|
for block in self._operations[-1].blocks.values():
|
136
149
|
block.captured_vars = update_captured_vars(block.captured_vars)
|
@@ -6,8 +6,10 @@ from typing import Any, Optional, cast
|
|
6
6
|
|
7
7
|
import numpy as np
|
8
8
|
from numpy.random import permutation
|
9
|
+
from pydantic import ValidationError
|
9
10
|
|
10
11
|
from classiq.interface.exceptions import (
|
12
|
+
ClassiqError,
|
11
13
|
ClassiqExpansionError,
|
12
14
|
ClassiqInternalExpansionError,
|
13
15
|
)
|
@@ -92,12 +94,6 @@ from classiq.qmod.builtins.functions import permute
|
|
92
94
|
from classiq.qmod.quantum_function import GenerativeQFunc
|
93
95
|
from classiq.qmod.semantics.error_manager import ErrorManager
|
94
96
|
|
95
|
-
STATEMENT_TYPES_FOR_SOURCE_REFERENCE_PROPAGATION: tuple[type[QuantumStatement], ...] = (
|
96
|
-
QuantumFunctionCall,
|
97
|
-
VariableDeclarationStatement,
|
98
|
-
QuantumAssignmentOperation,
|
99
|
-
)
|
100
|
-
|
101
97
|
|
102
98
|
class Interpreter:
|
103
99
|
def __init__(
|
@@ -168,6 +164,8 @@ class Interpreter:
|
|
168
164
|
except Exception as e:
|
169
165
|
if isinstance(e, ClassiqInternalExpansionError) or debug_mode.get():
|
170
166
|
raise e
|
167
|
+
if not isinstance(e, (ClassiqError, ValidationError)):
|
168
|
+
raise ClassiqInternalExpansionError(str(e)) from None
|
171
169
|
prefix = ""
|
172
170
|
if not isinstance(e, ClassiqExpansionError):
|
173
171
|
prefix = f"{type(e).__name__}: "
|
@@ -333,17 +331,14 @@ class Interpreter:
|
|
333
331
|
self.emit_statement(statement)
|
334
332
|
|
335
333
|
def emit_statement(self, statement: QuantumStatement) -> None:
|
336
|
-
|
334
|
+
source_ref = statement.source_ref
|
335
|
+
error_context = (
|
337
336
|
self._error_manager.node_context(statement)
|
338
|
-
if
|
337
|
+
if source_ref is not None
|
339
338
|
else nullcontext()
|
340
|
-
)
|
339
|
+
)
|
340
|
+
with error_context, self._builder.source_ref_context(source_ref):
|
341
341
|
self.emit(statement)
|
342
|
-
if isinstance(
|
343
|
-
statement,
|
344
|
-
STATEMENT_TYPES_FOR_SOURCE_REFERENCE_PROPAGATION,
|
345
|
-
):
|
346
|
-
self._builder.current_statement.source_ref = statement.source_ref
|
347
342
|
|
348
343
|
def _expand_operation(self, operation: Closure) -> OperationContext:
|
349
344
|
with self._builder.operation_context(operation) as context:
|
@@ -83,10 +83,13 @@ from classiq.qmod.utilities import DEFAULT_DECIMAL_PRECISION
|
|
83
83
|
|
84
84
|
class DSLPrettyPrinter(Visitor):
|
85
85
|
def __init__(
|
86
|
-
self,
|
86
|
+
self,
|
87
|
+
decimal_precision: Optional[int] = DEFAULT_DECIMAL_PRECISION,
|
88
|
+
rename_phase: bool = False,
|
87
89
|
) -> None:
|
88
90
|
self._level = 0
|
89
91
|
self._decimal_precision = decimal_precision
|
92
|
+
self._rename_phase = rename_phase
|
90
93
|
|
91
94
|
def visit(self, node: NodeType) -> str:
|
92
95
|
res = super().visit(node)
|
@@ -165,7 +168,10 @@ class DSLPrettyPrinter(Visitor):
|
|
165
168
|
def visit_QuantumVariableDeclaration(
|
166
169
|
self, var_decl: QuantumVariableDeclaration
|
167
170
|
) -> str:
|
168
|
-
|
171
|
+
var_name = var_decl.name
|
172
|
+
if self._rename_phase and var_name == "phase":
|
173
|
+
var_name = "phase_var"
|
174
|
+
return f"{var_name}: {self.visit(var_decl.quantum_type)}"
|
169
175
|
|
170
176
|
def visit_AnonPortDeclaration(self, port_decl: AnonPortDeclaration) -> str:
|
171
177
|
dir_str = (
|
@@ -173,7 +179,12 @@ class DSLPrettyPrinter(Visitor):
|
|
173
179
|
if port_decl.direction != PortDeclarationDirection.Inout
|
174
180
|
else ""
|
175
181
|
)
|
176
|
-
|
182
|
+
port_name = (
|
183
|
+
port_decl.name
|
184
|
+
if not (self._rename_phase and port_decl.name == "phase")
|
185
|
+
else "phase_var"
|
186
|
+
)
|
187
|
+
param_name = f"{port_name}: " if port_decl.name is not None else ""
|
177
188
|
return f"{dir_str}{param_name}{self.visit(port_decl.quantum_type)}"
|
178
189
|
|
179
190
|
def visit_QuantumBit(self, qtype: QuantumBit) -> str:
|
@@ -339,7 +350,11 @@ class DSLPrettyPrinter(Visitor):
|
|
339
350
|
return f"lambda({positional_args}) {{\n{body}{self._indent}}}"
|
340
351
|
|
341
352
|
def visit_HandleBinding(self, var_ref: HandleBinding) -> str:
|
342
|
-
return
|
353
|
+
return (
|
354
|
+
var_ref.name
|
355
|
+
if not (self._rename_phase and var_ref.name == "phase")
|
356
|
+
else "phase_var"
|
357
|
+
)
|
343
358
|
|
344
359
|
def visit_SlicedHandleBinding(self, var_ref: SlicedHandleBinding) -> str:
|
345
360
|
return f"{self.visit(var_ref.base_handle)}[{self.visit(var_ref.start)}:{self.visit(var_ref.end)}]"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
from classiq.interface.generator.functions.type_name import TypeName
|
2
|
+
from classiq.interface.generator.visitor import Visitor
|
3
|
+
|
4
|
+
from classiq.qmod.model_state_container import QMODULE
|
5
|
+
|
6
|
+
|
7
|
+
class QStructAnnotator(Visitor):
|
8
|
+
def __init__(self) -> None:
|
9
|
+
self._visited: set[TypeName] = set()
|
10
|
+
|
11
|
+
def visit_TypeName(self, type_name: TypeName) -> None:
|
12
|
+
decl = QMODULE.qstruct_decls.get(type_name.name)
|
13
|
+
if decl is None or type_name.has_fields or (type_name in self._visited):
|
14
|
+
return
|
15
|
+
self._visited.add(type_name)
|
16
|
+
new_fields = {
|
17
|
+
field_name: field_type.model_copy()
|
18
|
+
for field_name, field_type in decl.fields.items()
|
19
|
+
}
|
20
|
+
# We first visit the new fields and then set to deal with recursive
|
21
|
+
# qstructs
|
22
|
+
self.visit(new_fields)
|
23
|
+
type_name.set_fields(new_fields)
|
@@ -44,6 +44,7 @@ from classiq.interface.model.within_apply_operation import WithinApply
|
|
44
44
|
from classiq.qmod.builtins.functions import BUILTIN_FUNCTION_DECLARATIONS
|
45
45
|
from classiq.qmod.semantics.annotation import annotate_function_call_decl
|
46
46
|
from classiq.qmod.semantics.error_manager import ErrorManager
|
47
|
+
from classiq.qmod.semantics.qstruct_annotator import QStructAnnotator
|
47
48
|
from classiq.qmod.semantics.validation.constants_validation import (
|
48
49
|
check_duplicate_constants,
|
49
50
|
)
|
@@ -70,7 +71,6 @@ HANDLE_BINDING_PART_MESSAGE = {
|
|
70
71
|
|
71
72
|
|
72
73
|
class StaticScope:
|
73
|
-
|
74
74
|
def __init__(
|
75
75
|
self,
|
76
76
|
parameters: list[str],
|
@@ -363,6 +363,8 @@ def resolve_function_calls(
|
|
363
363
|
quantum_function_dict: Mapping[str, QuantumFunctionDeclaration],
|
364
364
|
) -> None:
|
365
365
|
with ErrorManager().ignore_errors_context():
|
366
|
+
QStructAnnotator().visit(quantum_function_dict)
|
367
|
+
QStructAnnotator().visit(root)
|
366
368
|
StaticSemanticsVisitor(
|
367
369
|
{**BUILTIN_FUNCTION_DECLARATIONS, **quantum_function_dict},
|
368
370
|
[],
|
@@ -372,6 +374,7 @@ def resolve_function_calls(
|
|
372
374
|
def static_semantics_analysis_pass(
|
373
375
|
model: Model, error_type: Optional[type[Exception]] = ClassiqSemanticError
|
374
376
|
) -> None:
|
377
|
+
QStructAnnotator().visit(model)
|
375
378
|
StaticSemanticsVisitor(
|
376
379
|
{**BUILTIN_FUNCTION_DECLARATIONS, **model.function_dict},
|
377
380
|
[const.name for const in model.constants],
|
classiq/qmod/write_qmod.py
CHANGED
@@ -36,7 +36,9 @@ def write_qmod(
|
|
36
36
|
model
|
37
37
|
)
|
38
38
|
|
39
|
-
synthesis_options = model.model_dump(
|
39
|
+
synthesis_options = model.model_dump(
|
40
|
+
include={"constraints", "preferences"}, exclude_none=True
|
41
|
+
)
|
40
42
|
|
41
43
|
synthesis_options_path = Path(f"{name}.{_SYNTHESIS_OPTIONS_SUFFIX}")
|
42
44
|
if directory is not None:
|
@@ -37,7 +37,7 @@ classiq/applications/combinatorial_helpers/arithmetic/arithmetic_expression.py,s
|
|
37
37
|
classiq/applications/combinatorial_helpers/arithmetic/isolation.py,sha256=wpu0Sq-z7Fu39mOodGEdD_hWtlUV3cYKCcq_izrypLY,1546
|
38
38
|
classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py,sha256=WCSbNMfdJ62jRZ5yA_c0fqsCZ4ov3e1hoBbfqXYwaP0,5105
|
39
39
|
classiq/applications/combinatorial_helpers/encoding_mapping.py,sha256=ULt_ZGzhiu2QMVv5L9Eo7VzsgPYmfUAiE1wG2_CnqQ8,3652
|
40
|
-
classiq/applications/combinatorial_helpers/encoding_utils.py,sha256=
|
40
|
+
classiq/applications/combinatorial_helpers/encoding_utils.py,sha256=Y75F2IHwjlwGshtqsfBG1U_S3cOl2eWu4zNZcCJ5nGE,3835
|
41
41
|
classiq/applications/combinatorial_helpers/memory.py,sha256=b-VKPf8UiMxjQR5DICLoeV58noDgVTZz1iK218wvdNo,2283
|
42
42
|
classiq/applications/combinatorial_helpers/optimization_model.py,sha256=Kb9FHLU4ZTsJecD-V8_QoSPuC78Z3Fd16Pu1zhhrRms,7032
|
43
43
|
classiq/applications/combinatorial_helpers/pauli_helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -48,7 +48,7 @@ classiq/applications/combinatorial_helpers/pyomo_utils.py,sha256=DWdrSBlB1ZAVXwe
|
|
48
48
|
classiq/applications/combinatorial_helpers/solvers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
49
49
|
classiq/applications/combinatorial_helpers/sympy_utils.py,sha256=vz85CdjuM-EJmEH0kCTIy5RmPqj_S1g2lb417gMzsks,673
|
50
50
|
classiq/applications/combinatorial_helpers/transformations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
|
-
classiq/applications/combinatorial_helpers/transformations/encoding.py,sha256=
|
51
|
+
classiq/applications/combinatorial_helpers/transformations/encoding.py,sha256=WFN-O96lORThFpOm9v3g_dTkxdk1OWl5b2MAJKVo6mk,7176
|
52
52
|
classiq/applications/combinatorial_helpers/transformations/fixed_variables.py,sha256=nCvQc2F_77NTakWrBaIiGxieWMTbvoMuYZHxnr07KOg,4999
|
53
53
|
classiq/applications/combinatorial_helpers/transformations/ising_converter.py,sha256=MxC8rZuHedKCTWpGC5ARzxiCk9hhYejkH5geCTAoNGI,4480
|
54
54
|
classiq/applications/combinatorial_helpers/transformations/penalty.py,sha256=PJ4_SEcF6waQLBtAFZIvzDH-8-lbKzKTJDTUDwJr4lM,1091
|
@@ -90,12 +90,12 @@ classiq/execution/__init__.py,sha256=t43kgz7GlyB8WT4gY10kr6tBBCTsD95oSWy-AZZZF_8
|
|
90
90
|
classiq/execution/all_hardware_devices.py,sha256=KpLefEISE03FDdgFPGggXeG7NAxBW4090gN4272Dl-E,368
|
91
91
|
classiq/execution/execution_session.py,sha256=txq8bvULxS4nTKJo0LBcmtVoRZVLjrkqdidzGuk-6JE,15832
|
92
92
|
classiq/execution/iqcc.py,sha256=0wy1tgQFcwqf9wFYyi6_OYRtx4s0AEViIAIvUkyKBmk,2429
|
93
|
-
classiq/execution/jobs.py,sha256=
|
93
|
+
classiq/execution/jobs.py,sha256=XCxv2oLF-0XyXmWS5DutuHhvLrmg5thc0j4yBSdvX3Q,9880
|
94
94
|
classiq/execution/qaoa.py,sha256=IiicS_L41FeR_9kDcqLKnbuBuWj5ABuuGKqyC6SVsHk,3007
|
95
95
|
classiq/execution/qnn.py,sha256=6lAKO0TpSEkcY_EwbJfVqNeqCeOegmkBQC1AzUrWxy0,2333
|
96
96
|
classiq/executor.py,sha256=wp8FwEUbtkgXCchmgjHTqgMgNYxC06zR7sSvPlDokvk,2603
|
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=fB8IzJ1NsU_6BSoV8yPoYeKqaym44Sn3aaLqGWhN1IE,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
|
@@ -104,10 +104,10 @@ classiq/interface/applications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
104
104
|
classiq/interface/applications/qsvm.py,sha256=4dHVSZH--sv58SvxmpDHPh9JDr4qQUZbbGCeaEv6b1I,3408
|
105
105
|
classiq/interface/ast_node.py,sha256=EE06R8KwRA-QkK44Ou9TmMxiaa8J60G9Z9qf9T76k_k,398
|
106
106
|
classiq/interface/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
107
|
-
classiq/interface/backend/backend_preferences.py,sha256=
|
107
|
+
classiq/interface/backend/backend_preferences.py,sha256=jNW-3LIb8dPxmJbT6JdIstOeU66hcxmknu9jwLAhOGA,20946
|
108
108
|
classiq/interface/backend/ionq/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
109
109
|
classiq/interface/backend/ionq/ionq_quantum_program.py,sha256=f8w1XvgIggaM_w9TF0_wkQHB3wamXg5kHMNsgtCsH3k,1235
|
110
|
-
classiq/interface/backend/pydantic_backend.py,sha256=
|
110
|
+
classiq/interface/backend/pydantic_backend.py,sha256=6Lv71R6k-_kl2NfO86BcCCHmnMNs9VNbOB56pNVVJyY,1596
|
111
111
|
classiq/interface/backend/quantum_backend_providers.py,sha256=NWjfxwNxtY1tmBCktSVtOEkSDsdcIaHnkH0VQKJ-o8E,6575
|
112
112
|
classiq/interface/chemistry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
113
113
|
classiq/interface/chemistry/ansatz_library.py,sha256=3ki3uaV77cUxUxUzDbn3mVhjvMoKejJ5bIR1kXpBT1k,360
|
@@ -146,7 +146,7 @@ classiq/interface/enum_utils.py,sha256=QxkxLGgON8vdSzLZzHFlPEBJoGOqoIwpESEfLfRqN
|
|
146
146
|
classiq/interface/exceptions.py,sha256=j_FisYmjHhnW0GnYshCSC6TLvkFMdwNzbLRetA15ZhI,4375
|
147
147
|
classiq/interface/execution/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
148
148
|
classiq/interface/execution/iqcc.py,sha256=HmqnkUCJT_rXGp4PIjcqJwDw2IfybxfLZ8MBRGgR6Tg,370
|
149
|
-
classiq/interface/execution/jobs.py,sha256=
|
149
|
+
classiq/interface/execution/jobs.py,sha256=YBHJY4jbZnWILHW-Hm4WUh8bhjfbJAG3pEIAu9EY-O8,736
|
150
150
|
classiq/interface/execution/primitives.py,sha256=_--jsR32K5QwuA5YgU43HGIH-nElBBGnY6SCPBf6-OU,578
|
151
151
|
classiq/interface/execution/resource_estimator.py,sha256=YJRuk9lAkhpwqegjyOrxvEY1TgHzvPnXCMAd-MQC6GE,144
|
152
152
|
classiq/interface/execution/result.py,sha256=6TduBhKFw8j7Yxcgn9d2MA0lm82sEcfY1yWIKUOdHro,139
|
@@ -155,7 +155,7 @@ classiq/interface/executor/aws_execution_cost.py,sha256=0yx_q_-rvaaofaqHyI9YvTtA
|
|
155
155
|
classiq/interface/executor/constants.py,sha256=DtSx-1HArWE0hHjOZHY9WJBevt3hP7M8SrYO3eM3dgo,31
|
156
156
|
classiq/interface/executor/estimation.py,sha256=lJEmN3Uj9bW0EY7JEZvzItwEybbBHSn7zYFz89L8fqo,389
|
157
157
|
classiq/interface/executor/execution_preferences.py,sha256=lEjsv_RGPLrpXBUw55TOZ17lWLEgCJLi3ol9uo1-_Rk,2931
|
158
|
-
classiq/interface/executor/execution_request.py,sha256=
|
158
|
+
classiq/interface/executor/execution_request.py,sha256=bf5qEF4eeb2UQ2DIriW-DBTRmPcDYiWs9QsfmzyhYEg,2441
|
159
159
|
classiq/interface/executor/execution_result.py,sha256=56wymbRd8ukd5QCgZ4o41MAnBHVMhBCNkxlt-zlw7_g,2867
|
160
160
|
classiq/interface/executor/iqae_result.py,sha256=mCjbLTd4vtFOkvEEUfcSp3569wGzQOvFpZO4KKaLnmU,565
|
161
161
|
classiq/interface/executor/optimizer_preferences.py,sha256=iw-UJ_8WhziqB2s8cmQ1jmyTRX1Krpld4CG5tXDWpZ0,4407
|
@@ -249,7 +249,7 @@ classiq/interface/generator/functions/concrete_types.py,sha256=odTCFSdBXx2vjRxGc
|
|
249
249
|
classiq/interface/generator/functions/function_declaration.py,sha256=G0kjoaQeW_OvTTy6TwcKC0BW1pJBn_osIf_Cydj_0ew,595
|
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
|
-
classiq/interface/generator/functions/type_name.py,sha256=
|
252
|
+
classiq/interface/generator/functions/type_name.py,sha256=mzeS-AD2sIrDdaCalTHxKtfZ4ygI9LGmYSIbTmzfol4,2520
|
253
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
|
@@ -401,14 +401,14 @@ classiq/model_expansions/evaluators/arg_type_match.py,sha256=ovN41FwUYr0-t_PbTrt
|
|
401
401
|
classiq/model_expansions/evaluators/argument_types.py,sha256=5KBtDgr_cOaJg9pAfme66P2hKLe9TT_bw39ipYtAumM,1424
|
402
402
|
classiq/model_expansions/evaluators/classical_expression.py,sha256=OM-lPEX9-5IW6DEVZ3GMkSZDqsVDV7WRLItOUaTOvgw,1403
|
403
403
|
classiq/model_expansions/evaluators/control.py,sha256=HxkK1uKKWnMRsbI8e_20i2MJM6y7HqNBw-I_MIaQTtQ,4718
|
404
|
-
classiq/model_expansions/evaluators/parameter_types.py,sha256
|
405
|
-
classiq/model_expansions/evaluators/quantum_type_utils.py,sha256=
|
404
|
+
classiq/model_expansions/evaluators/parameter_types.py,sha256=XCK8dKMemY6ptK3UqOdRqRA_9LsorqiX1-HUoMWc1NQ,7905
|
405
|
+
classiq/model_expansions/evaluators/quantum_type_utils.py,sha256=5H5ri5RW6TLdXhnXV2t0Xe7DeSpMpg4sor_rLVsbwp4,8807
|
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=
|
409
|
+
classiq/model_expansions/function_builder.py,sha256=9KeicLhIaY3inf1BpNqw2u6EcbNg2a2fP1INmqZ2Hjk,7460
|
410
410
|
classiq/model_expansions/generative_functions.py,sha256=bw3KbNCrq72H-jSDZx9npdxha0Po8lV4cqSjneW2Xlo,8465
|
411
|
-
classiq/model_expansions/interpreter.py,sha256=
|
411
|
+
classiq/model_expansions/interpreter.py,sha256=YqGY8c3PnWUbf_caEMa9MeMalGFWM85i1HwQ4duVD1A,15418
|
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
|
@@ -481,7 +481,7 @@ classiq/qmod/generative.py,sha256=3hFrDhAu-WZovuK28f7abVS4lSX7i5aK2GEvrkEqOv4,15
|
|
481
481
|
classiq/qmod/model_state_container.py,sha256=hODhsBvwgH6u6G2dPLyxrJQVx0hKuoc0aFdOkfXtqQ4,844
|
482
482
|
classiq/qmod/native/__init__.py,sha256=gm0L3ew0KAy0eSqaMQrvpnKWx85HoA1p9ADaAlyejdA,126
|
483
483
|
classiq/qmod/native/expression_to_qmod.py,sha256=a33dDr7BGWl7YhsFjpfAuI9Ys7amJjMo4DImSrD4NZg,7143
|
484
|
-
classiq/qmod/native/pretty_printer.py,sha256=
|
484
|
+
classiq/qmod/native/pretty_printer.py,sha256=jbnlknjtd9qblhWg8B1dyVSNxQDWsO1szq1G73XgGco,16008
|
485
485
|
classiq/qmod/pretty_print/__init__.py,sha256=jhR0cpXumOJnyb-zWnvMLpEuUOYPnnJ7DJmV-Zxpy1I,132
|
486
486
|
classiq/qmod/pretty_print/expression_to_python.py,sha256=QoRP817CFEp3Ad3Q3hxWW-hbVzWQbHQIGUHjZkpZDm8,7480
|
487
487
|
classiq/qmod/pretty_print/pretty_printer.py,sha256=KVgAbQXiMjriif1E2DtgBLadkZzvv8lRlipWZ4_AuM4,23135
|
@@ -496,7 +496,8 @@ classiq/qmod/quantum_function.py,sha256=vF2qU8Z1yTtZA6pbVLS0Rjh02A-OTt4VGxbnFGoS
|
|
496
496
|
classiq/qmod/semantics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
497
497
|
classiq/qmod/semantics/annotation.py,sha256=0IeRymMK20sPHzbs7EzGoqhZICQmR6-gXR3SS9sr9OE,1255
|
498
498
|
classiq/qmod/semantics/error_manager.py,sha256=KAnNaQE0YarkXTQ0du3mvCqGCbbH-d81sv2Ti-NpkL4,2783
|
499
|
-
classiq/qmod/semantics/
|
499
|
+
classiq/qmod/semantics/qstruct_annotator.py,sha256=NoWaeKnXYg-XbEUW94tejsa5ZqxSrpRp1rIANrz9OuU,857
|
500
|
+
classiq/qmod/semantics/static_semantics_visitor.py,sha256=Iwl5ozq-x7fDuYpm_Tcu8_atSwFvyZTuqit2Rc6F33M,16218
|
500
501
|
classiq/qmod/semantics/validation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
501
502
|
classiq/qmod/semantics/validation/constants_validation.py,sha256=Z1JV5Er9yXeki2MokRCy-xu8HoGcYsPImrCKZUBZ3A8,652
|
502
503
|
classiq/qmod/semantics/validation/func_call_validation.py,sha256=dcl60jJ3zpTuFyc3hQ6uBYPgdkqVfOHMXTW60f72D9o,3809
|
@@ -508,8 +509,8 @@ classiq/qmod/symbolic_expr.py,sha256=LJoa9c6puMvUu4d5oU0SNzc7VXzSFBUNLf19ADzktLs
|
|
508
509
|
classiq/qmod/symbolic_type.py,sha256=ded7bVfWmHFw8MoyivVDJsG5vZZVRQontOZYb1kCrTQ,162
|
509
510
|
classiq/qmod/type_attribute_remover.py,sha256=NZmTXAsngWqthXjE8n-n6yE72fiWTFM12-TXXJ1kJ-Q,1242
|
510
511
|
classiq/qmod/utilities.py,sha256=z_VnIRmOYTWjJp2UlOcWK0rQRtMqysmP_Gr6WYY_nak,2734
|
511
|
-
classiq/qmod/write_qmod.py,sha256=
|
512
|
+
classiq/qmod/write_qmod.py,sha256=Oo-j_rSfcmzC5MOn0Vq334vv_OTvdD4P7K9pv-gbo8c,1833
|
512
513
|
classiq/synthesis.py,sha256=WLk3wpX_xPiAMstF9PGMO5SWVb_qqa1sN2Nj3MekX34,8113
|
513
|
-
classiq-0.
|
514
|
-
classiq-0.
|
515
|
-
classiq-0.
|
514
|
+
classiq-0.58.0.dist-info/METADATA,sha256=u4WUy-839kPlNe5YcZmsPcGbO2m_xmD8W-bWfHSKbfI,3458
|
515
|
+
classiq-0.58.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
516
|
+
classiq-0.58.0.dist-info/RECORD,,
|
File without changes
|