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.
Files changed (91) hide show
  1. classiq/__init__.py +1 -0
  2. classiq/_internals/api_wrapper.py +24 -6
  3. classiq/_internals/authentication/device.py +6 -3
  4. classiq/_internals/authentication/token_manager.py +21 -5
  5. classiq/_internals/client.py +7 -2
  6. classiq/_internals/config.py +12 -0
  7. classiq/_internals/host_checker.py +1 -1
  8. classiq/_internals/jobs.py +3 -1
  9. classiq/_internals/type_validation.py +3 -6
  10. classiq/analyzer/analyzer.py +1 -0
  11. classiq/analyzer/rb.py +3 -5
  12. classiq/applications_model_constructors/chemistry_model_constructor.py +42 -67
  13. classiq/applications_model_constructors/grover_model_constructor.py +27 -18
  14. classiq/exceptions.py +5 -0
  15. classiq/execution/jobs.py +13 -4
  16. classiq/executor.py +3 -2
  17. classiq/interface/_version.py +1 -1
  18. classiq/interface/analyzer/analysis_params.py +0 -6
  19. classiq/interface/analyzer/result.py +0 -4
  20. classiq/interface/backend/backend_preferences.py +2 -2
  21. classiq/interface/backend/quantum_backend_providers.py +1 -1
  22. classiq/interface/execution/resource_estimator.py +7 -0
  23. classiq/interface/execution/result.py +5 -0
  24. classiq/interface/executor/register_initialization.py +3 -1
  25. classiq/interface/executor/vqe_result.py +1 -0
  26. classiq/interface/generator/ansatz_library.py +3 -3
  27. classiq/interface/generator/arith/argument_utils.py +4 -4
  28. classiq/interface/generator/arith/arithmetic.py +4 -2
  29. classiq/interface/generator/arith/arithmetic_arg_type_validator.py +11 -5
  30. classiq/interface/generator/arith/arithmetic_expression_parser.py +8 -7
  31. classiq/interface/generator/arith/arithmetic_operations.py +7 -0
  32. classiq/interface/generator/arith/arithmetic_param_getters.py +97 -16
  33. classiq/interface/generator/arith/arithmetic_result_builder.py +13 -3
  34. classiq/interface/generator/arith/binary_ops.py +8 -10
  35. classiq/interface/generator/arith/extremum_operations.py +2 -2
  36. classiq/interface/generator/arith/number_utils.py +20 -23
  37. classiq/interface/generator/arith/register_user_input.py +3 -1
  38. classiq/interface/generator/arith/unary_ops.py +9 -13
  39. classiq/interface/generator/expressions/atomic_expression_functions.py +2 -0
  40. classiq/interface/generator/expressions/expression.py +7 -2
  41. classiq/interface/generator/expressions/qmod_qnum_proxy.py +22 -0
  42. classiq/interface/generator/expressions/qmod_sized_proxy.py +2 -12
  43. classiq/interface/generator/functions/core_lib_declarations/quantum_functions/atomic_quantum_functions.py +63 -3
  44. classiq/interface/generator/functions/core_lib_declarations/quantum_functions/std_lib_functions.py +143 -17
  45. classiq/interface/generator/functions/core_lib_declarations/quantum_operators.py +41 -16
  46. classiq/interface/generator/functions/native_function_definition.py +3 -3
  47. classiq/interface/generator/model/constraints.py +3 -3
  48. classiq/interface/generator/model/preferences/preferences.py +13 -9
  49. classiq/interface/generator/noise_properties.py +5 -5
  50. classiq/interface/generator/qpe.py +5 -5
  51. classiq/interface/generator/quantum_function_call.py +5 -3
  52. classiq/interface/generator/randomized_benchmarking.py +5 -3
  53. classiq/interface/generator/visitor.py +1 -2
  54. classiq/interface/hardware.py +1 -1
  55. classiq/interface/helpers/custom_pydantic_types.py +6 -0
  56. classiq/interface/model/{modular_addition_operation.py → inplace_binary_operation.py} +16 -2
  57. classiq/interface/model/native_function_definition.py +2 -24
  58. classiq/interface/model/operator_synthesis_data.py +6 -0
  59. classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +8 -4
  60. classiq/interface/model/quantum_expressions/arithmetic_operation.py +9 -5
  61. classiq/interface/model/quantum_expressions/control_state.py +38 -0
  62. classiq/interface/model/quantum_expressions/quantum_expression.py +21 -11
  63. classiq/interface/model/quantum_function_call.py +81 -6
  64. classiq/interface/model/quantum_function_declaration.py +3 -3
  65. classiq/interface/model/quantum_if_operation.py +95 -0
  66. classiq/interface/model/resolvers/function_call_resolver.py +1 -1
  67. classiq/interface/model/validations/handles_validator.py +42 -15
  68. classiq/interface/server/routes.py +10 -6
  69. classiq/model/function_handler.pyi +86 -86
  70. classiq/model/model.py +1 -0
  71. classiq/qmod/__init__.py +6 -1
  72. classiq/qmod/builtins/__init__.py +13 -1
  73. classiq/qmod/builtins/classical_execution_primitives.py +109 -0
  74. classiq/qmod/builtins/classical_functions.py +68 -0
  75. classiq/qmod/builtins/functions.py +88 -18
  76. classiq/qmod/builtins/operations.py +60 -35
  77. classiq/qmod/classical_function.py +40 -0
  78. classiq/qmod/declaration_inferrer.py +5 -2
  79. classiq/qmod/qmod_variable.py +17 -10
  80. classiq/qmod/quantum_callable.py +24 -3
  81. classiq/qmod/quantum_expandable.py +131 -21
  82. classiq/qmod/quantum_function.py +12 -2
  83. classiq/qmod/symbolic.py +182 -107
  84. classiq/qmod/symbolic_expr.py +11 -10
  85. classiq/qmod/symbolic_type.py +8 -0
  86. classiq/quantum_functions/decorators.py +2 -4
  87. classiq/quantum_functions/function_library.py +1 -0
  88. {classiq-0.36.0.dist-info → classiq-0.37.0.dist-info}/METADATA +1 -1
  89. {classiq-0.36.0.dist-info → classiq-0.37.0.dist-info}/RECORD +90 -82
  90. classiq/interface/model/local_variable_declaration.py +0 -7
  91. {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
- from sympy import Symbol
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
- INPLACE_ADD_FUNCTION = QuantumFunctionDeclaration(
477
- name="inplace_add",
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
- "INPLACE_ADD_FUNCTION",
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
  ]
@@ -34,35 +34,101 @@ QFT = QuantumFunctionDeclaration.parse_raw(
34
34
  }"""
35
35
  )
36
36
 
37
- STANDARD_QPE = QuantumFunctionDeclaration.parse_raw(
37
+ QPE_FLEXIBLE = QuantumFunctionDeclaration.parse_raw(
38
38
  """{
39
- "name": "standard_qpe",
40
- "param_decls": {
41
- "precision": {
42
- "kind": "int"
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
- "size": {
49
- "expr": "precision"
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
- QPE = QuantumFunctionDeclaration.parse_raw(
129
+ STANDARD_QPE = QuantumFunctionDeclaration.parse_raw(
64
130
  """{
65
- "name": "qpe",
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": "output"
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": "qint"
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
- "STANDARD_QPE",
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={"operand": QuantumOperandDeclaration(name="operand")},
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
- "ctrl": PortDeclaration(
35
- name="ctrl",
38
+ CTRL_FIELD_NAME: PortDeclaration(
39
+ name=CTRL_FIELD_NAME,
36
40
  direction=PortDeclarationDirection.Inout,
37
41
  )
38
42
  },
39
- operand_declarations={"operand": QuantumOperandDeclaration(name="operand")},
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={"operand": QuantumOperandDeclaration(name="operand")},
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
- CONTROL_WITH_VALUE_OPERATOR = QuantumFunctionDeclaration(
115
- name="control_with_value",
116
- param_decls={"ctrl_val": Integer()},
117
- port_declarations={
118
- "ctrl": PortDeclaration(
119
- name="ctrl",
120
- quantum_type=QuantumInteger(),
121
- direction=PortDeclarationDirection.Inout,
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
- CONTROL_WITH_VALUE_OPERATOR,
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
- Dict[IOName, SynthesisPortDeclaration]
94
- ] = values.get("port_declarations")
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
- TranspilerBasisGates, pydantic.NonNegativeInt
45
- ] = pydantic.Field(default_factory=lambda: defaultdict(int))
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
- backend_service_provider: Optional[
80
- Union[Provider, ProviderVendor, str]
81
- ] = pydantic.Field(
82
- default=None, description="Provider company or cloud for the requested backend."
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
- Union[PydanticBackendName, AllBackendsNameByVendor]
86
- ] = pydantic.Field(
87
- default=None, description="Name of the requested backend or target."
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
- PydanticProbabilityFloat
12
- ] = pydantic.Field(
13
- default=None,
14
- description="Probability of measuring the wrong value for each qubit.",
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
- ExponentiationSpecification
89
- ] = pydantic.Field(
90
- default=None,
91
- description="The specifications for phase estimation of exponentiation functions.",
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
- invalid_expressions.append(
541
- expression
542
- ) if expression_match is None else valid_matches.append(expression_match)
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
- _DEFAULT_RB_NAME = "rb_reg"
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
- self.register_name: RegisterArithmeticInfo(size=self.num_of_qubits)
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]
@@ -13,7 +13,7 @@ class Provider(StrEnum):
13
13
  IONQ = "IonQ"
14
14
  CLASSIQ = "Classiq"
15
15
  GOOGLE = "Google"
16
- ALICE_AND_BOB = "Alice and Bob"
16
+ ALICE_AND_BOB = "Alice & Bob"
17
17
  OQC = "OQC"
18
18
 
19
19
  @property
@@ -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: