classiq 0.36.0__py3-none-any.whl → 0.37.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 +1 -0
- classiq/_internals/api_wrapper.py +24 -6
- classiq/_internals/authentication/device.py +6 -3
- classiq/_internals/authentication/token_manager.py +21 -5
- classiq/_internals/client.py +7 -2
- classiq/_internals/config.py +12 -0
- classiq/_internals/host_checker.py +1 -1
- classiq/_internals/jobs.py +3 -1
- classiq/_internals/type_validation.py +3 -6
- classiq/analyzer/analyzer.py +1 -0
- classiq/analyzer/rb.py +3 -5
- classiq/applications_model_constructors/chemistry_model_constructor.py +42 -67
- classiq/applications_model_constructors/grover_model_constructor.py +27 -18
- classiq/exceptions.py +5 -0
- classiq/execution/jobs.py +13 -4
- classiq/executor.py +3 -2
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +0 -6
- classiq/interface/analyzer/result.py +0 -4
- classiq/interface/backend/backend_preferences.py +2 -2
- classiq/interface/backend/quantum_backend_providers.py +1 -1
- classiq/interface/execution/resource_estimator.py +7 -0
- classiq/interface/execution/result.py +5 -0
- classiq/interface/executor/register_initialization.py +3 -1
- classiq/interface/executor/vqe_result.py +1 -0
- classiq/interface/generator/ansatz_library.py +3 -3
- classiq/interface/generator/arith/argument_utils.py +4 -4
- classiq/interface/generator/arith/arithmetic.py +4 -2
- classiq/interface/generator/arith/arithmetic_arg_type_validator.py +11 -5
- classiq/interface/generator/arith/arithmetic_expression_parser.py +8 -7
- classiq/interface/generator/arith/arithmetic_operations.py +7 -0
- classiq/interface/generator/arith/arithmetic_param_getters.py +97 -16
- classiq/interface/generator/arith/arithmetic_result_builder.py +13 -3
- classiq/interface/generator/arith/binary_ops.py +8 -10
- classiq/interface/generator/arith/extremum_operations.py +2 -2
- classiq/interface/generator/arith/number_utils.py +20 -23
- classiq/interface/generator/arith/register_user_input.py +3 -1
- classiq/interface/generator/arith/unary_ops.py +9 -13
- classiq/interface/generator/expressions/atomic_expression_functions.py +2 -0
- classiq/interface/generator/expressions/expression.py +7 -2
- classiq/interface/generator/expressions/qmod_qnum_proxy.py +22 -0
- classiq/interface/generator/expressions/qmod_sized_proxy.py +2 -12
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/atomic_quantum_functions.py +63 -3
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/std_lib_functions.py +143 -17
- classiq/interface/generator/functions/core_lib_declarations/quantum_operators.py +41 -16
- classiq/interface/generator/functions/native_function_definition.py +3 -3
- classiq/interface/generator/model/constraints.py +3 -3
- classiq/interface/generator/model/preferences/preferences.py +13 -9
- classiq/interface/generator/noise_properties.py +5 -5
- classiq/interface/generator/qpe.py +5 -5
- classiq/interface/generator/quantum_function_call.py +5 -3
- classiq/interface/generator/randomized_benchmarking.py +5 -3
- classiq/interface/generator/visitor.py +1 -2
- classiq/interface/hardware.py +1 -1
- classiq/interface/helpers/custom_pydantic_types.py +6 -0
- classiq/interface/model/{modular_addition_operation.py → inplace_binary_operation.py} +16 -2
- classiq/interface/model/native_function_definition.py +2 -24
- classiq/interface/model/operator_synthesis_data.py +6 -0
- classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +8 -4
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +9 -5
- classiq/interface/model/quantum_expressions/control_state.py +38 -0
- classiq/interface/model/quantum_expressions/quantum_expression.py +21 -11
- classiq/interface/model/quantum_function_call.py +81 -6
- classiq/interface/model/quantum_function_declaration.py +3 -3
- classiq/interface/model/quantum_if_operation.py +95 -0
- classiq/interface/model/resolvers/function_call_resolver.py +1 -1
- classiq/interface/model/validations/handles_validator.py +42 -15
- classiq/interface/server/routes.py +10 -6
- classiq/model/function_handler.pyi +86 -86
- classiq/model/model.py +1 -0
- classiq/qmod/__init__.py +6 -1
- classiq/qmod/builtins/__init__.py +13 -1
- classiq/qmod/builtins/classical_execution_primitives.py +109 -0
- classiq/qmod/builtins/classical_functions.py +68 -0
- classiq/qmod/builtins/functions.py +88 -18
- classiq/qmod/builtins/operations.py +60 -35
- classiq/qmod/classical_function.py +40 -0
- classiq/qmod/declaration_inferrer.py +5 -2
- classiq/qmod/qmod_variable.py +17 -10
- classiq/qmod/quantum_callable.py +24 -3
- classiq/qmod/quantum_expandable.py +131 -21
- classiq/qmod/quantum_function.py +12 -2
- classiq/qmod/symbolic.py +182 -107
- classiq/qmod/symbolic_expr.py +11 -10
- classiq/qmod/symbolic_type.py +8 -0
- classiq/quantum_functions/decorators.py +2 -4
- classiq/quantum_functions/function_library.py +1 -0
- {classiq-0.36.0.dist-info → classiq-0.37.0.dist-info}/METADATA +1 -1
- {classiq-0.36.0.dist-info → classiq-0.37.0.dist-info}/RECORD +90 -82
- classiq/interface/model/local_variable_declaration.py +0 -7
- {classiq-0.36.0.dist-info → classiq-0.37.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
from sympy import Symbol
|
2
|
+
|
3
|
+
from classiq.interface.generator.expressions.qmod_sized_proxy import QmodSizedProxy
|
4
|
+
from classiq.interface.model.quantum_type import QuantumNumeric
|
5
|
+
|
6
|
+
|
7
|
+
class QmodQNumProxy(Symbol, QmodSizedProxy):
|
8
|
+
def __new__(cls, name, **assumptions):
|
9
|
+
return super().__new__(cls, name, **assumptions)
|
10
|
+
|
11
|
+
def __init__(self, name: str, quantum_type: QuantumNumeric) -> None:
|
12
|
+
super().__init__(quantum_type.size_in_bits)
|
13
|
+
self._fraction_digits = quantum_type.fraction_digits
|
14
|
+
self._is_signed = quantum_type.is_signed
|
15
|
+
|
16
|
+
@property
|
17
|
+
def fraction_digits(self) -> int:
|
18
|
+
return self._fraction_digits
|
19
|
+
|
20
|
+
@property
|
21
|
+
def is_signed(self) -> bool:
|
22
|
+
return self._is_signed
|
@@ -1,16 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class QmodSizedProxy(Symbol):
|
5
|
-
def __new__(cls, name, **assumptions):
|
6
|
-
return super().__new__(cls, name, **assumptions)
|
7
|
-
|
8
|
-
def __init__(self, name: str, size: int) -> None:
|
1
|
+
class QmodSizedProxy:
|
2
|
+
def __init__(self, size: int) -> None:
|
9
3
|
self._size = size
|
10
4
|
|
11
|
-
@property
|
12
|
-
def size(self) -> int:
|
13
|
-
return self.args[0]
|
14
|
-
|
15
5
|
def __len__(self) -> int:
|
16
6
|
return self._size
|
@@ -473,8 +473,23 @@ ADD_FUNCTION = QuantumFunctionDeclaration(
|
|
473
473
|
)
|
474
474
|
|
475
475
|
|
476
|
-
|
477
|
-
name="
|
476
|
+
MODULAR_ADD_FUNCTION = QuantumFunctionDeclaration(
|
477
|
+
name="modular_add",
|
478
|
+
port_declarations={
|
479
|
+
"left": PortDeclaration(
|
480
|
+
name="left",
|
481
|
+
direction=PortDeclarationDirection.Inout,
|
482
|
+
),
|
483
|
+
"right": PortDeclaration(
|
484
|
+
name="right",
|
485
|
+
direction=PortDeclarationDirection.Inout,
|
486
|
+
),
|
487
|
+
},
|
488
|
+
)
|
489
|
+
|
490
|
+
|
491
|
+
INTEGER_XOR_FUNCTION = QuantumFunctionDeclaration(
|
492
|
+
name="integer_xor",
|
478
493
|
port_declarations={
|
479
494
|
"left": PortDeclaration(
|
480
495
|
name="left",
|
@@ -541,6 +556,47 @@ FREE_FUNCTION = QuantumFunctionDeclaration(
|
|
541
556
|
},
|
542
557
|
)
|
543
558
|
|
559
|
+
|
560
|
+
RANDOMIZED_BENCHMARKING = QuantumFunctionDeclaration(
|
561
|
+
name="randomized_benchmarking",
|
562
|
+
port_declarations={
|
563
|
+
DEFAULT_TARGET_NAME: PortDeclaration(
|
564
|
+
name=DEFAULT_TARGET_NAME,
|
565
|
+
direction=PortDeclarationDirection.Inout,
|
566
|
+
),
|
567
|
+
},
|
568
|
+
param_decls={
|
569
|
+
"num_of_cliffords": Integer(),
|
570
|
+
},
|
571
|
+
)
|
572
|
+
|
573
|
+
|
574
|
+
INPLACE_PREPARE_STATE = QuantumFunctionDeclaration(
|
575
|
+
name="inplace_prepare_state",
|
576
|
+
param_decls={"probabilities": ClassicalList(element_type=Real()), "bound": Real()},
|
577
|
+
port_declarations={
|
578
|
+
"target": PortDeclaration(
|
579
|
+
name="target",
|
580
|
+
direction=PortDeclarationDirection.Inout,
|
581
|
+
size=Expression(expr="log(len(probabilities), 2)"),
|
582
|
+
)
|
583
|
+
},
|
584
|
+
)
|
585
|
+
|
586
|
+
|
587
|
+
INPLACE_PREPARE_AMPLITUDES = QuantumFunctionDeclaration(
|
588
|
+
name="inplace_prepare_amplitudes",
|
589
|
+
param_decls={"amplitudes": ClassicalList(element_type=Real()), "bound": Real()},
|
590
|
+
port_declarations={
|
591
|
+
"target": PortDeclaration(
|
592
|
+
name="target",
|
593
|
+
direction=PortDeclarationDirection.Inout,
|
594
|
+
size=Expression(expr="log(len(amplitudes), 2)"),
|
595
|
+
)
|
596
|
+
},
|
597
|
+
)
|
598
|
+
|
599
|
+
|
544
600
|
__all__ = [
|
545
601
|
"H_FUNCTION",
|
546
602
|
"X_FUNCTION",
|
@@ -573,9 +629,13 @@ __all__ = [
|
|
573
629
|
"PREPARE_AMPLITUDES_FUNCTION",
|
574
630
|
"UNITARY_FUNCTION",
|
575
631
|
"ADD_FUNCTION",
|
576
|
-
"
|
632
|
+
"MODULAR_ADD_FUNCTION",
|
633
|
+
"INTEGER_XOR_FUNCTION",
|
577
634
|
"U_FUNCTION",
|
578
635
|
"CCX_FUNCTION",
|
579
636
|
"ALLOCATE_FUNCTION",
|
580
637
|
"FREE_FUNCTION",
|
638
|
+
"RANDOMIZED_BENCHMARKING",
|
639
|
+
"INPLACE_PREPARE_STATE",
|
640
|
+
"INPLACE_PREPARE_AMPLITUDES",
|
581
641
|
]
|
classiq/interface/generator/functions/core_lib_declarations/quantum_functions/std_lib_functions.py
CHANGED
@@ -34,35 +34,101 @@ QFT = QuantumFunctionDeclaration.parse_raw(
|
|
34
34
|
}"""
|
35
35
|
)
|
36
36
|
|
37
|
-
|
37
|
+
QPE_FLEXIBLE = QuantumFunctionDeclaration.parse_raw(
|
38
38
|
"""{
|
39
|
-
"name": "
|
40
|
-
"param_decls": {
|
41
|
-
|
42
|
-
|
39
|
+
"name": "qpe_flexible",
|
40
|
+
"param_decls": {},
|
41
|
+
"port_declarations": {
|
42
|
+
"phase": {
|
43
|
+
"name": "phase",
|
44
|
+
"quantum_type": {
|
45
|
+
"size": null,
|
46
|
+
"kind": "qnum"
|
47
|
+
},
|
48
|
+
"direction": "inout"
|
43
49
|
}
|
44
50
|
},
|
51
|
+
"operand_declarations": {
|
52
|
+
"unitary_with_power": {
|
53
|
+
"name": "unitary_with_power",
|
54
|
+
"positional_arg_declarations": [
|
55
|
+
{
|
56
|
+
"name": "arg0",
|
57
|
+
"classical_type": {
|
58
|
+
"kind": "int"
|
59
|
+
}
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"is_list": false
|
63
|
+
}
|
64
|
+
},
|
65
|
+
"positional_arg_declarations": [
|
66
|
+
{
|
67
|
+
"name": "unitary_with_power",
|
68
|
+
"positional_arg_declarations": [
|
69
|
+
{
|
70
|
+
"name": "arg0",
|
71
|
+
"classical_type": {
|
72
|
+
"kind": "int"
|
73
|
+
}
|
74
|
+
}
|
75
|
+
],
|
76
|
+
"is_list": false
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"name": "phase",
|
80
|
+
"quantum_type": {
|
81
|
+
"size": null,
|
82
|
+
"kind": "qnum"
|
83
|
+
},
|
84
|
+
"direction": "inout"
|
85
|
+
}
|
86
|
+
]
|
87
|
+
}"""
|
88
|
+
)
|
89
|
+
|
90
|
+
QPE = QuantumFunctionDeclaration.parse_raw(
|
91
|
+
"""{
|
92
|
+
"name": "qpe",
|
93
|
+
"param_decls": {},
|
45
94
|
"port_declarations": {
|
46
95
|
"phase": {
|
47
96
|
"name": "phase",
|
48
|
-
"
|
49
|
-
"
|
97
|
+
"quantum_type": {
|
98
|
+
"size": null,
|
99
|
+
"kind": "qnum"
|
50
100
|
},
|
51
101
|
"direction": "inout"
|
52
102
|
}
|
53
103
|
},
|
54
104
|
"operand_declarations": {
|
55
105
|
"unitary": {
|
56
|
-
"name": "unitary"
|
106
|
+
"name": "unitary",
|
107
|
+
"positional_arg_declarations": [],
|
108
|
+
"is_list": false
|
57
109
|
}
|
58
110
|
},
|
59
|
-
"positional_arg_declarations": [
|
111
|
+
"positional_arg_declarations": [
|
112
|
+
{
|
113
|
+
"name": "unitary",
|
114
|
+
"positional_arg_declarations": [],
|
115
|
+
"is_list": false
|
116
|
+
},
|
117
|
+
{
|
118
|
+
"name": "phase",
|
119
|
+
"quantum_type": {
|
120
|
+
"size": null,
|
121
|
+
"kind": "qnum"
|
122
|
+
},
|
123
|
+
"direction": "inout"
|
124
|
+
}
|
125
|
+
]
|
60
126
|
}"""
|
61
127
|
)
|
62
128
|
|
63
|
-
|
129
|
+
STANDARD_QPE = QuantumFunctionDeclaration.parse_raw(
|
64
130
|
"""{
|
65
|
-
"name": "
|
131
|
+
"name": "standard_qpe",
|
66
132
|
"param_decls": {
|
67
133
|
"precision": {
|
68
134
|
"kind": "int"
|
@@ -74,7 +140,7 @@ QPE = QuantumFunctionDeclaration.parse_raw(
|
|
74
140
|
"size": {
|
75
141
|
"expr": "precision"
|
76
142
|
},
|
77
|
-
"direction": "
|
143
|
+
"direction": "inout"
|
78
144
|
}
|
79
145
|
},
|
80
146
|
"operand_declarations": {
|
@@ -450,7 +516,7 @@ PREPARE_INT = QuantumFunctionDeclaration.parse_raw(
|
|
450
516
|
"out": {
|
451
517
|
"name": "out",
|
452
518
|
"quantum_type": {
|
453
|
-
"kind": "
|
519
|
+
"kind": "qnum"
|
454
520
|
},
|
455
521
|
"direction": "output"
|
456
522
|
}
|
@@ -467,11 +533,11 @@ ALLOCATE_NUM = QuantumFunctionDeclaration.parse_raw(
|
|
467
533
|
"num_qubits": {
|
468
534
|
"kind": "int"
|
469
535
|
},
|
470
|
-
"fraction_digits": {
|
471
|
-
"kind": "int"
|
472
|
-
},
|
473
536
|
"is_signed": {
|
474
537
|
"kind": "bool"
|
538
|
+
},
|
539
|
+
"fraction_digits": {
|
540
|
+
"kind": "int"
|
475
541
|
}
|
476
542
|
},
|
477
543
|
"port_declarations": {
|
@@ -711,11 +777,70 @@ FULL_HEA = QuantumFunctionDeclaration.parse_raw(
|
|
711
777
|
}"""
|
712
778
|
)
|
713
779
|
|
780
|
+
SWAP_TEST = QuantumFunctionDeclaration.parse_raw(
|
781
|
+
"""{
|
782
|
+
"name": "swap_test",
|
783
|
+
"param_decls": {},
|
784
|
+
"port_declarations": {
|
785
|
+
"state1": {
|
786
|
+
"name": "state1",
|
787
|
+
"quantum_type": {
|
788
|
+
"length": null,
|
789
|
+
"kind": "qvec"
|
790
|
+
},
|
791
|
+
"direction": "inout"
|
792
|
+
},
|
793
|
+
"state2": {
|
794
|
+
"name": "state2",
|
795
|
+
"quantum_type": {
|
796
|
+
"length": null,
|
797
|
+
"kind": "qvec"
|
798
|
+
},
|
799
|
+
"direction": "inout"
|
800
|
+
},
|
801
|
+
"test": {
|
802
|
+
"name": "test",
|
803
|
+
"quantum_type": {
|
804
|
+
"kind": "qbit"
|
805
|
+
},
|
806
|
+
"direction": "output"
|
807
|
+
}
|
808
|
+
},
|
809
|
+
"operand_declarations": {},
|
810
|
+
"positional_arg_declarations": [
|
811
|
+
{
|
812
|
+
"name": "state1",
|
813
|
+
"quantum_type": {
|
814
|
+
"length": null,
|
815
|
+
"kind": "qvec"
|
816
|
+
},
|
817
|
+
"direction": "inout"
|
818
|
+
},
|
819
|
+
{
|
820
|
+
"name": "state2",
|
821
|
+
"quantum_type": {
|
822
|
+
"length": null,
|
823
|
+
"kind": "qvec"
|
824
|
+
},
|
825
|
+
"direction": "inout"
|
826
|
+
},
|
827
|
+
{
|
828
|
+
"name": "test",
|
829
|
+
"quantum_type": {
|
830
|
+
"kind": "qbit"
|
831
|
+
},
|
832
|
+
"direction": "output"
|
833
|
+
}
|
834
|
+
]
|
835
|
+
}"""
|
836
|
+
)
|
837
|
+
|
714
838
|
__all__ = [
|
715
839
|
"QFT_STEP",
|
716
840
|
"QFT",
|
717
|
-
"
|
841
|
+
"QPE_FLEXIBLE",
|
718
842
|
"QPE",
|
843
|
+
"STANDARD_QPE",
|
719
844
|
"SINGLE_PAULI",
|
720
845
|
"LINEAR_PAULI_ROTATIONS",
|
721
846
|
"AMPLITUDE_ESTIMATION",
|
@@ -733,4 +858,5 @@ __all__ = [
|
|
733
858
|
"QAOA_INIT",
|
734
859
|
"QAOA_PENALTY",
|
735
860
|
"FULL_HEA",
|
861
|
+
"SWAP_TEST",
|
736
862
|
]
|
@@ -9,7 +9,6 @@ from classiq.interface.model.quantum_function_declaration import (
|
|
9
9
|
QuantumFunctionDeclaration,
|
10
10
|
QuantumOperandDeclaration,
|
11
11
|
)
|
12
|
-
from classiq.interface.model.quantum_type import QuantumInteger
|
13
12
|
|
14
13
|
REPEAT_OPERATOR = QuantumFunctionDeclaration(
|
15
14
|
name="repeat",
|
@@ -21,22 +20,29 @@ REPEAT_OPERATOR = QuantumFunctionDeclaration(
|
|
21
20
|
},
|
22
21
|
)
|
23
22
|
|
23
|
+
OPERAND_FIELD_NAME = "operand"
|
24
|
+
CTRL_FIELD_NAME = "ctrl"
|
25
|
+
|
24
26
|
|
25
27
|
INVERT_OPERATOR = QuantumFunctionDeclaration(
|
26
28
|
name="invert",
|
27
|
-
operand_declarations={
|
29
|
+
operand_declarations={
|
30
|
+
OPERAND_FIELD_NAME: QuantumOperandDeclaration(name=OPERAND_FIELD_NAME)
|
31
|
+
},
|
28
32
|
)
|
29
33
|
|
30
34
|
|
31
35
|
CONTROL_OPERATOR = QuantumFunctionDeclaration(
|
32
36
|
name="control",
|
33
37
|
port_declarations={
|
34
|
-
|
35
|
-
name=
|
38
|
+
CTRL_FIELD_NAME: PortDeclaration(
|
39
|
+
name=CTRL_FIELD_NAME,
|
36
40
|
direction=PortDeclarationDirection.Inout,
|
37
41
|
)
|
38
42
|
},
|
39
|
-
operand_declarations={
|
43
|
+
operand_declarations={
|
44
|
+
OPERAND_FIELD_NAME: QuantumOperandDeclaration(name=OPERAND_FIELD_NAME)
|
45
|
+
},
|
40
46
|
)
|
41
47
|
|
42
48
|
IF_OPERATOR = QuantumFunctionDeclaration(
|
@@ -107,21 +113,38 @@ PERMUTE_OPERATOR = QuantumFunctionDeclaration(
|
|
107
113
|
POWER_OPERATOR = QuantumFunctionDeclaration(
|
108
114
|
name="power",
|
109
115
|
param_decls={"power": Integer()},
|
110
|
-
operand_declarations={
|
116
|
+
operand_declarations={
|
117
|
+
OPERAND_FIELD_NAME: QuantumOperandDeclaration(name=OPERAND_FIELD_NAME)
|
118
|
+
},
|
111
119
|
)
|
112
120
|
|
121
|
+
APPLY = QuantumFunctionDeclaration(
|
122
|
+
name="apply",
|
123
|
+
operand_declarations={
|
124
|
+
OPERAND_FIELD_NAME: QuantumOperandDeclaration(
|
125
|
+
name=OPERAND_FIELD_NAME,
|
126
|
+
)
|
127
|
+
},
|
128
|
+
)
|
113
129
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
name=
|
120
|
-
|
121
|
-
|
130
|
+
|
131
|
+
COMPUTE = QuantumFunctionDeclaration(
|
132
|
+
name="compute",
|
133
|
+
operand_declarations={
|
134
|
+
OPERAND_FIELD_NAME: QuantumOperandDeclaration(
|
135
|
+
name=OPERAND_FIELD_NAME,
|
136
|
+
)
|
137
|
+
},
|
138
|
+
)
|
139
|
+
|
140
|
+
|
141
|
+
UNCOMPUTE = QuantumFunctionDeclaration(
|
142
|
+
name="uncompute",
|
143
|
+
operand_declarations={
|
144
|
+
OPERAND_FIELD_NAME: QuantumOperandDeclaration(
|
145
|
+
name=OPERAND_FIELD_NAME,
|
122
146
|
)
|
123
147
|
},
|
124
|
-
operand_declarations={"operand": QuantumOperandDeclaration(name="operand")},
|
125
148
|
)
|
126
149
|
|
127
150
|
|
@@ -135,7 +158,9 @@ BUILTIN_QUANTUM_OPERATOR_LIST = [
|
|
135
158
|
SPLIT_OPERATOR,
|
136
159
|
PERMUTE_OPERATOR,
|
137
160
|
POWER_OPERATOR,
|
138
|
-
|
161
|
+
APPLY,
|
162
|
+
COMPUTE,
|
163
|
+
UNCOMPUTE,
|
139
164
|
]
|
140
165
|
|
141
166
|
|
@@ -89,9 +89,9 @@ class SynthesisNativeFunctionDefinition(SynthesisQuantumFunctionDeclaration):
|
|
89
89
|
|
90
90
|
@pydantic.root_validator
|
91
91
|
def validate_ports(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
92
|
-
port_declarations: Optional[
|
93
|
-
|
94
|
-
|
92
|
+
port_declarations: Optional[Dict[IOName, SynthesisPortDeclaration]] = (
|
93
|
+
values.get("port_declarations")
|
94
|
+
)
|
95
95
|
if port_declarations is None:
|
96
96
|
return values
|
97
97
|
cls._validate_direction_ports(
|
@@ -40,9 +40,9 @@ class Constraints(BaseModel, extra=Extra.forbid):
|
|
40
40
|
)
|
41
41
|
max_depth: Optional[pydantic.PositiveInt] = None
|
42
42
|
|
43
|
-
max_gate_count: Dict[
|
44
|
-
|
45
|
-
|
43
|
+
max_gate_count: Dict[TranspilerBasisGates, pydantic.NonNegativeInt] = (
|
44
|
+
pydantic.Field(default_factory=lambda: defaultdict(int))
|
45
|
+
)
|
46
46
|
|
47
47
|
optimization_parameter: OptimizationParameterType = pydantic.Field(
|
48
48
|
default=OptimizationParameter.NO_OPTIMIZATION,
|
@@ -11,12 +11,14 @@ from classiq.interface.backend.quantum_backend_providers import (
|
|
11
11
|
AllBackendsNameByVendor,
|
12
12
|
ProviderVendor,
|
13
13
|
)
|
14
|
+
from classiq.interface.generator.arith.number_utils import MAXIMAL_MACHINE_PRECISION
|
14
15
|
from classiq.interface.generator.hardware.hardware_data import (
|
15
16
|
BACKEND_VALIDATION_ERROR_MESSAGE,
|
16
17
|
CustomHardwareSettings,
|
17
18
|
)
|
18
19
|
from classiq.interface.generator.model.preferences.randomness import create_random_seed
|
19
20
|
from classiq.interface.hardware import Provider
|
21
|
+
from classiq.interface.helpers.custom_pydantic_types import PydanticMachinePrecision
|
20
22
|
|
21
23
|
from classiq._internals.enum_utils import StrEnum
|
22
24
|
|
@@ -50,7 +52,6 @@ _SERVICE_PROVIDER_TO_FORMAT: Dict[Provider, QuantumFormat] = {
|
|
50
52
|
Provider.AMAZON_BRAKET: QuantumFormat.QASM,
|
51
53
|
}
|
52
54
|
|
53
|
-
|
54
55
|
if TYPE_CHECKING:
|
55
56
|
PydanticConstrainedQuantumFormatList = List[QuantumFormat]
|
56
57
|
else:
|
@@ -76,15 +77,18 @@ class Preferences(pydantic.BaseModel, extra=pydantic.Extra.forbid):
|
|
76
77
|
_backend_preferences: Optional[BackendPreferences] = pydantic.PrivateAttr(
|
77
78
|
default=None
|
78
79
|
)
|
79
|
-
|
80
|
-
|
81
|
-
] =
|
82
|
-
|
80
|
+
machine_precision: PydanticMachinePrecision = MAXIMAL_MACHINE_PRECISION
|
81
|
+
|
82
|
+
backend_service_provider: Optional[Union[Provider, ProviderVendor, str]] = (
|
83
|
+
pydantic.Field(
|
84
|
+
default=None,
|
85
|
+
description="Provider company or cloud for the requested backend.",
|
86
|
+
)
|
83
87
|
)
|
84
|
-
backend_name: Optional[
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
+
backend_name: Optional[Union[PydanticBackendName, AllBackendsNameByVendor]] = (
|
89
|
+
pydantic.Field(
|
90
|
+
default=None, description="Name of the requested backend or target."
|
91
|
+
)
|
88
92
|
)
|
89
93
|
custom_hardware_settings: CustomHardwareSettings = pydantic.Field(
|
90
94
|
default_factory=CustomHardwareSettings,
|
@@ -7,9 +7,9 @@ from classiq.interface.helpers.custom_pydantic_types import PydanticProbabilityF
|
|
7
7
|
|
8
8
|
|
9
9
|
class NoiseProperties(BaseModel):
|
10
|
-
measurement_bit_flip_probability: Optional[
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
measurement_bit_flip_probability: Optional[PydanticProbabilityFloat] = (
|
11
|
+
pydantic.Field(
|
12
|
+
default=None,
|
13
|
+
description="Probability of measuring the wrong value for each qubit.",
|
14
|
+
)
|
15
15
|
)
|
@@ -84,11 +84,11 @@ class PhaseEstimation(FunctionParams):
|
|
84
84
|
description="The unitary function parameters.",
|
85
85
|
default_factory=CustomFunction,
|
86
86
|
)
|
87
|
-
exponentiation_specification: Optional[
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
exponentiation_specification: Optional[ExponentiationSpecification] = (
|
88
|
+
pydantic.Field(
|
89
|
+
default=None,
|
90
|
+
description="The specifications for phase estimation of exponentiation functions.",
|
91
|
+
)
|
92
92
|
)
|
93
93
|
|
94
94
|
_output_name: IOName = pydantic.PrivateAttr(
|
@@ -537,9 +537,11 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
537
537
|
valid_matches: List[Match] = []
|
538
538
|
invalid_expressions: List[str] = []
|
539
539
|
for expression, expression_match in zip(expressions, expression_matches):
|
540
|
-
|
541
|
-
expression
|
542
|
-
|
540
|
+
(
|
541
|
+
invalid_expressions.append(expression)
|
542
|
+
if expression_match is None
|
543
|
+
else valid_matches.append(expression_match)
|
544
|
+
)
|
543
545
|
|
544
546
|
invalid_slicings: List[str] = []
|
545
547
|
invalid_names: List[str] = []
|
@@ -3,16 +3,18 @@ import pydantic
|
|
3
3
|
from classiq.interface.generator.arith.register_user_input import RegisterArithmeticInfo
|
4
4
|
from classiq.interface.generator.function_params import FunctionParams
|
5
5
|
|
6
|
-
|
6
|
+
RANDOMIZED_BENCHMARKING_INPUT: str = "TARGET"
|
7
|
+
RANDOMIZED_BENCHMARKING_OUTPUT: str = "TARGET"
|
7
8
|
|
8
9
|
|
9
10
|
class RandomizedBenchmarking(FunctionParams):
|
10
11
|
num_of_qubits: pydantic.PositiveInt
|
11
12
|
num_of_cliffords: pydantic.PositiveInt
|
12
|
-
register_name: str = _DEFAULT_RB_NAME
|
13
13
|
|
14
14
|
def _create_ios(self) -> None:
|
15
15
|
self._inputs = {
|
16
|
-
|
16
|
+
RANDOMIZED_BENCHMARKING_INPUT: RegisterArithmeticInfo(
|
17
|
+
size=self.num_of_qubits
|
18
|
+
)
|
17
19
|
}
|
18
20
|
self._outputs = {**self._inputs}
|
@@ -81,8 +81,7 @@ class Visitor:
|
|
81
81
|
class Transformer(Visitor):
|
82
82
|
if TYPE_CHECKING:
|
83
83
|
|
84
|
-
def visit(self, node: NodeType) -> Any:
|
85
|
-
...
|
84
|
+
def visit(self, node: NodeType) -> Any: ...
|
86
85
|
|
87
86
|
def visit_list(self, node: List[NodeType]) -> List[RetType]:
|
88
87
|
return [self.visit(elem) for elem in node]
|
classiq/interface/hardware.py
CHANGED
@@ -2,6 +2,7 @@ from typing import TYPE_CHECKING, Any, List, Tuple
|
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
+
from classiq.interface.generator.arith.number_utils import MAXIMAL_MACHINE_PRECISION
|
5
6
|
from classiq.interface.generator.parameters import ParameterComplexType
|
6
7
|
|
7
8
|
# General int types
|
@@ -10,11 +11,16 @@ MAX_EXPRESSION_SIZE = 32768
|
|
10
11
|
|
11
12
|
if TYPE_CHECKING:
|
12
13
|
PydanticLargerThanOneInteger = int
|
14
|
+
PydanticMachinePrecision = int
|
13
15
|
else:
|
14
16
|
|
15
17
|
class PydanticLargerThanOneInteger(pydantic.ConstrainedInt):
|
16
18
|
gt = 1
|
17
19
|
|
20
|
+
class PydanticMachinePrecision(pydantic.ConstrainedInt):
|
21
|
+
gt = 0
|
22
|
+
le = MAXIMAL_MACHINE_PRECISION
|
23
|
+
|
18
24
|
|
19
25
|
# Probability float types
|
20
26
|
if TYPE_CHECKING:
|