classiq 0.48.0__py3-none-any.whl → 0.49.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 CHANGED
@@ -48,13 +48,16 @@ from classiq.executor import (
48
48
  )
49
49
  from classiq.qmod import * # noqa: F403
50
50
  from classiq.qmod import __all__ as _qmod_all
51
- from classiq.show import show
52
51
  from classiq.synthesis import (
53
52
  set_constraints,
54
53
  set_execution_preferences,
55
54
  set_preferences,
55
+ show,
56
56
  synthesize,
57
57
  synthesize_async,
58
+ update_constraints,
59
+ update_execution_preferences,
60
+ update_preferences,
58
61
  )
59
62
 
60
63
  _application_constructors_all = [
@@ -95,6 +98,9 @@ __all__ = (
95
98
  "set_preferences",
96
99
  "set_constraints",
97
100
  "set_execution_preferences",
101
+ "update_preferences",
102
+ "update_constraints",
103
+ "update_execution_preferences",
98
104
  "set_quantum_program_execution_preferences",
99
105
  "show",
100
106
  "hamiltonian_to_matrix",
@@ -1,6 +1,8 @@
1
1
  import webbrowser
2
2
  from urllib.parse import urljoin
3
3
 
4
+ from classiq.interface.exceptions import ClassiqAnalyzerVisualizationError
5
+ from classiq.interface.generator.model.preferences.preferences import QuantumFormat
4
6
  from classiq.interface.generator.quantum_program import QuantumProgram
5
7
 
6
8
  from classiq._internals.api_wrapper import ApiWrapper
@@ -8,18 +10,27 @@ from classiq._internals.async_utils import syncify_function
8
10
  from classiq.analyzer.url_utils import circuit_page_uri, client_ide_base_url
9
11
 
10
12
 
11
- async def handle_remote_app(circuit: QuantumProgram) -> None:
13
+ async def handle_remote_app(circuit: QuantumProgram, dispaly_url: bool = False) -> None:
14
+ if circuit.outputs.get(QuantumFormat.QASM) is None:
15
+ raise ClassiqAnalyzerVisualizationError(
16
+ "Missing QASM transpilation: visualization is only supported "
17
+ "for QASM programs. Try adding QASM to the output formats "
18
+ "synthesis preferences"
19
+ )
12
20
  circuit_dataid = await ApiWrapper.call_analyzer_app(circuit)
13
21
  app_url = urljoin(
14
22
  client_ide_base_url(),
15
23
  circuit_page_uri(circuit_id=circuit_dataid.id, circuit_version=circuit.version),
16
24
  )
17
- print(f"Opening: {app_url}") # noqa: T201
25
+
26
+ if dispaly_url:
27
+ print(f"Opening: {app_url}") # noqa: T201
28
+
18
29
  webbrowser.open_new_tab(app_url)
19
30
 
20
31
 
21
- async def _show_interactive(self: QuantumProgram) -> None:
22
- await handle_remote_app(circuit=self)
32
+ async def _show_interactive(self: QuantumProgram, dispaly_url: bool = False) -> None:
33
+ await handle_remote_app(self, dispaly_url)
23
34
 
24
35
 
25
36
  QuantumProgram.show = syncify_function(_show_interactive) # type: ignore[attr-defined]
@@ -3,5 +3,5 @@ from packaging.version import Version
3
3
  # This file was generated automatically
4
4
  # Please don't track in version control (DONTTRACK)
5
5
 
6
- SEMVER_VERSION = '0.48.0'
6
+ SEMVER_VERSION = '0.49.0'
7
7
  VERSION = str(Version(SEMVER_VERSION))
@@ -13,6 +13,7 @@ from classiq.interface.backend.quantum_backend_providers import (
13
13
  AzureQuantumBackendNames,
14
14
  ClassiqNvidiaBackendNames,
15
15
  ClassiqSimulatorBackendNames,
16
+ IntelBackendNames,
16
17
  IonqBackendNames,
17
18
  OQCBackendNames,
18
19
  ProviderTypeVendor,
@@ -427,6 +428,25 @@ class OQCBackendPreferences(BackendPreferences):
427
428
  )
428
429
 
429
430
 
431
+ class IntelBackendPreferences(BackendPreferences):
432
+ """
433
+ Represents backend preferences specific to Classiq quantum computing targets.
434
+
435
+ This class is used to configure the backend options for executing quantum circuits on Classiq's platform.
436
+ The relevant backend names for Classiq targets are specified in `ClassiqSimulatorBackendNames` & `ClassiqNvidiaBackendNames`.
437
+
438
+ For more details, refer to the [Classiq Backend Documentation](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/classiq-backends/).
439
+ """
440
+
441
+ backend_service_provider: ProviderTypeVendor.INTEL
442
+
443
+ @pydantic.root_validator(pre=True)
444
+ def _set_backend_service_provider(cls, values: Dict[str, Any]) -> Dict[str, Any]:
445
+ return values_with_discriminator(
446
+ values, "backend_service_provider", ProviderVendor.INTEL
447
+ )
448
+
449
+
430
450
  def is_exact_simulator(backend_preferences: BackendPreferences) -> bool:
431
451
  return backend_preferences.backend_name in EXACT_SIMULATORS
432
452
 
@@ -456,6 +476,7 @@ BackendPreferencesTypes = Union[
456
476
  GCPBackendPreferences,
457
477
  AliceBobBackendPreferences,
458
478
  OQCBackendPreferences,
479
+ IntelBackendPreferences,
459
480
  ]
460
481
 
461
482
  __all__ = [
@@ -471,11 +492,13 @@ __all__ = [
471
492
  "IonqBackendPreferences",
472
493
  "IonqBackendNames",
473
494
  "ClassiqNvidiaBackendNames",
495
+ "IntelBackendNames",
474
496
  "GCPBackendPreferences",
475
497
  "AliceBobBackendPreferences",
476
498
  "AliceBobBackendNames",
477
499
  "OQCBackendPreferences",
478
500
  "OQCBackendNames",
501
+ "IntelBackendPreferences",
479
502
  ]
480
503
 
481
504
 
@@ -18,6 +18,7 @@ class ProviderVendor(StrEnum):
18
18
  GOOGLE = "Google"
19
19
  ALICE_AND_BOB = "Alice & Bob"
20
20
  OQC = "OQC"
21
+ INTEL = "Intel"
21
22
 
22
23
 
23
24
  class ProviderTypeVendor:
@@ -29,6 +30,7 @@ class ProviderTypeVendor:
29
30
  GOOGLE = Literal[ProviderVendor.GOOGLE]
30
31
  ALICE_BOB = Literal[ProviderVendor.ALICE_AND_BOB]
31
32
  OQC = Literal[ProviderVendor.OQC]
33
+ INTEL = Literal[ProviderVendor.INTEL]
32
34
 
33
35
 
34
36
  class ClassiqSimulatorBackendNames(StrEnum):
@@ -167,6 +169,10 @@ class ClassiqNvidiaBackendNames(StrEnum):
167
169
  SIMULATOR = "nvidia_state_vector_simulator"
168
170
 
169
171
 
172
+ class IntelBackendNames(StrEnum):
173
+ SIMULATOR = "intel_qsdk_simulator"
174
+
175
+
170
176
  AllClassiqBackendNames = Union[ClassiqSimulatorBackendNames, ClassiqNvidiaBackendNames]
171
177
 
172
178
 
@@ -205,6 +211,7 @@ EXACT_SIMULATORS = {
205
211
  AmazonBraketBackendNames.AMAZON_BRAKET_TN1,
206
212
  AmazonBraketBackendNames.AMAZON_BRAKET_DM1,
207
213
  *ClassiqSimulatorBackendNames,
214
+ *IntelBackendNames,
208
215
  *ClassiqNvidiaBackendNames,
209
216
  }
210
217
 
@@ -215,6 +222,7 @@ AllBackendsNameByVendor = Union[
215
222
  AzureQuantumBackendNames,
216
223
  AmazonBraketBackendNames,
217
224
  IonqBackendNames,
225
+ IntelBackendNames,
218
226
  ClassiqNvidiaBackendNames,
219
227
  AliceBobBackendNames,
220
228
  OQCBackendNames,
@@ -226,6 +234,7 @@ AllBackendsNameEnums = [
226
234
  AmazonBraketBackendNames,
227
235
  IonqBackendNames,
228
236
  AliceBobBackendNames,
237
+ IntelBackendNames,
229
238
  ClassiqNvidiaBackendNames,
230
239
  OQCBackendNames,
231
240
  ]
@@ -19,6 +19,7 @@ class FunctionDebugInfo(BaseModel):
19
19
  parameters: Dict[str, str] = Field(type=Dict[str, ParameterValue])
20
20
  level: OperationLevel
21
21
  is_allocate_or_free: bool = Field(default=False)
22
+ is_inverse: bool = Field(default=False)
22
23
  port_to_passed_variable_map: Dict[str, str] = Field(default_factory=dict)
23
24
 
24
25
  @staticmethod
@@ -46,7 +46,7 @@ class ClassiqAnalyzerError(ClassiqError):
46
46
  pass
47
47
 
48
48
 
49
- class ClassiqAnalyzerGraphError(ClassiqError):
49
+ class ClassiqAnalyzerVisualizationError(ClassiqError):
50
50
  pass
51
51
 
52
52
 
@@ -9,7 +9,7 @@ from classiq.interface.generator.register_role import RegisterRole
9
9
  from classiq.interface.generator.synthesis_metadata.synthesis_execution_data import (
10
10
  ExecutionData,
11
11
  )
12
- from classiq.interface.ide.visual_model import OperationParameter
12
+ from classiq.interface.ide.visual_model import OperationLevel, OperationParameter
13
13
 
14
14
  _logger = logging.getLogger(__name__)
15
15
  ParameterName = str
@@ -102,9 +102,17 @@ class FunctionDebugInfoInterface(pydantic.BaseModel):
102
102
  relative_qubits: Tuple[int, ...]
103
103
  absolute_qubits: Optional[Tuple[int, ...]]
104
104
  is_basis_gate: Optional[bool]
105
+ is_inverse: bool = pydantic.Field(default=False)
106
+ level: OperationLevel = pydantic.Field(default=OperationLevel.UNKNOWN)
105
107
  parameters: List[OperationParameter] = list()
106
108
  port_to_passed_variable_map: Dict[str, str] = pydantic.Field(default_factory=dict)
107
109
 
110
+ @property
111
+ def name(self) -> str:
112
+ if self.generated_function is None:
113
+ return ""
114
+ return self.generated_function.name
115
+
108
116
  @property
109
117
  def registers(self) -> List[GeneratedRegister]:
110
118
  if self.generated_function is None:
@@ -153,6 +161,12 @@ class FunctionDebugInfoInterface(pydantic.BaseModel):
153
161
  )
154
162
  child.propagate_absolute_qubits()
155
163
 
164
+ def inverse(self) -> None:
165
+ self.is_inverse = not self.is_inverse
166
+ for child in self.children:
167
+ child.inverse()
168
+ self.children = self.children[::-1]
169
+
156
170
 
157
171
  def _get_absolute_from_relative(
158
172
  absolute_qubits: Tuple[int, ...], relative_qubits: Tuple[int, ...]
@@ -20,6 +20,7 @@ class Provider(StrEnum):
20
20
  GOOGLE = "Google"
21
21
  ALICE_AND_BOB = "Alice & Bob"
22
22
  OQC = "OQC"
23
+ INTEL = "Intel"
23
24
 
24
25
  @property
25
26
  def id(self) -> "ProviderIDEnum":
@@ -34,24 +34,28 @@ class ArithmeticOperation(QuantumAssignmentOperation):
34
34
  )
35
35
 
36
36
  operation_kind: ArithmeticOperationKind = pydantic.Field(
37
- default=ArithmeticOperationKind.InplaceXor,
37
+ default=None,
38
38
  )
39
39
 
40
+ @pydantic.validator("operation_kind", always=True)
41
+ def _propagate_inplace_result(
42
+ cls, operation_kind: Optional[ArithmeticOperationKind], values: dict
43
+ ) -> ArithmeticOperationKind:
44
+ if operation_kind is None:
45
+ operation_kind = (
46
+ ArithmeticOperationKind.InplaceXor
47
+ if values["inplace_result"]
48
+ else ArithmeticOperationKind.Assignment
49
+ )
50
+ return operation_kind
51
+
40
52
  @property
41
53
  def is_inplace(self) -> bool:
42
- return self.get_operation_kind() in (
54
+ return self.operation_kind in (
43
55
  ArithmeticOperationKind.InplaceXor,
44
56
  ArithmeticOperationKind.InplaceAdd,
45
57
  )
46
58
 
47
- def get_operation_kind(self) -> ArithmeticOperationKind:
48
- if hasattr(self, "inplace_result"):
49
- if self.inplace_result is False:
50
- return ArithmeticOperationKind.Assignment
51
- if self.inplace_result is True:
52
- return ArithmeticOperationKind.InplaceXor
53
- return self.operation_kind
54
-
55
59
  def initialize_var_types(
56
60
  self,
57
61
  var_types: Dict[str, QuantumType],
@@ -152,15 +152,11 @@ def _build_inplace_binary_operation(
152
152
  *target_bind_ops,
153
153
  *value_bind_ops,
154
154
  *value_pad_pre_bind_ops,
155
+ *value_pad_init_ops,
156
+ *value_post_bind_ops,
155
157
  ],
156
158
  action=[
157
- *value_pad_init_ops,
158
- WithinApply(
159
- compute=[
160
- *value_post_bind_ops,
161
- ],
162
- action=[op_call],
163
- ),
159
+ op_call,
164
160
  ],
165
161
  ),
166
162
  ]
@@ -71,7 +71,7 @@ class QuantumAssignmentOperationEmitter(
71
71
  def _emit_inplace_arithmetic_op(
72
72
  self, op: ArithmeticOperation, expression: Expression, is_bool_opt: bool
73
73
  ) -> None:
74
- if op.get_operation_kind() != ArithmeticOperationKind.InplaceXor or (
74
+ if op.operation_kind != ArithmeticOperationKind.InplaceXor or (
75
75
  op.result_type.size_in_bits > 1 or not _is_res_boolean(op)
76
76
  ):
77
77
  _validate_naive_inplace_handles(op)
@@ -105,7 +105,7 @@ class QuantumAssignmentOperationEmitter(
105
105
  ) -> Tuple[ArithmeticOperation, Expression, bool]:
106
106
  if (
107
107
  self._interpreter._is_frontend
108
- or op.get_operation_kind()
108
+ or op.operation_kind
109
109
  not in (
110
110
  ArithmeticOperationKind.Assignment,
111
111
  ArithmeticOperationKind.InplaceXor,
@@ -143,7 +143,7 @@ class QuantumAssignmentOperationEmitter(
143
143
  expression=new_expression,
144
144
  operation_kind=ArithmeticOperationKind.Assignment,
145
145
  )
146
- if qe.get_operation_kind() == ArithmeticOperationKind.InplaceXor:
146
+ if qe.operation_kind == ArithmeticOperationKind.InplaceXor:
147
147
  op = BinaryOperation.Xor
148
148
  else:
149
149
  op = BinaryOperation.Addition
@@ -345,9 +345,9 @@ class DSLPrettyPrinter(Visitor):
345
345
  return f"{self.visit(var_ref.base_handle)}.{self.visit(var_ref.field)}"
346
346
 
347
347
  def visit_ArithmeticOperation(self, arith_op: ArithmeticOperation) -> str:
348
- if arith_op.get_operation_kind() == ArithmeticOperationKind.Assignment:
348
+ if arith_op.operation_kind == ArithmeticOperationKind.Assignment:
349
349
  op = "="
350
- elif arith_op.get_operation_kind() == ArithmeticOperationKind.InplaceXor:
350
+ elif arith_op.operation_kind == ArithmeticOperationKind.InplaceXor:
351
351
  op = "^="
352
352
  else:
353
353
  op = "+="
@@ -469,9 +469,9 @@ class PythonPrettyPrinter(Visitor):
469
469
  return f"{self.visit(var_ref.base_handle)}.{self.visit(var_ref.field)}"
470
470
 
471
471
  def visit_ArithmeticOperation(self, arith_op: ArithmeticOperation) -> str:
472
- if arith_op.get_operation_kind() == ArithmeticOperationKind.Assignment:
472
+ if arith_op.operation_kind == ArithmeticOperationKind.Assignment:
473
473
  op = "|="
474
- elif arith_op.get_operation_kind() == ArithmeticOperationKind.InplaceXor:
474
+ elif arith_op.operation_kind == ArithmeticOperationKind.InplaceXor:
475
475
  op = "^="
476
476
  else:
477
477
  op = "+="
classiq/synthesis.py CHANGED
@@ -1,17 +1,41 @@
1
- from typing import NewType
1
+ from typing import Any, NewType, Optional
2
2
 
3
3
  import pydantic
4
4
 
5
+ from classiq.interface.exceptions import ClassiqValueError
5
6
  from classiq.interface.executor.execution_preferences import ExecutionPreferences
6
7
  from classiq.interface.generator.model.constraints import Constraints
7
8
  from classiq.interface.generator.model.preferences.preferences import Preferences
8
9
  from classiq.interface.model.model import Model, SerializedModel
9
10
 
11
+ from classiq import QuantumProgram
10
12
  from classiq._internals import async_utils
11
13
  from classiq._internals.api_wrapper import ApiWrapper
12
14
 
13
15
  SerializedQuantumProgram = NewType("SerializedQuantumProgram", str)
14
16
 
17
+ CANT_PARSE_QUANTUM_PROGRAM_MSG = (
18
+ "Can not parse quantum_program into GeneratedCircuit, \n"
19
+ )
20
+
21
+
22
+ def show(quantum_program: SerializedQuantumProgram) -> None:
23
+ """
24
+ Displays the interactive representation of the quantum program in the Classiq IDE.
25
+
26
+ Args:
27
+ quantum_program:
28
+ The serialized quantum program to be displayed.
29
+
30
+ Links:
31
+ [Visualization tool](https://docs.classiq.io/latest/reference-manual/analyzer/quantum-program-visualization-tool/)
32
+ """
33
+ try:
34
+ circuit = QuantumProgram.parse_raw(quantum_program)
35
+ except pydantic.error_wrappers.ValidationError as exc:
36
+ raise ClassiqValueError(CANT_PARSE_QUANTUM_PROGRAM_MSG) from exc
37
+ circuit.show() # type: ignore[attr-defined]
38
+
15
39
 
16
40
  async def synthesize_async(
17
41
  serialized_model: SerializedModel,
@@ -21,82 +45,182 @@ async def synthesize_async(
21
45
  return SerializedQuantumProgram(quantum_program.json(indent=2))
22
46
 
23
47
 
24
- def synthesize(serialized_model: SerializedModel) -> SerializedQuantumProgram:
48
+ def synthesize(
49
+ serialized_model: SerializedModel, auto_show: bool = False
50
+ ) -> SerializedQuantumProgram:
25
51
  """
26
52
  Synthesize a model with the Classiq engine to receive a quantum program.
27
53
  [More details](https://docs.classiq.io/latest/reference-manual/synthesis/)
28
54
 
29
55
  Args:
30
56
  serialized_model: A model object serialized as a string.
57
+ auto_show: boolean. whether to call `show` on the output
31
58
 
32
59
  Returns:
33
60
  SerializedQuantumProgram: Quantum program serialized as a string. (See: QuantumProgram)
34
61
  """
35
- return async_utils.run(synthesize_async(serialized_model))
62
+ result = async_utils.run(synthesize_async(serialized_model))
63
+ if auto_show:
64
+ show(result)
65
+ return result
36
66
 
37
67
 
38
68
  def set_preferences(
39
- serialized_model: SerializedModel, preferences: Preferences
69
+ serialized_model: SerializedModel,
70
+ preferences: Optional[Preferences] = None,
71
+ **kwargs: Any
40
72
  ) -> SerializedModel:
41
73
  """
42
- Updates the preferences of a (serialized) model and returns the updated model.
74
+ Overrides the preferences of a (serialized) model and returns the updated model.
43
75
 
44
76
  Args:
45
77
  serialized_model: The model in serialized form.
46
- preferences: The new preferences to be set for the model.
78
+ preferences: The new preferences to be set for the model. Can be passed as keyword arguments.
47
79
 
48
80
  Returns:
49
81
  SerializedModel: The updated model with the new preferences applied.
50
82
  """
83
+ if preferences is None:
84
+ if kwargs:
85
+ preferences = Preferences(**kwargs)
86
+ else:
87
+ raise ClassiqValueError(
88
+ "Missing preferences. Either pass `Preferences` object or pass keywords"
89
+ )
90
+
51
91
  model = pydantic.parse_raw_as(Model, serialized_model)
52
92
  model.preferences = preferences
53
93
  return model.get_model()
54
94
 
55
95
 
96
+ def update_preferences(
97
+ serialized_model: SerializedModel, **kwargs: Any
98
+ ) -> SerializedModel:
99
+ """
100
+ Updates the preferences of a (serialized) model and returns the updated model.
101
+
102
+ Args:
103
+ serialized_model: The model in serialized form.
104
+ kwargs: key-value combination of preferences fields to update
105
+
106
+ Returns:
107
+ SerializedModel: The updated model with the new preferences applied.
108
+ """
109
+ model = pydantic.parse_raw_as(Model, serialized_model)
110
+
111
+ for key, value in kwargs.items():
112
+ setattr(model.preferences, key, value)
113
+
114
+ return model.get_model()
115
+
116
+
56
117
  def set_constraints(
57
- serialized_model: SerializedModel, constraints: Constraints
118
+ serialized_model: SerializedModel,
119
+ constraints: Optional[Constraints] = None,
120
+ **kwargs: Any
58
121
  ) -> SerializedModel:
59
122
  """
60
- Updates the constraints of a (serialized) model and returns the updated model.
123
+ Overrides the constraints of a (serialized) model and returns the updated model.
61
124
 
62
125
  Args:
63
126
  serialized_model: The model in serialized form.
64
- constraints: The new constraints to be set for the model.
127
+ constraints: The new constraints to be set for the model. Can be passed as keyword arguments.
65
128
 
66
129
  Returns:
67
130
  SerializedModel: The updated model with the new constraints applied.
68
131
  """
132
+ if constraints is None:
133
+ if kwargs:
134
+ constraints = Constraints(**kwargs)
135
+ else:
136
+ raise ClassiqValueError(
137
+ "Missing constraints. Either pass `Constraints` object or pass keywords"
138
+ )
139
+
69
140
  model = pydantic.parse_raw_as(Model, serialized_model)
70
141
  model.constraints = constraints
71
142
  return model.get_model()
72
143
 
73
144
 
145
+ def update_constraints(
146
+ serialized_model: SerializedModel, **kwargs: Any
147
+ ) -> SerializedModel:
148
+ """
149
+ Updates the constraints of a (serialized) model and returns the updated model.
150
+
151
+ Args:
152
+ serialized_model: The model in serialized form.
153
+ kwargs: key-value combination of constraints fields to update
154
+
155
+ Returns:
156
+ SerializedModel: The updated model with the new constraints applied.
157
+ """
158
+ model = pydantic.parse_raw_as(Model, serialized_model)
159
+
160
+ for key, value in kwargs.items():
161
+ setattr(model.constraints, key, value)
162
+
163
+ return model.get_model()
164
+
165
+
74
166
  def set_execution_preferences(
75
- serialized_model: SerializedModel, execution_preferences: ExecutionPreferences
167
+ serialized_model: SerializedModel,
168
+ execution_preferences: Optional[ExecutionPreferences] = None,
169
+ **kwargs: Any
76
170
  ) -> SerializedModel:
77
171
  """
78
- Attaching the execution preferences to the model.
172
+ Overrides the execution preferences of a (serialized) model and returns the updated model.
79
173
 
80
174
  Args:
81
175
  serialized_model: A serialization of the defined model.
82
- execution_preferences: The execution preferences we want to attach to the model.
176
+ execution_preferences: The new execution preferences to be set for the model. Can be passed as keyword arguments.
83
177
  Returns:
84
178
  SerializedModel: The model with the attached execution preferences.
85
179
 
86
180
  For more examples please see: [set_execution_preferences](https://docs.classiq.io/latest/reference-manual/executor/?h=set_execution_preferences#usage)
87
-
88
181
  """
182
+ if execution_preferences is None:
183
+ if kwargs:
184
+ execution_preferences = ExecutionPreferences(**kwargs)
185
+ else:
186
+ raise ClassiqValueError(
187
+ "Missing execution_preferences. Either pass `ExecutionPreferences` object or pass keywords"
188
+ )
89
189
 
90
190
  model = pydantic.parse_raw_as(Model, serialized_model)
91
191
  model.execution_preferences = execution_preferences
92
192
  return model.get_model()
93
193
 
94
194
 
195
+ def update_execution_preferences(
196
+ serialized_model: SerializedModel, **kwargs: Any
197
+ ) -> SerializedModel:
198
+ """
199
+ Updates the execution_preferences of a (serialized) model and returns the updated model.
200
+
201
+ Args:
202
+ serialized_model: The model in serialized form.
203
+ kwargs: key-value combination of execution_preferences fields to update
204
+
205
+ Returns:
206
+ SerializedModel: The updated model with the new execution_preferences applied.
207
+ """
208
+ model = pydantic.parse_raw_as(Model, serialized_model)
209
+
210
+ for key, value in kwargs.items():
211
+ setattr(model.execution_preferences, key, value)
212
+
213
+ return model.get_model()
214
+
215
+
95
216
  __all__ = [
96
217
  "SerializedModel",
97
218
  "SerializedQuantumProgram",
98
- "synthesize",
99
- "set_preferences",
100
219
  "set_constraints",
101
220
  "set_execution_preferences",
221
+ "set_preferences",
222
+ "synthesize",
223
+ "update_constraints",
224
+ "update_execution_preferences",
225
+ "update_preferences",
102
226
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: classiq
3
- Version: 0.48.0
3
+ Version: 0.49.0
4
4
  Summary: Classiq's Python SDK for quantum computing
5
5
  Home-page: https://classiq.io
6
6
  License: Proprietary
@@ -1,4 +1,4 @@
1
- classiq/__init__.py,sha256=Fkx4vmBHR2h2x4e8OOp34tOspjXcrz2XiMYaGZ4Ei1g,3128
1
+ classiq/__init__.py,sha256=kJpBZtjz012nNg9KoP6bi5TtYTTGOFPi3bF7ZoRUfT4,3290
2
2
  classiq/_analyzer_extras/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  classiq/_analyzer_extras/_ipywidgets_async_extension.py,sha256=DF-G1Dhp51P6qlxTJT-kxPMJiYy9tyNoCvqbPQOeJd0,2163
4
4
  classiq/_analyzer_extras/interactive_hardware.py,sha256=f7ad2HeFq1f-2dJtPpgOE_w2IFzm49W6P_c-MzqJ5qE,3257
@@ -22,7 +22,7 @@ classiq/analyzer/__init__.py,sha256=qPMmlHic9bHkjQ71aPJbHph1IVrY_lsOpcvjLPOJE4s,
22
22
  classiq/analyzer/analyzer.py,sha256=ON4k7OqPwS20IFVYyPsP7CsNUh7YsAyH9EGAbCSRsZI,7224
23
23
  classiq/analyzer/analyzer_utilities.py,sha256=9UfbD3_078-KJ85L4Auwtoc5dOUbzb3ZybHwgTO7w7A,3664
24
24
  classiq/analyzer/rb.py,sha256=z1AEYcxOJBmOiifVxejjAJWtJT8Lcg8ahFQEh4gRZVw,4951
25
- classiq/analyzer/show_interactive_hack.py,sha256=8AoQ6yJsW86Uz1i3EtIXaepGYk_s_HsN69Ggmq8-17k,946
25
+ classiq/analyzer/show_interactive_hack.py,sha256=lW56gbwn83Zcl7107hIpee7Uht5sOAD03A_ZSVjkbrM,1488
26
26
  classiq/analyzer/url_utils.py,sha256=FfcERpHqqNILwTt7LNwLUKURmpN21rilQVFpnvPtdHE,690
27
27
  classiq/applications/__init__.py,sha256=ANRW68--0PJMxA2Z5XuhGrDKLilkTdj3U5y9EAmPUfU,331
28
28
  classiq/applications/chemistry/__init__.py,sha256=JwKGDR6NiKoykoNdOSovbZges6i40N2xkxYbAMHOS2A,1119
@@ -93,7 +93,7 @@ classiq/execution/jobs.py,sha256=t7Wdegpi6lylthg23a98rSmoZ8xXNGfz--efHYw39JY,956
93
93
  classiq/execution/qnn.py,sha256=qsOA2mD8Ne_4VwvyGPfuHVDTzyxVnDHwE2gfoaOMsf8,2339
94
94
  classiq/executor.py,sha256=jKD5O_tJpL2NMTC_N0NEuPJEmKZIaqsTpQrgZ88sleg,2594
95
95
  classiq/interface/__init__.py,sha256=cg7hD_XVu1_jJ1fgwmT0rMIoZHopNVeB8xtlmMx-E_A,83
96
- classiq/interface/_version.py,sha256=vK6DuSdhhyiaz7vVMCdZUXqVEX6JjpArpmU3wGys474,197
96
+ classiq/interface/_version.py,sha256=JUL5JBM1c6ImIoSihQYA76hNNGvABq6AvQdP5Mf11BM,197
97
97
  classiq/interface/analyzer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
98
98
  classiq/interface/analyzer/analysis_params.py,sha256=043hfS-I3Ec6tkcniKMQQUiRyEC7zlNhntTBpZQB8hw,3725
99
99
  classiq/interface/analyzer/cytoscape_graph.py,sha256=_2GviubgrDMAbF57PTDMhS9W0mTCLYWdyu0HndDPh54,2116
@@ -102,11 +102,11 @@ classiq/interface/applications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
102
102
  classiq/interface/applications/qsvm.py,sha256=7LElAz4QwTeia7MeAOy8WUHvuFUOUojs8j2wDOwPMao,3363
103
103
  classiq/interface/ast_node.py,sha256=EE06R8KwRA-QkK44Ou9TmMxiaa8J60G9Z9qf9T76k_k,398
104
104
  classiq/interface/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
105
- classiq/interface/backend/backend_preferences.py,sha256=HbQ4xo4WjnW_kd2EeLRCVLbcNl_2SOBauLRtU9P5eK0,19685
105
+ classiq/interface/backend/backend_preferences.py,sha256=l05slQjXiIFul59f0FmI6M1WHOY67qcBT3wWn3nIqj8,20649
106
106
  classiq/interface/backend/ionq/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
107
  classiq/interface/backend/ionq/ionq_quantum_program.py,sha256=2DRnrzeSDC34mIdpsafWFSm7ZnHhKYspJYGULHv0XgI,1584
108
108
  classiq/interface/backend/pydantic_backend.py,sha256=aRf8kljUMiLBH2odswSCJ3hbex_1nOGTK3YmBC6EfmQ,1462
109
- classiq/interface/backend/quantum_backend_providers.py,sha256=vxaGmRwfIQtYQOyzkTNHxIYI2NOicI2sOGwNStuL-SU,6256
109
+ classiq/interface/backend/quantum_backend_providers.py,sha256=d77iUBupdvocQTALuFGbeZjkm7Foav03pimGHftmtqs,6463
110
110
  classiq/interface/chemistry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
111
111
  classiq/interface/chemistry/ansatz_library.py,sha256=3ki3uaV77cUxUxUzDbn3mVhjvMoKejJ5bIR1kXpBT1k,360
112
112
  classiq/interface/chemistry/elements.py,sha256=Yy8L80SBVgmuKQyW-GlZKzwTqnP1O9po-FGFmKMJLRA,1181
@@ -139,9 +139,9 @@ classiq/interface/combinatorial_optimization/result.py,sha256=noMqXdirAq7weswk3t
139
139
  classiq/interface/combinatorial_optimization/sense.py,sha256=P8_kJRf3aUKbCkIqOP3tOc81Vpz9yW4Z74RGaYbd9TA,262
140
140
  classiq/interface/combinatorial_optimization/solver_types.py,sha256=kcLt80fQucq_DWmJXmmVljwCGV4gtDnqOMlJdemhPQc,135
141
141
  classiq/interface/debug_info/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
142
- classiq/interface/debug_info/debug_info.py,sha256=c8U3yiDgPFzgFhmCiG8Lq_3YAkDSIh7PEhaZG4e0MhU,3070
142
+ classiq/interface/debug_info/debug_info.py,sha256=eDOKHDdUnetvITIeOl1V_yH_Q29mTIiZxqmsBWxNCAk,3114
143
143
  classiq/interface/enum_utils.py,sha256=QxkxLGgON8vdSzLZzHFlPEBJoGOqoIwpESEfLfRqN0w,312
144
- classiq/interface/exceptions.py,sha256=kBi7lViviXksngC60NFpMtjKtSx8J6lwTV2ERhPr_-s,4113
144
+ classiq/interface/exceptions.py,sha256=-mM4XQV-PCsyPvnYWYRHNQgyGairmI6qpCNa65KljUg,4121
145
145
  classiq/interface/execution/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
146
146
  classiq/interface/execution/jobs.py,sha256=24QKl98LBAYm7OgUk64Ch4bYasuivGFhG33L9KWunCw,585
147
147
  classiq/interface/execution/primitives.py,sha256=a_vH8YgdMeEVYx1h9sgNAqbDQmqca3ePvHfsADHJMn4,584
@@ -247,7 +247,7 @@ classiq/interface/generator/functions/function_declaration.py,sha256=xlNLzVsU_Kz
247
247
  classiq/interface/generator/functions/port_declaration.py,sha256=ESJE_19jOg_zS1reFN5dq0xgobZ6J3C3DsIs6EME1c4,1100
248
248
  classiq/interface/generator/functions/qmod_python_interface.py,sha256=DVHHTMtbWn38nN5XrTMrfJHkIzeKRU54AWfLymLppvs,66
249
249
  classiq/interface/generator/functions/type_name.py,sha256=3Xzo11Wbe3azNfoATBiKMcHK5xPm-0R0-oN3CifF-QI,2593
250
- classiq/interface/generator/generated_circuit_data.py,sha256=nMEcqeURljkmvrZ7m-i904RDTav1RuZJDsMa4yTGtkg,5415
250
+ classiq/interface/generator/generated_circuit_data.py,sha256=h2CdXuvBD1xiJfGMQcAS45afSJMjynTrLj2RNldEiAQ,5897
251
251
  classiq/interface/generator/grover_diffuser.py,sha256=aqamtljo986D5k-DTh2B4yBlEH3F7DOJXjxS9hhrGps,3530
252
252
  classiq/interface/generator/grover_operator.py,sha256=warGAu9gZH0WIWBLkKdfARMivxNnb8EuOWJrH71obyQ,3822
253
253
  classiq/interface/generator/hadamard_transform.py,sha256=NI4oZBpDCGfaw2OTb5SL3iSGI_nDtyUgElTCO4pEKnk,673
@@ -330,7 +330,7 @@ classiq/interface/generator/validations/validator_functions.py,sha256=n-K4R903O2
330
330
  classiq/interface/generator/visitor.py,sha256=4stDieh3p7JYuSL9bH_FqKrn0k0Nl8bMO72RQocZ8M8,2864
331
331
  classiq/interface/grover/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
332
332
  classiq/interface/grover/grover_modelling_params.py,sha256=eMXdjfuGlVq5qD3QyG-C8mAyIBAoxzkjF052M4b1i-k,390
333
- classiq/interface/hardware.py,sha256=1HI2HTN3HADO-FWzvTryG_vJ4ifVOILlgwVrPLdFwvs,1987
333
+ classiq/interface/hardware.py,sha256=1ZXtKhkhpJo2-Fg7oqGMe-XDG9OBNIUj29gmukuJblQ,2007
334
334
  classiq/interface/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
335
335
  classiq/interface/helpers/classproperty.py,sha256=pt9A39GgEMzj2nbY5gjFp_CId_wom6lOQt_PADidT4Y,279
336
336
  classiq/interface/helpers/custom_encoders.py,sha256=0-9DTHwQr-I_vP1Ie4Z9N4qfzDhFvGT4qsXP-EdDegs,107
@@ -361,7 +361,7 @@ classiq/interface/model/port_declaration.py,sha256=l5ngik16iZU7BevFfyZvFY2YfY9pM
361
361
  classiq/interface/model/power.py,sha256=3C2NOkq_t8AafvYsN51hmgMIJB0pic_DvZxYbID9WX4,388
362
362
  classiq/interface/model/quantum_expressions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
363
363
  classiq/interface/model/quantum_expressions/amplitude_loading_operation.py,sha256=v45Eb44VxyBTMH-E1NTb5-YdKCj5EY_rb-BClHI0A48,2428
364
- classiq/interface/model/quantum_expressions/arithmetic_operation.py,sha256=EPk0SkJvierFUIh0GOMRNo_xiZvWUXCYKjhToFy9hAM,3347
364
+ classiq/interface/model/quantum_expressions/arithmetic_operation.py,sha256=HKFZci4z4QSmE8Bpwu6_6sCU1Wb-jzovrmsU1lmxjmw,3428
365
365
  classiq/interface/model/quantum_expressions/quantum_expression.py,sha256=yw-sYXbaaKoUSL8oujDFBjyShxCfAQnPPX64h-Yh-_8,2118
366
366
  classiq/interface/model/quantum_function_call.py,sha256=YOwmNuz7F0I7jimVjy69eGI044iXS0hAcBjBRuvhsI8,7313
367
367
  classiq/interface/model/quantum_function_declaration.py,sha256=N1iccemg-xC4Cc1pPLWT3cBGYO3RIEBPVz_zlWWkLpQ,7704
@@ -411,11 +411,11 @@ classiq/model_expansions/quantum_operations/classicalif.py,sha256=6SFumWVIWCTNQs
411
411
  classiq/model_expansions/quantum_operations/control.py,sha256=SibNNK8gwzBMojwmXDg--SXbqhn3PJmIB2y0sK-7rJA,10151
412
412
  classiq/model_expansions/quantum_operations/emitter.py,sha256=wMuICR_CzLmaiwhS6EZWu4H864ZxTndITQC1gNRVaWA,10899
413
413
  classiq/model_expansions/quantum_operations/expression_operation.py,sha256=q2EaNec3kvTw2xDVGrd36p_rHiNMaWzkR0qFC55sJDY,8182
414
- classiq/model_expansions/quantum_operations/inplace_binary_operation.py,sha256=_r7NFHkaC3AxV8DWY_aFrOJj6YLf6Njxu8m4h2hXtmo,11264
414
+ classiq/model_expansions/quantum_operations/inplace_binary_operation.py,sha256=OoEBjjE9sXoOuV3h7p29UN6DgGywcXPVHntSLHXAUp4,11142
415
415
  classiq/model_expansions/quantum_operations/invert.py,sha256=iR6ZpTyntchWb5kJFFMCC6rkBURbueJO42H7-8ljbKw,1661
416
416
  classiq/model_expansions/quantum_operations/phase.py,sha256=W3qHfxs9S25yE2Ofgy9NwO5t9og6DxhqSQW8w1ptm1w,7337
417
417
  classiq/model_expansions/quantum_operations/power.py,sha256=89FEo5xJkOxCP7L7Jy9MJatRbbzjVVR0oc8Q7aBzF8Q,2661
418
- classiq/model_expansions/quantum_operations/quantum_assignment_operation.py,sha256=1bT87G6aOPxtzmAhklV2zhZCwQooGqjlREXIjYv0YJQ,7503
418
+ classiq/model_expansions/quantum_operations/quantum_assignment_operation.py,sha256=-WjwH-DmRbIZa4BusHl8HC7fvt7pc0U2IeU7-Mz5k-A,7485
419
419
  classiq/model_expansions/quantum_operations/quantum_function_call.py,sha256=hQcOwaZV0qe7SmlqV3hdlKIcX_EKmxGOysH0lOVh9F0,729
420
420
  classiq/model_expansions/quantum_operations/repeat.py,sha256=zxxKxbMqa_4zkA5x10NrDpgUqEHKId4WxLXmD4aboJk,2060
421
421
  classiq/model_expansions/quantum_operations/variable_decleration.py,sha256=fRMRxctSxQFhPIhTMMVGC0F9p4iBLIMCD59G_j4Rk2Y,1196
@@ -471,10 +471,10 @@ classiq/qmod/generative.py,sha256=--557jt22gVKJROwcSA7AzQBdgNl9zMXGEfRJVI6W1k,15
471
471
  classiq/qmod/model_state_container.py,sha256=Csm3DbdzGsNG4hQyT8o8Hrwu5CqU3aeIYqlWu15saK4,706
472
472
  classiq/qmod/native/__init__.py,sha256=00ZlOKotzZ5MPkwwWNTnwrPeNRTFurFNJgueixP6BVo,151
473
473
  classiq/qmod/native/expression_to_qmod.py,sha256=p_WHipErHWbIDZkRPT487xik_49MheasCTiQvHVam2Y,7134
474
- classiq/qmod/native/pretty_printer.py,sha256=dYbhc4npUa9aZC2q_YDTwhecz5lbuIZWTWPzZMA4p24,15335
474
+ classiq/qmod/native/pretty_printer.py,sha256=MnsSSA2hmZ_7lkB0ZjhwRy18zVwEEM0URgIP9CFv41U,15323
475
475
  classiq/qmod/pretty_print/__init__.py,sha256=TY7bQpDw75-oLUinUoCUMQnbjUcFzcFqHO1sEK-DgPE,157
476
476
  classiq/qmod/pretty_print/expression_to_python.py,sha256=e9PG553YlTh1R7ywRFYoMyMIsh1oehWU3n0XN8Mj6GY,7471
477
- classiq/qmod/pretty_print/pretty_printer.py,sha256=Z8c-MloAh34PKyDeDeQsmMvGVNjvetc0FARcGS_xqF0,21500
477
+ classiq/qmod/pretty_print/pretty_printer.py,sha256=cO0fVbDoWPfMmRr9WwgW8zAKp9rlaHKfCi1pyXTIIXo,21488
478
478
  classiq/qmod/python_classical_type.py,sha256=kodOLRAm4UTnrRcHGCrUKJGMJBrPmtLEvE4K5SSKkgw,2404
479
479
  classiq/qmod/qfunc.py,sha256=R9Dif90S-RfOnkFWA53p-ZuG1MFVGJoNuMKPC1oULuM,1304
480
480
  classiq/qmod/qmod_constant.py,sha256=ZGYhlN4sN4opm91LGFxN7eShcj5mTlDH3DJXpazW-Zk,3857
@@ -498,8 +498,7 @@ classiq/qmod/symbolic_type.py,sha256=whMy3Uw4iE2SOVfHeyfTpDJ3BH6Rxlhk492ij-4QRU4
498
498
  classiq/qmod/type_attribute_remover.py,sha256=dN9dcsmFQI1UXz_DllGKl2BP4XkyvGdNk8diPan-9RE,1236
499
499
  classiq/qmod/utilities.py,sha256=z_VnIRmOYTWjJp2UlOcWK0rQRtMqysmP_Gr6WYY_nak,2734
500
500
  classiq/qmod/write_qmod.py,sha256=SO7hdBdO31lTzyeaJ-Htyma-aJmrbBNtABNEB2llI4Q,1818
501
- classiq/show.py,sha256=GyxceOzWrnVC9KvsLdHJbxycD9WkcQkkhOSw45P6CPo,1428
502
- classiq/synthesis.py,sha256=wBk5iFCH2Bw9AvVPzGvTI96zjQXw6QpKRN9VZxc_Xl0,3350
503
- classiq-0.48.0.dist-info/METADATA,sha256=JUmyJqwhybYuCk29KauILlmXTciyNJQFnQJeMW0EjcA,3458
504
- classiq-0.48.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
505
- classiq-0.48.0.dist-info/RECORD,,
501
+ classiq/synthesis.py,sha256=s9-o3lzSxghx0YftQg3iZGvIreJ-H7DSTQYsevKcKw8,7374
502
+ classiq-0.49.0.dist-info/METADATA,sha256=ZeMVAHnOEaDZFOBes0DgEd7_Lz_RT8vpUEkKSSLxwAU,3458
503
+ classiq-0.49.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
504
+ classiq-0.49.0.dist-info/RECORD,,
classiq/show.py DELETED
@@ -1,44 +0,0 @@
1
- import re
2
-
3
- import pydantic
4
-
5
- from classiq.interface.analyzer.result import QasmCode
6
- from classiq.interface.exceptions import ClassiqValueError
7
-
8
- from classiq import QuantumProgram
9
- from classiq._internals.api_wrapper import ApiWrapper
10
- from classiq._internals.async_utils import syncify_function
11
- from classiq.synthesis import SerializedQuantumProgram
12
-
13
- QASM_VERSION_REGEX = re.compile("OPENQASM (\\d*.\\d*);")
14
-
15
-
16
- async def qasm_show_interactive_async(qasm_code: str) -> None:
17
- circuit = await ApiWrapper.get_generated_circuit_from_qasm(QasmCode(code=qasm_code))
18
- circuit.show() # type: ignore[attr-defined]
19
-
20
-
21
- qasm_show_interactive = syncify_function(qasm_show_interactive_async)
22
-
23
-
24
- CANT_PARSE_QUANTUM_PROGRAM_MSG = (
25
- "Can not parse quantum_program into GeneratedCircuit, \n"
26
- )
27
-
28
-
29
- def show(quantum_program: SerializedQuantumProgram) -> None:
30
- """
31
- Displays the interactive representation of the quantum program in the Classiq IDE.
32
-
33
- Args:
34
- quantum_program:
35
- The serialized quantum program to be displayed.
36
-
37
- Links:
38
- [Visualization tool](https://docs.classiq.io/latest/reference-manual/analyzer/quantum-program-visualization-tool/)
39
- """
40
- try:
41
- circuit = QuantumProgram.parse_raw(quantum_program)
42
- except pydantic.error_wrappers.ValidationError as exc:
43
- raise ClassiqValueError(CANT_PARSE_QUANTUM_PROGRAM_MSG) from exc
44
- circuit.show() # type: ignore[attr-defined]