classiq 0.32.1__py3-none-any.whl → 0.34.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/__init__.py +2 -1
- classiq/_analyzer_extras/_ipywidgets_async_extension.py +1 -1
- classiq/_internals/api_wrapper.py +34 -23
- classiq/_internals/jobs.py +41 -14
- classiq/analyzer/__init__.py +3 -1
- classiq/applications/__init__.py +3 -1
- classiq/applications/benchmarking/__init__.py +3 -1
- classiq/applications/chemistry/__init__.py +3 -1
- classiq/applications/combinatorial_optimization/__init__.py +3 -1
- classiq/applications/combinatorial_optimization/examples/__init__.py +3 -1
- classiq/applications/finance/__init__.py +3 -1
- classiq/applications/qnn/__init__.py +3 -1
- classiq/applications/qnn/datasets/__init__.py +3 -1
- classiq/applications/qsvm/qsvm.py +1 -1
- classiq/applications_model_constructors/grover_model_constructor.py +25 -8
- classiq/builtin_functions/__init__.py +3 -1
- classiq/execution/__init__.py +3 -1
- classiq/execution/jobs.py +57 -20
- classiq/executor.py +4 -11
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +1 -1
- classiq/interface/backend/backend_preferences.py +17 -0
- classiq/interface/backend/pydantic_backend.py +8 -0
- classiq/interface/backend/quantum_backend_providers.py +15 -1
- classiq/interface/chemistry/ground_state_problem.py +1 -1
- classiq/interface/chemistry/operator.py +198 -0
- classiq/interface/executor/execution_request.py +5 -12
- classiq/interface/generator/circuit_code/types_and_constants.py +1 -1
- classiq/interface/generator/complex_type.py +4 -1
- classiq/interface/generator/functions/__init__.py +3 -1
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/__init__.py +0 -1
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/atomic_quantum_functions.py +39 -39
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/std_lib_functions.py +251 -87
- classiq/interface/generator/functions/core_lib_declarations/quantum_operators.py +5 -54
- classiq/interface/generator/generated_circuit.py +14 -43
- classiq/interface/generator/generated_circuit_data.py +26 -34
- classiq/interface/generator/model/preferences/preferences.py +3 -3
- classiq/interface/generator/partitioned_register.py +1 -1
- classiq/interface/generator/quantum_function_call.py +1 -1
- classiq/interface/generator/validations/validator_functions.py +4 -2
- classiq/interface/hardware.py +3 -2
- classiq/interface/ide/show.py +1 -14
- classiq/interface/model/bind_operation.py +20 -0
- classiq/interface/model/handle_binding.py +8 -0
- classiq/interface/model/native_function_definition.py +15 -5
- classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +8 -3
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +9 -4
- classiq/interface/model/quantum_expressions/quantum_expression.py +10 -5
- classiq/interface/model/quantum_function_call.py +24 -347
- classiq/interface/model/quantum_function_declaration.py +7 -11
- classiq/interface/model/quantum_statement.py +13 -7
- classiq/interface/model/validations/handle_validation_base.py +1 -2
- classiq/interface/model/validations/handles_validator.py +34 -8
- classiq/interface/model/variable_declaration_statement.py +8 -0
- classiq/interface/server/routes.py +11 -16
- classiq/model/__init__.py +3 -1
- classiq/model/function_handler.py +1 -1
- classiq/model/function_handler.pyi +88 -88
- classiq/qmod/declaration_inferrer.py +37 -18
- classiq/qmod/model_state_container.py +6 -3
- classiq/qmod/qmod_builtins.py +892 -4
- classiq/qmod/qmod_parameter.py +24 -8
- classiq/qmod/qmod_variable.py +2 -1
- classiq/qmod/quantum_expandable.py +6 -2
- classiq/qmod/quantum_function.py +11 -10
- classiq/quantum_functions/quantum_function.py +4 -1
- {classiq-0.32.1.dist-info → classiq-0.34.0.dist-info}/METADATA +1 -1
- {classiq-0.32.1.dist-info → classiq-0.34.0.dist-info}/RECORD +69 -72
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/apps_lib_functions.py +0 -262
- classiq/interface/model/clients/__init__.py +0 -0
- classiq/interface/model/clients/qmod/__init__.py +0 -0
- classiq/interface/model/clients/qmod/qmod_builtins.py +0 -908
- classiq/interface/model/semantics.py +0 -15
- {classiq-0.32.1.dist-info → classiq-0.34.0.dist-info}/WHEEL +0 -0
@@ -6,7 +6,9 @@ import pydantic
|
|
6
6
|
AZURE_QUANTUM_RESOURCE_ID_REGEX = r"^/subscriptions/([a-fA-F0-9-]*)/resourceGroups/([^\s/]*)/providers/Microsoft\.Quantum/Workspaces/([^\s/]*)$"
|
7
7
|
|
8
8
|
_IONQ_API_KEY_LENGTH: int = 32
|
9
|
+
_ALICE_BOB_API_KEY_LENGTH: int = 72
|
9
10
|
INVALID_API_KEY: str = _IONQ_API_KEY_LENGTH * "a"
|
11
|
+
INVALID_API_KEY_ALICE_BOB: str = _ALICE_BOB_API_KEY_LENGTH * "a"
|
10
12
|
MAX_EXECUTION_TIMEOUT_SECONDS = timedelta(hours=4).total_seconds()
|
11
13
|
|
12
14
|
if TYPE_CHECKING:
|
@@ -18,6 +20,7 @@ if TYPE_CHECKING:
|
|
18
20
|
PydanticIonQApiKeyType = str
|
19
21
|
PydanticArgumentNameType = str
|
20
22
|
PydanticExecutionParameter = str
|
23
|
+
PydanticAliceBobApiKeyType = str
|
21
24
|
else:
|
22
25
|
# TODO Simplify regular expressions in this file
|
23
26
|
|
@@ -32,6 +35,11 @@ else:
|
|
32
35
|
PydanticIonQApiKeyType = pydantic.constr(
|
33
36
|
regex=f"[A-Za-z0-9]{{{_IONQ_API_KEY_LENGTH}}}"
|
34
37
|
)
|
38
|
+
|
39
|
+
PydanticAliceBobApiKeyType = pydantic.constr(
|
40
|
+
regex=f"[A-Za-z0-9]{{{_ALICE_BOB_API_KEY_LENGTH}}}"
|
41
|
+
)
|
42
|
+
|
35
43
|
PydanticExecutionTimeout = pydantic.conint(gt=0, le=MAX_EXECUTION_TIMEOUT_SECONDS)
|
36
44
|
|
37
45
|
PydanticArgumentNameType = pydantic.constr(regex="[_a-zA-Z][_a-zA-Z0-9]*")
|
@@ -16,6 +16,7 @@ class ProviderVendor(StrEnum):
|
|
16
16
|
AMAZON_BRAKET = "Amazon Braket"
|
17
17
|
IONQ = "IonQ"
|
18
18
|
GOOGLE = "Google"
|
19
|
+
ALICE_AND_BOB = "Alice and Bob"
|
19
20
|
|
20
21
|
|
21
22
|
class ProviderTypeVendor:
|
@@ -25,6 +26,7 @@ class ProviderTypeVendor:
|
|
25
26
|
AMAZON_BRAKET = Literal[ProviderVendor.AMAZON_BRAKET]
|
26
27
|
IONQ = Literal[ProviderVendor.IONQ]
|
27
28
|
GOOGLE = Literal[ProviderVendor.GOOGLE]
|
29
|
+
ALICE_BOB = Literal[ProviderVendor.ALICE_AND_BOB]
|
28
30
|
|
29
31
|
|
30
32
|
class ClassiqAerBackendNames(StrEnum):
|
@@ -45,11 +47,13 @@ class AzureQuantumBackendNames(StrEnum):
|
|
45
47
|
IONQ_ARIA_1 = "ionq.qpu.aria-1"
|
46
48
|
IONQ_ARIA_2 = "ionq.qpu.aria-2"
|
47
49
|
IONQ_QPU = "ionq.qpu"
|
50
|
+
IONQ_QPU_FORTE = "ionq.qpu.forte-1"
|
48
51
|
IONQ_SIMULATOR = "ionq.simulator"
|
49
52
|
MICROSOFT_ESTIMATOR = "microsoft.estimator"
|
50
53
|
MICROSOFT_FULLSTATE_SIMULATOR = "microsoft.simulator.fullstate"
|
51
54
|
RIGETTI_ASPEN3 = "rigetti.qpu.aspen-m-3"
|
52
55
|
RIGETTI_SIMULATOR = "rigetti.sim.qvm"
|
56
|
+
RIGETTI_ANKAA2 = "rigetti.qpu.ankaa-2"
|
53
57
|
QCI_MACHINE1 = "qci.machine1"
|
54
58
|
QCI_NOISY_SIMULATOR = "qci.simulator.noisy"
|
55
59
|
QCI_SIMULATOR = "qci.simulator"
|
@@ -141,6 +145,17 @@ class GoogleNvidiaBackendNames(StrEnum):
|
|
141
145
|
CUQUANTUM = "cuquantum"
|
142
146
|
|
143
147
|
|
148
|
+
class AliceBobBackendNames(StrEnum):
|
149
|
+
PHYSICAL_CATS_40 = "EMU:40Q:PHYSICAL_CATS"
|
150
|
+
PERFECT_QUBITS = "EMU:20Q:PERFECT_QUBITS"
|
151
|
+
LOGICAL_TARGET = "EMU:40Q:LOGICAL_TARGET"
|
152
|
+
PHYSICAL_CATS_6 = "EMU:6Q:PHYSICAL_CATS"
|
153
|
+
LOGICAL_EARLY = "EMU:15Q:LOGICAL_EARLY"
|
154
|
+
LESCANNE = "EMU:1Q:LESCANNE_2020"
|
155
|
+
TRANSMONS = "EMU:7Q:TRANSMONS"
|
156
|
+
FATCAT = "QPU:1Q:FATCAT_0"
|
157
|
+
|
158
|
+
|
144
159
|
EXACT_SIMULATORS = {
|
145
160
|
IonqBackendNames.SIMULATOR,
|
146
161
|
AzureQuantumBackendNames.IONQ_SIMULATOR,
|
@@ -154,7 +169,6 @@ EXACT_SIMULATORS = {
|
|
154
169
|
|
155
170
|
AllIBMQBackendNames = IBMQHardwareNames
|
156
171
|
|
157
|
-
|
158
172
|
AllBackendsNameByVendor = Union[
|
159
173
|
AllIBMQBackendNames,
|
160
174
|
AzureQuantumBackendNames,
|
@@ -64,7 +64,7 @@ class GroundStateProblem(HashablePydanticBaseModel):
|
|
64
64
|
|
65
65
|
|
66
66
|
class MoleculeProblem(GroundStateProblem):
|
67
|
-
molecule: Molecule
|
67
|
+
molecule: Molecule
|
68
68
|
basis: str = pydantic.Field(default="sto3g", description="Molecular basis set")
|
69
69
|
freeze_core: bool = pydantic.Field(default=False)
|
70
70
|
remove_orbitals: List[int] = pydantic.Field(
|
@@ -224,6 +224,204 @@ class PauliOperator(HashablePydanticBaseModel, VersionedModel):
|
|
224
224
|
frozen = True
|
225
225
|
|
226
226
|
|
227
|
+
class PauliOperatorV1(HashablePydanticBaseModel):
|
228
|
+
"""
|
229
|
+
Specification of a Pauli sum operator.
|
230
|
+
"""
|
231
|
+
|
232
|
+
pauli_list: PydanticPauliList = pydantic.Field(
|
233
|
+
description="A list of tuples each containing a pauli string comprised of I,X,Y,Z characters and a complex coefficient; for example [('IZ', 0.1), ('XY', 0.2)].",
|
234
|
+
)
|
235
|
+
is_hermitian: bool = pydantic.Field(default=False)
|
236
|
+
has_complex_coefficients: bool = pydantic.Field(default=True)
|
237
|
+
|
238
|
+
def show(self) -> str:
|
239
|
+
if self.is_hermitian:
|
240
|
+
# If the operator is hermitian then the coefficients must be numeric
|
241
|
+
return "\n".join(
|
242
|
+
f"{summand[1].real:+.3f} * {summand[0]}" for summand in self.pauli_list # type: ignore[union-attr]
|
243
|
+
)
|
244
|
+
return "\n".join(
|
245
|
+
f"+({summand[1]:+.3f}) * {summand[0]}" for summand in self.pauli_list
|
246
|
+
)
|
247
|
+
|
248
|
+
@pydantic.validator("pauli_list", each_item=True, pre=True)
|
249
|
+
def _validate_pauli_monomials(
|
250
|
+
cls, monomial: Tuple[PydanticPauliMonomialStr, ParameterComplexType]
|
251
|
+
) -> Tuple[PydanticPauliMonomialStr, ParameterComplexType]:
|
252
|
+
_PauliMonomialLengthValidator( # type: ignore[call-arg]
|
253
|
+
monomial=monomial
|
254
|
+
) # Validate the length of the monomial.
|
255
|
+
coeff = cls._validate_monomial_coefficient(monomial[1])
|
256
|
+
parsed_monomial = _PauliMonomialParser(string=monomial[0], coeff=coeff) # type: ignore[call-arg]
|
257
|
+
return (parsed_monomial.string, parsed_monomial.coeff)
|
258
|
+
|
259
|
+
@staticmethod
|
260
|
+
def _validate_monomial_coefficient(
|
261
|
+
coeff: Union[sympy.Expr, ParameterComplexType]
|
262
|
+
) -> ParameterComplexType:
|
263
|
+
if isinstance(coeff, str):
|
264
|
+
validate_expression_str(coeff)
|
265
|
+
elif isinstance(coeff, sympy.Expr):
|
266
|
+
coeff = str(coeff)
|
267
|
+
return coeff
|
268
|
+
|
269
|
+
@pydantic.validator("pauli_list")
|
270
|
+
def _validate_pauli_list(cls, pauli_list: PydanticPauliList) -> PydanticPauliList:
|
271
|
+
if not all_equal(len(summand[0]) for summand in pauli_list):
|
272
|
+
raise ValueError("Pauli strings have incompatible lengths.")
|
273
|
+
return pauli_list
|
274
|
+
|
275
|
+
@pydantic.root_validator
|
276
|
+
def _validate_hermitianity(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
277
|
+
pauli_list = values.get("pauli_list", [])
|
278
|
+
if all(isinstance(summand[1], complex) for summand in pauli_list):
|
279
|
+
values["is_hermitian"] = all(
|
280
|
+
np.isclose(complex(summand[1]).real, summand[1])
|
281
|
+
for summand in pauli_list
|
282
|
+
)
|
283
|
+
if values.get("is_hermitian", False):
|
284
|
+
values["has_complex_coefficients"] = False
|
285
|
+
values["pauli_list"] = [
|
286
|
+
(summand[0], complex(summand[1].real)) for summand in pauli_list
|
287
|
+
]
|
288
|
+
else:
|
289
|
+
values["has_complex_coefficients"] = not all(
|
290
|
+
np.isclose(complex(summand[1]).real, summand[1])
|
291
|
+
for summand in pauli_list
|
292
|
+
if isinstance(summand[1], complex)
|
293
|
+
)
|
294
|
+
return values
|
295
|
+
|
296
|
+
def __mul__(self, coefficient: complex) -> "PauliOperatorV1":
|
297
|
+
multiplied_ising = [
|
298
|
+
(monomial[0], self._multiply_monomial_coefficient(monomial[1], coefficient))
|
299
|
+
for monomial in self.pauli_list
|
300
|
+
]
|
301
|
+
return self.__class__(pauli_list=multiplied_ising)
|
302
|
+
|
303
|
+
@staticmethod
|
304
|
+
def _multiply_monomial_coefficient(
|
305
|
+
monomial_coefficient: ParameterComplexType, coefficient: complex
|
306
|
+
) -> ParameterComplexType:
|
307
|
+
if isinstance(monomial_coefficient, ParameterType):
|
308
|
+
return str(sympy.sympify(monomial_coefficient) * coefficient)
|
309
|
+
return monomial_coefficient * coefficient
|
310
|
+
|
311
|
+
@property
|
312
|
+
def is_commutative(self) -> bool:
|
313
|
+
return all(
|
314
|
+
self._is_sub_pauli_commutative(
|
315
|
+
[summand[0][qubit_num] for summand in self.pauli_list]
|
316
|
+
)
|
317
|
+
for qubit_num in range(self.num_qubits)
|
318
|
+
)
|
319
|
+
|
320
|
+
@staticmethod
|
321
|
+
def _is_sub_pauli_commutative(qubit_pauli_string: Union[List[str], str]) -> bool:
|
322
|
+
unique_paulis = set(qubit_pauli_string) - {"I"}
|
323
|
+
return len(unique_paulis) <= 1
|
324
|
+
|
325
|
+
@property
|
326
|
+
def num_qubits(self) -> int:
|
327
|
+
return len(self.pauli_list[0][0])
|
328
|
+
|
329
|
+
def to_matrix(self) -> np.ndarray:
|
330
|
+
if not all(isinstance(summand[1], complex) for summand in self.pauli_list):
|
331
|
+
raise ClassiqValueError(
|
332
|
+
"Supporting only Hamiltonian with numeric coefficients."
|
333
|
+
)
|
334
|
+
return sum(
|
335
|
+
cast(complex, summand[1]) * to_pauli_matrix(summand[0])
|
336
|
+
for summand in self.pauli_list
|
337
|
+
) # type: ignore[return-value]
|
338
|
+
|
339
|
+
@staticmethod
|
340
|
+
def _extend_pauli_string(
|
341
|
+
pauli_string: PydanticPauliMonomialStr, num_extra_qubits: int
|
342
|
+
) -> PydanticPauliMonomialStr:
|
343
|
+
return "I" * num_extra_qubits + pauli_string
|
344
|
+
|
345
|
+
def extend(self, num_extra_qubits: int) -> "PauliOperatorV1":
|
346
|
+
new_pauli_list = [
|
347
|
+
(self._extend_pauli_string(pauli_string, num_extra_qubits), coeff)
|
348
|
+
for (pauli_string, coeff) in self.pauli_list
|
349
|
+
]
|
350
|
+
return self.copy(update={"pauli_list": new_pauli_list}, deep=True)
|
351
|
+
|
352
|
+
@staticmethod
|
353
|
+
def _reorder_pauli_string(
|
354
|
+
pauli_string: PydanticPauliMonomialStr,
|
355
|
+
order: Collection[int],
|
356
|
+
new_num_qubits: int,
|
357
|
+
) -> PydanticPauliMonomialStr:
|
358
|
+
reversed_pauli_string = pauli_string[::-1]
|
359
|
+
reversed_new_pauli_string = ["I"] * new_num_qubits
|
360
|
+
|
361
|
+
for logical_pos, actual_pos in enumerate(order):
|
362
|
+
reversed_new_pauli_string[actual_pos] = reversed_pauli_string[logical_pos]
|
363
|
+
|
364
|
+
return "".join(reversed(reversed_new_pauli_string))
|
365
|
+
|
366
|
+
@staticmethod
|
367
|
+
def _validate_reorder(
|
368
|
+
order: Collection[int],
|
369
|
+
num_qubits: int,
|
370
|
+
num_extra_qubits: int,
|
371
|
+
) -> None:
|
372
|
+
if num_extra_qubits < 0:
|
373
|
+
raise ValueError("Number of extra qubits cannot be negative")
|
374
|
+
|
375
|
+
if len(order) != num_qubits:
|
376
|
+
raise ValueError("The qubits order doesn't match the Pauli operator")
|
377
|
+
|
378
|
+
if len(order) != len(set(order)):
|
379
|
+
raise ValueError("The qubits order is not one-to-one")
|
380
|
+
|
381
|
+
if not all(pos < num_qubits + num_extra_qubits for pos in order):
|
382
|
+
raise ValueError("The qubits order contains qubits which do no exist")
|
383
|
+
|
384
|
+
@classmethod
|
385
|
+
def reorder(
|
386
|
+
cls,
|
387
|
+
operator: "PauliOperatorV1",
|
388
|
+
order: Collection[int],
|
389
|
+
num_extra_qubits: int = 0,
|
390
|
+
) -> "PauliOperatorV1":
|
391
|
+
cls._validate_reorder(order, operator.num_qubits, num_extra_qubits)
|
392
|
+
|
393
|
+
new_num_qubits = operator.num_qubits + num_extra_qubits
|
394
|
+
new_pauli_list = [
|
395
|
+
(cls._reorder_pauli_string(pauli_string, order, new_num_qubits), coeff)
|
396
|
+
for pauli_string, coeff in operator.pauli_list
|
397
|
+
]
|
398
|
+
return cls(pauli_list=new_pauli_list)
|
399
|
+
|
400
|
+
@classmethod
|
401
|
+
def from_unzipped_lists(
|
402
|
+
cls,
|
403
|
+
operators: List[List[Pauli]],
|
404
|
+
coefficients: Optional[List[complex]] = None,
|
405
|
+
) -> "PauliOperatorV1":
|
406
|
+
if coefficients is None:
|
407
|
+
coefficients = [1] * len(operators)
|
408
|
+
|
409
|
+
if len(operators) != len(coefficients):
|
410
|
+
raise ValueError(
|
411
|
+
f"The number of coefficients ({len(coefficients)}) must be equal to the number of pauli operators ({len(operators)})"
|
412
|
+
)
|
413
|
+
|
414
|
+
return cls(
|
415
|
+
pauli_list=[
|
416
|
+
(pauli_integers_to_str(op), coeff)
|
417
|
+
for op, coeff in zip(operators, coefficients)
|
418
|
+
]
|
419
|
+
)
|
420
|
+
|
421
|
+
class Config:
|
422
|
+
frozen = True
|
423
|
+
|
424
|
+
|
227
425
|
# This class validates the length of a monomial.
|
228
426
|
@pydantic.dataclasses.dataclass
|
229
427
|
class _PauliMonomialLengthValidator:
|
@@ -15,10 +15,7 @@ from classiq.interface.executor.quantum_program import (
|
|
15
15
|
)
|
16
16
|
from classiq.interface.executor.result import EstimationResult, ExecutionDetails
|
17
17
|
from classiq.interface.executor.vqe_result import VQESolverResult
|
18
|
-
from classiq.interface.generator.generated_circuit import
|
19
|
-
ExecutionCircuit,
|
20
|
-
GeneratedCircuit,
|
21
|
-
)
|
18
|
+
from classiq.interface.generator.generated_circuit import GeneratedCircuit
|
22
19
|
from classiq.interface.helpers.versioned_model import VersionedModel
|
23
20
|
from classiq.interface.jobs import JobStatus
|
24
21
|
|
@@ -29,10 +26,6 @@ class GeneratedCircuitExecution(GeneratedCircuit):
|
|
29
26
|
execution_type: Literal["generated_circuit"] = "generated_circuit"
|
30
27
|
|
31
28
|
|
32
|
-
class BareGeneratedCircuitExecution(ExecutionCircuit):
|
33
|
-
execution_type: Literal["bare_generated_circuit"] = "bare_generated_circuit"
|
34
|
-
|
35
|
-
|
36
29
|
class QuantumProgramExecution(QuantumProgram):
|
37
30
|
execution_type: Literal["quantum_program"] = "quantum_program"
|
38
31
|
|
@@ -42,10 +35,7 @@ class EstimateOperatorsExecution(OperatorsEstimation):
|
|
42
35
|
|
43
36
|
|
44
37
|
ExecutionPayloads = Union[
|
45
|
-
GeneratedCircuitExecution,
|
46
|
-
BareGeneratedCircuitExecution,
|
47
|
-
QuantumProgramExecution,
|
48
|
-
EstimateOperatorsExecution,
|
38
|
+
GeneratedCircuitExecution, QuantumProgramExecution, EstimateOperatorsExecution
|
49
39
|
]
|
50
40
|
|
51
41
|
|
@@ -175,6 +165,9 @@ class ExecutionJobDetails(VersionedModel):
|
|
175
165
|
status: JobStatus
|
176
166
|
|
177
167
|
num_shots: Optional[int]
|
168
|
+
program_id: Optional[str]
|
169
|
+
|
170
|
+
error: Optional[str]
|
178
171
|
|
179
172
|
|
180
173
|
class ExecutionJobsQueryResults(VersionedModel):
|
@@ -1,4 +1,7 @@
|
|
1
|
+
from typing import Any
|
2
|
+
|
1
3
|
import pydantic.json
|
4
|
+
from typing_extensions import Self
|
2
5
|
|
3
6
|
|
4
7
|
# Use this class as a type for complex data from the json, e.g., in the state_propagator function.
|
@@ -14,7 +17,7 @@ class Complex(complex):
|
|
14
17
|
)
|
15
18
|
|
16
19
|
@classmethod
|
17
|
-
def validate(cls, v):
|
20
|
+
def validate(cls, v: Any) -> Self:
|
18
21
|
if isinstance(v, str):
|
19
22
|
v = "".join(v.split())
|
20
23
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
from typing import List
|
2
|
+
|
1
3
|
import classiq.interface.generator.functions.core_lib_declarations.quantum_functions
|
2
4
|
import classiq.interface.generator.functions.core_lib_declarations.quantum_operators # noqa: F401
|
3
5
|
from classiq.interface.generator.functions.foreign_function_definition import *
|
@@ -17,5 +19,5 @@ __all__ = [ # noqa: F405
|
|
17
19
|
]
|
18
20
|
|
19
21
|
|
20
|
-
def __dir__():
|
22
|
+
def __dir__() -> List[str]:
|
21
23
|
return __all__
|
@@ -3,7 +3,6 @@ from classiq.interface.model.quantum_function_declaration import (
|
|
3
3
|
QuantumFunctionDeclaration,
|
4
4
|
)
|
5
5
|
|
6
|
-
from .apps_lib_functions import * # noqa: F403
|
7
6
|
from .atomic_quantum_functions import * # noqa: F403
|
8
7
|
from .exponentiation_functions import * # noqa: F403
|
9
8
|
from .std_lib_functions import * # noqa: F403
|
@@ -225,13 +225,13 @@ RZZ_FUNCTION = QuantumFunctionDeclaration(
|
|
225
225
|
CH_FUNCTION = QuantumFunctionDeclaration(
|
226
226
|
name="CH",
|
227
227
|
port_declarations={
|
228
|
-
"
|
229
|
-
name="
|
228
|
+
"control": PortDeclaration(
|
229
|
+
name="control",
|
230
230
|
direction=PortDeclarationDirection.Inout,
|
231
231
|
size=Expression(expr="1"),
|
232
232
|
),
|
233
|
-
"
|
234
|
-
name="
|
233
|
+
"target": PortDeclaration(
|
234
|
+
name="target",
|
235
235
|
direction=PortDeclarationDirection.Inout,
|
236
236
|
size=Expression(expr="1"),
|
237
237
|
),
|
@@ -242,13 +242,13 @@ CH_FUNCTION = QuantumFunctionDeclaration(
|
|
242
242
|
CX_FUNCTION = QuantumFunctionDeclaration(
|
243
243
|
name="CX",
|
244
244
|
port_declarations={
|
245
|
-
"
|
246
|
-
name="
|
245
|
+
"control": PortDeclaration(
|
246
|
+
name="control",
|
247
247
|
direction=PortDeclarationDirection.Inout,
|
248
248
|
size=Expression(expr="1"),
|
249
249
|
),
|
250
|
-
"
|
251
|
-
name="
|
250
|
+
"target": PortDeclaration(
|
251
|
+
name="target",
|
252
252
|
direction=PortDeclarationDirection.Inout,
|
253
253
|
size=Expression(expr="1"),
|
254
254
|
),
|
@@ -259,13 +259,13 @@ CX_FUNCTION = QuantumFunctionDeclaration(
|
|
259
259
|
CY_FUNCTION = QuantumFunctionDeclaration(
|
260
260
|
name="CY",
|
261
261
|
port_declarations={
|
262
|
-
"
|
263
|
-
name="
|
262
|
+
"control": PortDeclaration(
|
263
|
+
name="control",
|
264
264
|
direction=PortDeclarationDirection.Inout,
|
265
265
|
size=Expression(expr="1"),
|
266
266
|
),
|
267
|
-
"
|
268
|
-
name="
|
267
|
+
"target": PortDeclaration(
|
268
|
+
name="target",
|
269
269
|
direction=PortDeclarationDirection.Inout,
|
270
270
|
size=Expression(expr="1"),
|
271
271
|
),
|
@@ -276,13 +276,13 @@ CY_FUNCTION = QuantumFunctionDeclaration(
|
|
276
276
|
CZ_FUNCTION = QuantumFunctionDeclaration(
|
277
277
|
name="CZ",
|
278
278
|
port_declarations={
|
279
|
-
"
|
280
|
-
name="
|
279
|
+
"control": PortDeclaration(
|
280
|
+
name="control",
|
281
281
|
direction=PortDeclarationDirection.Inout,
|
282
282
|
size=Expression(expr="1"),
|
283
283
|
),
|
284
|
-
"
|
285
|
-
name="
|
284
|
+
"target": PortDeclaration(
|
285
|
+
name="target",
|
286
286
|
direction=PortDeclarationDirection.Inout,
|
287
287
|
size=Expression(expr="1"),
|
288
288
|
),
|
@@ -296,13 +296,13 @@ CRX_FUNCTION = QuantumFunctionDeclaration(
|
|
296
296
|
"theta": Real(),
|
297
297
|
},
|
298
298
|
port_declarations={
|
299
|
-
"
|
300
|
-
name="
|
299
|
+
"control": PortDeclaration(
|
300
|
+
name="control",
|
301
301
|
direction=PortDeclarationDirection.Inout,
|
302
302
|
size=Expression(expr="1"),
|
303
303
|
),
|
304
|
-
"
|
305
|
-
name="
|
304
|
+
"target": PortDeclaration(
|
305
|
+
name="target",
|
306
306
|
direction=PortDeclarationDirection.Inout,
|
307
307
|
size=Expression(expr="1"),
|
308
308
|
),
|
@@ -316,13 +316,13 @@ CRY_FUNCTION = QuantumFunctionDeclaration(
|
|
316
316
|
"theta": Real(),
|
317
317
|
},
|
318
318
|
port_declarations={
|
319
|
-
"
|
320
|
-
name="
|
319
|
+
"control": PortDeclaration(
|
320
|
+
name="control",
|
321
321
|
direction=PortDeclarationDirection.Inout,
|
322
322
|
size=Expression(expr="1"),
|
323
323
|
),
|
324
|
-
"
|
325
|
-
name="
|
324
|
+
"target": PortDeclaration(
|
325
|
+
name="target",
|
326
326
|
direction=PortDeclarationDirection.Inout,
|
327
327
|
size=Expression(expr="1"),
|
328
328
|
),
|
@@ -336,13 +336,13 @@ CRZ_FUNCTION = QuantumFunctionDeclaration(
|
|
336
336
|
"theta": Real(),
|
337
337
|
},
|
338
338
|
port_declarations={
|
339
|
-
"
|
340
|
-
name="
|
339
|
+
"control": PortDeclaration(
|
340
|
+
name="control",
|
341
341
|
direction=PortDeclarationDirection.Inout,
|
342
342
|
size=Expression(expr="1"),
|
343
343
|
),
|
344
|
-
"
|
345
|
-
name="
|
344
|
+
"target": PortDeclaration(
|
345
|
+
name="target",
|
346
346
|
direction=PortDeclarationDirection.Inout,
|
347
347
|
size=Expression(expr="1"),
|
348
348
|
),
|
@@ -356,13 +356,13 @@ CPHASE_FUNCTION = QuantumFunctionDeclaration(
|
|
356
356
|
"theta": Real(),
|
357
357
|
},
|
358
358
|
port_declarations={
|
359
|
-
"
|
360
|
-
name="
|
359
|
+
"control": PortDeclaration(
|
360
|
+
name="control",
|
361
361
|
direction=PortDeclarationDirection.Inout,
|
362
362
|
size=Expression(expr="1"),
|
363
363
|
),
|
364
|
-
"
|
365
|
-
name="
|
364
|
+
"target": PortDeclaration(
|
365
|
+
name="target",
|
366
366
|
direction=PortDeclarationDirection.Inout,
|
367
367
|
size=Expression(expr="1"),
|
368
368
|
),
|
@@ -441,11 +441,11 @@ ADD_FUNCTION = QuantumFunctionDeclaration(
|
|
441
441
|
port_declarations={
|
442
442
|
"left": PortDeclaration(
|
443
443
|
name="left",
|
444
|
-
direction=PortDeclarationDirection.
|
444
|
+
direction=PortDeclarationDirection.Inout,
|
445
445
|
),
|
446
446
|
"right": PortDeclaration(
|
447
447
|
name="right",
|
448
|
-
direction=PortDeclarationDirection.
|
448
|
+
direction=PortDeclarationDirection.Inout,
|
449
449
|
),
|
450
450
|
"result": PortDeclaration(
|
451
451
|
name="result",
|
@@ -472,16 +472,16 @@ U_FUNCTION = QuantumFunctionDeclaration(
|
|
472
472
|
CCX_FUNCTION = QuantumFunctionDeclaration(
|
473
473
|
name="CCX",
|
474
474
|
port_declarations={
|
475
|
-
"target": PortDeclaration(
|
476
|
-
name="target",
|
477
|
-
direction=PortDeclarationDirection.Inout,
|
478
|
-
size=Expression(expr="1"),
|
479
|
-
),
|
480
475
|
"control": PortDeclaration(
|
481
476
|
name="control",
|
482
477
|
direction=PortDeclarationDirection.Inout,
|
483
478
|
size=Expression(expr="2"),
|
484
479
|
),
|
480
|
+
"target": PortDeclaration(
|
481
|
+
name="target",
|
482
|
+
direction=PortDeclarationDirection.Inout,
|
483
|
+
size=Expression(expr="1"),
|
484
|
+
),
|
485
485
|
},
|
486
486
|
)
|
487
487
|
|