classiq 0.95.0__py3-none-any.whl → 0.96.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.

Potentially problematic release.


This version of classiq might be problematic. Click here for more details.

Files changed (31) hide show
  1. classiq/_internals/api_wrapper.py +0 -83
  2. classiq/applications/iqae/iqae.py +6 -3
  3. classiq/applications/qnn/gradients/simple_quantum_gradient.py +1 -1
  4. classiq/applications/qnn/qlayer.py +1 -1
  5. classiq/applications/qnn/torch_utils.py +2 -2
  6. classiq/execution/__init__.py +0 -3
  7. classiq/execution/user_budgets.py +0 -1
  8. classiq/interface/_version.py +1 -1
  9. classiq/interface/backend/backend_preferences.py +0 -29
  10. classiq/interface/backend/quantum_backend_providers.py +0 -2
  11. classiq/interface/generator/arith/register_user_input.py +1 -1
  12. classiq/interface/generator/hardware_efficient_ansatz.py +1 -1
  13. classiq/interface/generator/quantum_function_call.py +1 -1
  14. classiq/interface/hardware.py +0 -1
  15. classiq/interface/server/routes.py +0 -12
  16. classiq/model_expansions/generative_functions.py +6 -8
  17. classiq/open_library/functions/__init__.py +3 -5
  18. classiq/open_library/functions/amplitude_loading.py +24 -5
  19. classiq/open_library/functions/lcu.py +47 -18
  20. classiq/open_library/functions/state_preparation.py +7 -7
  21. classiq/qmod/builtins/functions/__init__.py +2 -0
  22. classiq/qmod/builtins/functions/allocation.py +21 -0
  23. classiq/qmod/builtins/operations.py +68 -4
  24. classiq/qmod/utilities.py +0 -10
  25. {classiq-0.95.0.dist-info → classiq-0.96.0.dist-info}/METADATA +1 -1
  26. {classiq-0.95.0.dist-info → classiq-0.96.0.dist-info}/RECORD +28 -31
  27. classiq/execution/iqcc.py +0 -128
  28. classiq/interface/execution/iqcc.py +0 -42
  29. classiq/open_library/functions/lookup_table.py +0 -71
  30. {classiq-0.95.0.dist-info → classiq-0.96.0.dist-info}/WHEEL +0 -0
  31. {classiq-0.95.0.dist-info → classiq-0.96.0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -12,15 +12,6 @@ from classiq.interface.analyzer.analysis_params import AnalysisRBParams
12
12
  from classiq.interface.analyzer.result import GraphStatus, QmodCode
13
13
  from classiq.interface.enum_utils import StrEnum
14
14
  from classiq.interface.exceptions import ClassiqAPIError, ClassiqValueError
15
- from classiq.interface.execution.iqcc import (
16
- IQCCAuthItemsDetails,
17
- IQCCInitAuthData,
18
- IQCCInitAuthResponse,
19
- IQCCListAuthMethods,
20
- IQCCListAuthTargets,
21
- IQCCProbeAuthData,
22
- IQCCProbeAuthResponse,
23
- )
24
15
  from classiq.interface.execution.primitives import PrimitivesInput
25
16
  from classiq.interface.executor import execution_request
26
17
  from classiq.interface.executor.quantum_program_params import (
@@ -488,80 +479,6 @@ class ApiWrapper:
488
479
  raise ClassiqAPIError(f"Unexpected value: {data}")
489
480
  return [HardwareInformation.model_validate(info) for info in data]
490
481
 
491
- @classmethod
492
- async def call_iqcc_init_auth(
493
- cls,
494
- data: IQCCInitAuthData,
495
- http_client: httpx.AsyncClient | None = None,
496
- ) -> IQCCInitAuthResponse:
497
- response = await cls._call_task_pydantic(
498
- http_method=HTTPMethod.PUT,
499
- url=f"{routes.IQCC_INIT_AUTH_FULL_PATH}",
500
- model=data,
501
- http_client=http_client,
502
- )
503
- return IQCCInitAuthResponse.model_validate(response)
504
-
505
- @classmethod
506
- async def call_iqcc_probe_auth(
507
- cls,
508
- data: IQCCProbeAuthData,
509
- http_client: httpx.AsyncClient | None = None,
510
- ) -> IQCCProbeAuthResponse | None:
511
- try:
512
- response = await cls._call_task_pydantic(
513
- http_method=HTTPMethod.PUT,
514
- url=f"{routes.IQCC_PROBE_AUTH_FULL_PATH}",
515
- model=data,
516
- http_client=http_client,
517
- )
518
- except ClassiqAPIError as ex:
519
- if ex.status_code == 418:
520
- return None
521
- raise
522
-
523
- return IQCCProbeAuthResponse.model_validate(response)
524
-
525
- @classmethod
526
- async def call_iqcc_list_auth_scopes(
527
- cls,
528
- http_client: httpx.AsyncClient | None = None,
529
- ) -> IQCCAuthItemsDetails:
530
- response = await cls._call_task(
531
- http_method=HTTPMethod.GET,
532
- url=routes.IQCC_LIST_AUTH_SCOPES_FULL_PATH,
533
- http_client=http_client,
534
- )
535
- return IQCCAuthItemsDetails.model_validate(response)
536
-
537
- @classmethod
538
- async def call_iqcc_list_auth_methods(
539
- cls,
540
- data: IQCCListAuthMethods,
541
- http_client: httpx.AsyncClient | None = None,
542
- ) -> IQCCAuthItemsDetails:
543
- response = await cls._call_task_pydantic(
544
- http_method=HTTPMethod.PUT,
545
- url=routes.IQCC_LIST_AUTH_METHODS_FULL_PATH,
546
- model=data,
547
- http_client=http_client,
548
- )
549
- return IQCCAuthItemsDetails.model_validate(response)
550
-
551
- @classmethod
552
- async def call_iqcc_list_auth_targets(
553
- cls,
554
- data: IQCCListAuthTargets,
555
- http_client: httpx.AsyncClient | None = None,
556
- ) -> IQCCAuthItemsDetails:
557
- response = await cls._call_task_pydantic(
558
- http_method=HTTPMethod.PUT,
559
- url=routes.IQCC_LIST_AUTH_TARGETS_FULL_PATH,
560
- model=data,
561
- http_client=http_client,
562
- )
563
- return IQCCAuthItemsDetails.model_validate(response)
564
-
565
482
  @classmethod
566
483
  async def call_get_all_budgets(cls) -> list[UserBudget]:
567
484
  data = await client().call_api(
@@ -20,8 +20,10 @@ from classiq.qmod import (
20
20
  QCallable,
21
21
  )
22
22
  from classiq.qmod.builtins import Z, allocate, bind, within_apply
23
+ from classiq.qmod.builtins.functions.allocation import drop
23
24
  from classiq.qmod.create_model_function import create_model
24
- from classiq.qmod.qfunc import qfunc
25
+ from classiq.qmod.qfunc import qfunc, qperm
26
+ from classiq.qmod.qmod_variable import Const
25
27
  from classiq.synthesis import synthesize
26
28
 
27
29
 
@@ -83,8 +85,8 @@ class IQAE:
83
85
  def space_transform(est_reg: QArray) -> None:
84
86
  state_prep_op(est_reg[0 : est_reg.len - 1], est_reg[est_reg.len - 1])
85
87
 
86
- @qfunc
87
- def oracle(est_reg: QArray) -> None:
88
+ @qperm
89
+ def oracle(est_reg: Const[QArray]) -> None:
88
90
  Z(est_reg[est_reg.len - 1])
89
91
 
90
92
  @qfunc
@@ -105,6 +107,7 @@ class IQAE:
105
107
  est_reg,
106
108
  ),
107
109
  )
110
+ drop(problem_vars)
108
111
 
109
112
  if self._model is None:
110
113
  self._model = create_model(
@@ -59,7 +59,7 @@ def _differentiate_tensor(
59
59
  # The minus comes from the way pytorch defines diff
60
60
  # it diffs the second object minus the first
61
61
  # where we want the first minus the second
62
- diff = -tensor.diff(axis=axis).squeeze(axis) # type: ignore[call-arg] # torch does accept `axis` keyword
62
+ diff = -tensor.diff(axis=axis).squeeze(axis)
63
63
  return diff / (2 * epsilon)
64
64
 
65
65
 
@@ -104,7 +104,7 @@ class QLayerFunction(torch.autograd.Function):
104
104
  )
105
105
 
106
106
  @staticmethod
107
- def backward( # type: ignore[override]
107
+ def backward(
108
108
  ctx: Any, grad_output: Tensor
109
109
  ) -> tuple[Tensor | None, Tensor | None, None, None, None, None]:
110
110
  """
@@ -23,7 +23,7 @@ def get_shape_second_dimension(shape: torch.Size) -> int:
23
23
  if len(shape) == 1:
24
24
  return 1
25
25
  elif len(shape) == 2:
26
- return shape[1]
26
+ return shape[1] # type: ignore[index]
27
27
  else:
28
28
  raise ClassiqValueError("Invalid shape dimension - must be 1D or 2D")
29
29
 
@@ -33,7 +33,7 @@ def get_shape_first_dimension(shape: torch.Size) -> int:
33
33
  raise ClassiqValueError("Invalid shape type - must have `__len__`")
34
34
 
35
35
  if len(shape) in (1, 2):
36
- return shape[0]
36
+ return shape[0] # type: ignore[index]
37
37
  else:
38
38
  raise ClassiqValueError("Invalid shape dimension - must be 1D or 2D")
39
39
 
@@ -8,7 +8,6 @@ from ..interface.executor.execution_preferences import __all__ as _ep_all
8
8
  from ..interface.executor.result import ExecutionDetails
9
9
  from ..interface.executor.vqe_result import VQESolverResult
10
10
  from .execution_session import ExecutionSession
11
- from .iqcc import generate_iqcc_token, generate_iqcc_token_async
12
11
  from .jobs import ExecutionJob, get_execution_jobs, get_execution_jobs_async
13
12
  from .qnn import execute_qnn
14
13
  from .user_budgets import (
@@ -33,8 +32,6 @@ __all__ = (
33
32
  "get_execution_jobs_async",
34
33
  "ExecutionSession",
35
34
  "execute_qnn",
36
- "generate_iqcc_token",
37
- "generate_iqcc_token_async",
38
35
  "get_budget",
39
36
  "get_budget_async",
40
37
  "set_budget_limit",
@@ -14,7 +14,6 @@ PROVIDER_MAPPER = {
14
14
  ProviderVendor.OQC: "OQC",
15
15
  ProviderVendor.INTEL: "INTEL",
16
16
  ProviderVendor.AQT: "AQT",
17
- ProviderVendor.IQCC: "IQCC",
18
17
  ProviderVendor.CLASSIQ: "CLASSIQ",
19
18
  }
20
19
 
@@ -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.95.0'
6
+ SEMVER_VERSION = '0.96.0'
7
7
  VERSION = str(Version(SEMVER_VERSION))
@@ -433,33 +433,6 @@ class AQTBackendPreferences(BackendPreferences):
433
433
  workspace: str = pydantic.Field(description="AQT workspace")
434
434
 
435
435
 
436
- class IQCCBackendPreferences(BackendPreferences):
437
- """
438
- NOTE: This is a work in progress and is subject to change.
439
-
440
- Represents the backend preferences specific to IQCC (Israeli Quantum Computing
441
- Center).
442
-
443
- Attributes:
444
- auth_token: The authorization token generated by calling `generate_iqcc_token`.
445
- target_id: The target ID of the login node.
446
- target_scope_id: The scope ID of the specified target.
447
- ssh_user_name: The user name to use when connecting to the SSH server on the login node.
448
- ssh_key: The private key to use when connecting to the SSH server on the login node.
449
- slurm_account: The account to use when initiating SLURM jobs.
450
- """
451
-
452
- backend_service_provider: ProviderTypeVendor.IQCC = pydantic.Field(
453
- default=ProviderVendor.IQCC
454
- )
455
- auth_token: str
456
- target_id: str
457
- target_scope_id: str
458
- ssh_user_name: str
459
- ssh_key: str
460
- slurm_account: str
461
-
462
-
463
436
  class CINECABackendPreferences(BackendPreferences):
464
437
  """
465
438
  Represents the backend preferences specific to CINECA.
@@ -512,7 +485,6 @@ BackendPreferencesTypes = Union[
512
485
  OQCBackendPreferences,
513
486
  IntelBackendPreferences,
514
487
  AQTBackendPreferences,
515
- IQCCBackendPreferences,
516
488
  CINECABackendPreferences,
517
489
  ]
518
490
 
@@ -530,7 +502,6 @@ __all__ = [
530
502
  "ClassiqSimulatorBackendNames",
531
503
  "GCPBackendPreferences",
532
504
  "IBMBackendPreferences",
533
- "IQCCBackendPreferences",
534
505
  "IntelBackendNames",
535
506
  "IntelBackendPreferences",
536
507
  "IonqBackendNames",
@@ -20,7 +20,6 @@ class ProviderVendor(StrEnum):
20
20
  OQC = "OQC"
21
21
  INTEL = "Intel"
22
22
  AQT = "AQT"
23
- IQCC = "IQCC"
24
23
  CINECA = "CINECA"
25
24
 
26
25
 
@@ -35,7 +34,6 @@ class ProviderTypeVendor:
35
34
  OQC = Literal[ProviderVendor.OQC]
36
35
  INTEL = Literal[ProviderVendor.INTEL]
37
36
  AQT = Literal[ProviderVendor.AQT]
38
- IQCC = Literal[ProviderVendor.IQCC]
39
37
  CINECA = Literal[ProviderVendor.CINECA]
40
38
 
41
39
 
@@ -19,7 +19,7 @@ class RegisterArithmeticInfo(HashablePydanticBaseModel):
19
19
  is_signed: bool = pydantic.Field(default=False)
20
20
  fraction_places: pydantic.NonNegativeInt = pydantic.Field(default=0)
21
21
  bypass_bounds_validation: bool = pydantic.Field(default=False)
22
- bounds: PydanticFloatTuple = pydantic.Field( # type: ignore[assignment]
22
+ bounds: PydanticFloatTuple = pydantic.Field(
23
23
  default=None,
24
24
  validate_default=True,
25
25
  )
@@ -42,7 +42,7 @@ class HardwareEfficientAnsatz(function_params.FunctionParams):
42
42
  "If none specified - use connectivity map from the model hardware settings. "
43
43
  "If none specified as well, all qubit pairs will be connected.",
44
44
  )
45
- num_qubits: pydantic.PositiveInt = pydantic.Field( # type: ignore[assignment]
45
+ num_qubits: pydantic.PositiveInt = pydantic.Field(
46
46
  default=None,
47
47
  description="Number of qubits in the ansatz.",
48
48
  validate_default=True,
@@ -144,7 +144,7 @@ class SynthesisQuantumFunctionCall(BaseModel):
144
144
  power: PydanticPowerType = pydantic.Field(
145
145
  default=1, description="Number of successive calls to the operation"
146
146
  )
147
- name: PydanticNonEmptyString = pydantic.Field( # type: ignore[assignment]
147
+ name: PydanticNonEmptyString = pydantic.Field(
148
148
  default=None,
149
149
  validate_default=True,
150
150
  description="The name of the function instance. "
@@ -32,7 +32,6 @@ class Provider(StrEnum):
32
32
  OQC = "OQC"
33
33
  INTEL = "Intel"
34
34
  AQT = "AQT"
35
- IQCC = "IQCC"
36
35
  CINECA = "CINECA"
37
36
 
38
37
  @property
@@ -4,7 +4,6 @@ EXECUTION_SESSIONS_PREFIX = EXECUTION_PREFIX + "/sessions"
4
4
  CONVERSION_PREFIX = "/conversion"
5
5
  PROVIDERS_PREFIX = "/providers"
6
6
 
7
- IQCC_PREFIX = PROVIDERS_PREFIX + "/iqcc"
8
7
  USER_BUDGETS_PREFIX = "/user_budgets"
9
8
 
10
9
 
@@ -70,17 +69,6 @@ QASM_TO_QMOD_FULL_PATH = CONVERSION_PREFIX + QASM_TO_QMOD_SUFFIX
70
69
 
71
70
  STATIC_SEMANTICS_VALIDATION_PATH = "/validate_static_semantics"
72
71
 
73
- IQCC_INIT_AUTH_SUFFIX = "/init_auth"
74
- IQCC_INIT_AUTH_FULL_PATH = IQCC_PREFIX + IQCC_INIT_AUTH_SUFFIX
75
- IQCC_PROBE_AUTH_SUFFIX = "/probe_auth"
76
- IQCC_PROBE_AUTH_FULL_PATH = IQCC_PREFIX + IQCC_PROBE_AUTH_SUFFIX
77
- IQCC_LIST_AUTH_SCOPES_SUFFIX = "/auth_scopes"
78
- IQCC_LIST_AUTH_SCOPES_FULL_PATH = IQCC_PREFIX + IQCC_LIST_AUTH_SCOPES_SUFFIX
79
- IQCC_LIST_AUTH_METHODS_SUFFIX = "/auth_methods"
80
- IQCC_LIST_AUTH_METHODS_FULL_PATH = IQCC_PREFIX + IQCC_LIST_AUTH_METHODS_SUFFIX
81
- IQCC_LIST_AUTH_TARGETS_SUFFIX = "/auth_targets"
82
- IQCC_LIST_AUTH_TARGETS_FULL_PATH = IQCC_PREFIX + IQCC_LIST_AUTH_TARGETS_SUFFIX
83
-
84
72
  USER_BUDGETS_SUFFIX = "/all"
85
73
  USER_BUDGETS_FULL_PATH = USER_BUDGETS_PREFIX + USER_BUDGETS_SUFFIX
86
74
  USER_BUDGET_SET_LIMIT_SUFFIX = "/set_limit"
@@ -172,20 +172,18 @@ class _InterpreterExpandable(QFunc):
172
172
  scope_func_decls: dict[str, QuantumFunctionDeclaration] = {}
173
173
  for name, evaluated in self._interpreter._builder.current_scope.items():
174
174
  value = evaluated.value
175
+ if (
176
+ isinstance(value, list)
177
+ and len(value) > 0
178
+ and isinstance(value[0], FunctionClosure)
179
+ ):
180
+ value = value[0]
175
181
  if isinstance(value, FunctionClosure):
176
182
  scope_func_decls[name] = QuantumFunctionDeclaration(
177
183
  name=name,
178
184
  positional_arg_declarations=value.positional_arg_declarations,
179
185
  )
180
186
  continue
181
- op_param = self._interpreter._builder.current_function.parameters_dict.get(
182
- name
183
- )
184
- if isinstance(op_param, QuantumOperandDeclaration):
185
- scope_func_decls[name] = QuantumFunctionDeclaration(
186
- name=name,
187
- positional_arg_declarations=op_param.positional_arg_declarations,
188
- )
189
187
  return (
190
188
  nameables_to_dict(self._interpreter._get_function_declarations())
191
189
  | scope_func_decls
@@ -3,7 +3,7 @@ from .amplitude_amplification import (
3
3
  exact_amplitude_amplification,
4
4
  )
5
5
  from .amplitude_estimation import *
6
- from .amplitude_loading import load_amplitudes
6
+ from .amplitude_loading import assign_amplitude_table
7
7
  from .discrete_sine_cosine_transform import *
8
8
  from .discrete_sine_cosine_transform import _qct_d_operator, _qct_pi_operator
9
9
  from .grover import *
@@ -12,7 +12,6 @@ from .hea import *
12
12
  from .lcu import *
13
13
  from .linear_pauli_rotation import *
14
14
  from .linear_pauli_rotation import _single_pauli
15
- from .lookup_table import get_lookup_table, span_lookup_table
16
15
  from .modular_exponentiation import *
17
16
  from .modular_exponentiation import _check_msb
18
17
  from .qaoa_penalty import *
@@ -93,13 +92,13 @@ __all__ = [
93
92
  "amplitude_amplification",
94
93
  "amplitude_estimation",
95
94
  "apply_to_all",
95
+ "assign_amplitude_table",
96
96
  "c_modular_multiply",
97
97
  "cc_modular_add",
98
98
  "encode_in_angle",
99
99
  "encode_on_bloch",
100
100
  "exact_amplitude_amplification",
101
101
  "full_hea",
102
- "get_lookup_table",
103
102
  "gqsp",
104
103
  "grover_diffuser",
105
104
  "grover_operator",
@@ -113,7 +112,6 @@ __all__ = [
113
112
  "lcu",
114
113
  "lcu_pauli",
115
114
  "linear_pauli_rotations",
116
- "load_amplitudes",
117
115
  "modular_add_qft_space",
118
116
  "modular_exp",
119
117
  "modular_increment",
@@ -129,6 +127,7 @@ __all__ = [
129
127
  "prepare_ghz_state",
130
128
  "prepare_int",
131
129
  "prepare_linear_amplitudes",
130
+ "prepare_select",
132
131
  "prepare_sparse_amplitudes",
133
132
  "prepare_uniform_interval_state",
134
133
  "prepare_uniform_trimmed_state",
@@ -154,7 +153,6 @@ __all__ = [
154
153
  "qsvt_lcu_step",
155
154
  "qsvt_step",
156
155
  "reflect_about_zero",
157
- "span_lookup_table",
158
156
  "suzuki_trotter",
159
157
  "swap_test",
160
158
  "switch",
@@ -6,7 +6,10 @@ from sympy import fwht
6
6
  from classiq.interface.exceptions import ClassiqValueError
7
7
 
8
8
  from classiq.qmod.builtins.functions import CX, RY
9
- from classiq.qmod.builtins.operations import bind, skip_control
9
+ from classiq.qmod.builtins.operations import (
10
+ bind,
11
+ skip_control,
12
+ )
10
13
  from classiq.qmod.qfunc import qfunc
11
14
  from classiq.qmod.qmod_variable import QArray, QBit, QNum
12
15
 
@@ -30,20 +33,36 @@ def _get_graycode_ctrls(size: int) -> list[int]:
30
33
 
31
34
 
32
35
  @qfunc
33
- def load_amplitudes(amplitudes: list[float], index: QNum, indicator: QBit) -> None:
36
+ def assign_amplitude_table(
37
+ amplitudes: list[float], index: QNum, indicator: QBit
38
+ ) -> None:
34
39
  """
35
40
  [Qmod Classiq-library function]
36
41
 
37
42
  Load a specified list of real amplitudes into a quantum variable using an extra indicator qubit:
38
- \\( |i\rangle|0\rangle \rightarrow a(i)\\,|i\rangle|1\rangle + \\sqrt{1 - a(i)^2}\\,|x\rangle|0\rangle \\).
43
+ \\( |i\\rangle|0\\rangle \\rightarrow a(i),\\ |i\\rangle|1\\rangle + \\sqrt{1 - a(i)^2},\\ |x\\rangle|0\\rangle \\).
39
44
  Here, \\(a(i)\\) is the i-th amplitude, determined by the QNum when the index is in state \\(i\\).
40
- A list extracted from a given classical function \\(f(x)\\), with indexing according to a given QNum, can be obtained via the utility SDK function `get_lookup_table`.
41
- This function expects the indicator qubit to be initialized to \\(|0\rangle\\).
45
+ A list extracted from a given classical function \\(f(x)\\), with indexing according to a given QNum, can be obtained via the utility SDK function `lookup_table`.
46
+ This function expects the indicator qubit to be initialized to \\(|0\\rangle\\).
42
47
 
43
48
  Args:
44
49
  amplitudes: Real values for the amplitudes
45
50
  index: The quantum variable used for amplitude indexing
46
51
  indicator: The quantum indicator qubit
52
+
53
+ Example:
54
+ ```python
55
+ from classiq import *
56
+
57
+
58
+ @qfunc
59
+ def main(x: Output[QNum[5, UNSIGNED, 5]], ind: Output[QBit]) -> None:
60
+ allocate(x)
61
+ hadamard_transform(x)
62
+ allocate(ind)
63
+
64
+ assign_amplitude_table(lookup_table(lambda x: x**2, x), x, ind)
65
+ ```
47
66
  """
48
67
  if len(amplitudes) != 2**index.size:
49
68
  raise ClassiqValueError(
@@ -9,6 +9,7 @@ from classiq.open_library.functions.utility_functions import switch
9
9
  from classiq.qmod.builtins.functions import IDENTITY, X, Y, Z, inplace_prepare_state
10
10
  from classiq.qmod.builtins.operations import (
11
11
  control,
12
+ if_,
12
13
  repeat,
13
14
  within_apply,
14
15
  )
@@ -16,7 +17,7 @@ from classiq.qmod.builtins.structs import IndexedPauli, SparsePauliOp
16
17
  from classiq.qmod.cparam import CArray
17
18
  from classiq.qmod.qfunc import qfunc
18
19
  from classiq.qmod.qmod_variable import QArray, QBit, QNum
19
- from classiq.qmod.quantum_callable import QCallableList
20
+ from classiq.qmod.quantum_callable import QCallable, QCallableList
20
21
 
21
22
 
22
23
  @qfunc
@@ -36,27 +37,23 @@ def apply_pauli_term(pauli_string: CArray[IndexedPauli], x: QArray[QBit]) -> Non
36
37
 
37
38
 
38
39
  @qfunc
39
- def lcu(
40
+ def prepare_select(
40
41
  coefficients: list[float],
41
- unitaries: QCallableList,
42
+ select: QCallable[QNum],
42
43
  block: QNum[Literal["max(ceiling(log(coefficients.len, 2)), 1)"]],
43
44
  ) -> None:
44
45
  """
45
46
  [Qmod Classiq-library function]
46
47
 
47
- Implements a general linear combination of unitaries (LCU) procedure. The algorithm prepares a superposition
48
- over the `unitaries` according to `magnitudes`, and then conditionally applies each unitary controlled by the `block`.
49
-
50
- The operation is of the form:
51
-
52
- $$\\sum_j \\alpha_j U_j$$
53
-
54
- where $U_j$ is a unitary operation applied to `data`.
48
+ Applies the 'Prepare-Select' scheme used for Linear Combination of Unitaries (LCU).
49
+ Compared to the `lcu` function, here the Select operator should be provided directly, allowing to take advantage of some structure for
50
+ the unitaries of the LCU.
51
+ The select operator is defined by: $\\mathrm{SELECT} = \\sum_{j=0}^{m-1} |j\rangle\\!\\langle j|_{block} \\otimes U_j$.
55
52
 
56
53
  Args:
57
54
  coefficients: L1-normalized array of $\\{ \\alpha_j \\}$ of the LCU coefficients.
58
- unitaries: A list of quantum callable functions to be applied conditionally.
59
- block: Quantum variable that holds the superposition index used for conditional application of each unitary.
55
+ select: A quantum callable to be applied between the state preparation and its inverse. Its input is the `block` variable, labeling the index of the unitaries in the LCU.
56
+ block: A Quantum variable that holds the index used as input for the 'select' operator.
60
57
  """
61
58
  coefficients = coefficients + [0] * (
62
59
  2**block.size - len(coefficients) # type:ignore[operator]
@@ -68,16 +65,48 @@ def lcu(
68
65
  within_apply(
69
66
  lambda: inplace_prepare_state(magnitudes, 0, block),
70
67
  lambda: [
71
- repeat(
72
- count=unitaries.len,
73
- iteration=lambda i: control(block == i, lambda: unitaries[i]()),
68
+ select(block),
69
+ if_(
70
+ not np.allclose(np.array(phases) % (2 * np.pi), 0),
71
+ lambda: apply_phase_table(phases, block),
74
72
  ),
75
- # TODO: replace to sparse constant phase
76
- apply_phase_table(phases, block),
77
73
  ],
78
74
  )
79
75
 
80
76
 
77
+ @qfunc
78
+ def lcu(
79
+ coefficients: list[float],
80
+ unitaries: QCallableList,
81
+ block: QNum[Literal["max(ceiling(log(coefficients.len, 2)), 1)"]],
82
+ ) -> None:
83
+ """
84
+ [Qmod Classiq-library function]
85
+
86
+ Implements a general linear combination of unitaries (LCU) procedure. The algorithm prepares a superposition
87
+ over the `unitaries` according to the given `coefficients`, and then conditionally applies each unitary controlled by the `block`.
88
+
89
+ The operation is of the form:
90
+
91
+ $$\\sum_j \\alpha_j U_j$$
92
+
93
+ where $U_j$ is a unitary operation applied to `data`.
94
+
95
+ Args:
96
+ coefficients: L1-normalized array of $\\{ \\alpha_j \\}$ of the LCU coefficients.
97
+ unitaries: A list of quantum callable functions to be applied conditionally.
98
+ block: Quantum variable that holds the superposition index used for conditional application of each unitary.
99
+ """
100
+ prepare_select(
101
+ coefficients,
102
+ lambda _block: repeat(
103
+ count=unitaries.len,
104
+ iteration=lambda i: control(_block == i, lambda: unitaries[i]()),
105
+ ),
106
+ block,
107
+ )
108
+
109
+
81
110
  @qfunc
82
111
  def lcu_pauli(
83
112
  operator: SparsePauliOp,
@@ -29,7 +29,7 @@ from classiq.qmod.builtins.operations import (
29
29
  within_apply,
30
30
  )
31
31
  from classiq.qmod.cparam import CArray, CInt, CReal
32
- from classiq.qmod.qfunc import qfunc
32
+ from classiq.qmod.qfunc import qfunc, qperm
33
33
  from classiq.qmod.qmod_variable import Output, QArray, QBit, QNum
34
34
  from classiq.qmod.symbolic import (
35
35
  acos,
@@ -248,7 +248,7 @@ def prepare_bell_state(
248
248
  CX(qpair[0], qpair[1])
249
249
 
250
250
 
251
- @qfunc
251
+ @qperm
252
252
  def inplace_prepare_int(value: CInt, target: QNum) -> None:
253
253
  """
254
254
  [Qmod Classiq-library function]
@@ -273,7 +273,7 @@ def inplace_prepare_int(value: CInt, target: QNum) -> None:
273
273
  target ^= value
274
274
 
275
275
 
276
- @qfunc
276
+ @qperm
277
277
  def prepare_int(
278
278
  value: CInt,
279
279
  out: Output[QNum[Literal["floor(log(value, 2)) + 1"]]],
@@ -324,7 +324,7 @@ def _classical_hadamard_transform(arr: list[float]) -> np.ndarray:
324
324
  return 1 / np.sqrt(len(arr)) * np.array(sympy.fwht(np.array(arr)))
325
325
 
326
326
 
327
- @qfunc
327
+ @qperm
328
328
  def apply_phase_table(
329
329
  phases: list[float],
330
330
  target: QArray[QBit, Literal["log(phases.len, 2)"]],
@@ -456,7 +456,7 @@ def prepare_dicke_state(k: int, qvar: QArray[QBit]) -> None:
456
456
  prepare_dicke_state_unary_input(k, qvar)
457
457
 
458
458
 
459
- @qfunc
459
+ @qperm
460
460
  def prepare_basis_state(state: list[bool], arr: Output[QArray]) -> None:
461
461
  """
462
462
  [Qmod Classiq-library function]
@@ -515,7 +515,7 @@ def prepare_linear_amplitudes(x: QArray) -> None:
515
515
  hadamard_transform(x)
516
516
 
517
517
 
518
- @qfunc
518
+ @qperm
519
519
  def swap_states(a: int, b: int, target: QArray) -> None:
520
520
  """
521
521
  Swap 2 computational basis states a and b, leave all other states untouched.
@@ -538,7 +538,7 @@ def swap_states(a: int, b: int, target: QArray) -> None:
538
538
  if anchor < target.len - 1:
539
539
  target_without_anchor.append(target[anchor + 1 : target.len])
540
540
 
541
- @qfunc
541
+ @qperm
542
542
  def _xor_if_equal(n: CInt, ctrl: QNum, target: QBit) -> None:
543
543
  target ^= ctrl == n
544
544
 
@@ -51,6 +51,7 @@ CORE_LIB_DECLS = [
51
51
  U,
52
52
  CCX,
53
53
  free,
54
+ drop,
54
55
  randomized_benchmarking,
55
56
  inplace_prepare_state,
56
57
  inplace_prepare_state_approx,
@@ -107,6 +108,7 @@ __all__ = [ # noqa: RUF022
107
108
  "apply",
108
109
  "exponentiation_with_depth_constraint",
109
110
  "free",
111
+ "drop",
110
112
  "inplace_prepare_amplitudes",
111
113
  "inplace_prepare_amplitudes_approx",
112
114
  "inplace_prepare_state",
@@ -21,6 +21,27 @@ def free(in_: Input[QArray[QBit]]) -> None:
21
21
  pass
22
22
 
23
23
 
24
+ @qperm(external=True)
25
+ def drop(in_: Input[QArray[QBit]]) -> None:
26
+ """
27
+ [Qmod core-library function]
28
+
29
+ Discards the qubits allocated to a quantum variable which may be in any state,
30
+ preventing their further use.
31
+
32
+ Args:
33
+ in_: The quantum variable that will be dropped. Must be initialized before.
34
+
35
+ Note:
36
+ This operation can be used to bypass the restrictions on a local variable
37
+ that enable its uncomputation. The implication is that its qubits are left
38
+ dirty, possibly entangled with functional qubits, and never subsequently reused.
39
+
40
+ Functions which use `drop` cannot be inverted or used inside a _within_ block.
41
+ """
42
+ pass
43
+
44
+
24
45
  @qfunc(external=True)
25
46
  def prepare_state(
26
47
  probabilities: CArray[CReal],
@@ -2,6 +2,7 @@ import inspect
2
2
  import sys
3
3
  from collections.abc import Callable, Mapping
4
4
  from functools import wraps
5
+ from itertools import product
5
6
  from types import FrameType
6
7
  from typing import (
7
8
  Any,
@@ -48,6 +49,7 @@ from classiq.interface.model.skip_control import SkipControl
48
49
  from classiq.interface.model.statement_block import StatementBlock
49
50
  from classiq.interface.model.within_apply_operation import WithinApply
50
51
 
52
+ from classiq.qmod.builtins.functions import H, S
51
53
  from classiq.qmod.generative import is_generative_mode
52
54
  from classiq.qmod.qmod_constant import QConstant
53
55
  from classiq.qmod.qmod_variable import Input, Output, QArray, QBit, QNum, QScalar, QVar
@@ -55,15 +57,21 @@ from classiq.qmod.quantum_callable import QCallable
55
57
  from classiq.qmod.quantum_expandable import prepare_arg
56
58
  from classiq.qmod.semantics.error_manager import ErrorManager
57
59
  from classiq.qmod.symbolic_expr import SymbolicExpr
58
- from classiq.qmod.utilities import Statements, get_source_ref, suppress_return_value
60
+ from classiq.qmod.utilities import (
61
+ RealFunction,
62
+ Statements,
63
+ get_source_ref,
64
+ qnum_values,
65
+ suppress_return_value,
66
+ )
59
67
 
60
68
  _MISSING_VALUE: Final[int] = -1
61
69
 
62
- Params = ParamSpec("Params")
63
- RetType = TypeVar("RetType")
70
+ _Params = ParamSpec("_Params")
71
+ _RetType = TypeVar("_RetType")
64
72
 
65
73
 
66
- def qmod_statement(func: Callable[Params, RetType]) -> Callable[Params, RetType]:
74
+ def qmod_statement(func: Callable[_Params, _RetType]) -> Callable[_Params, _RetType]:
67
75
  @wraps(func)
68
76
  def wrapper(*args: Any, **kwargs: Any) -> Any:
69
77
  source_ref = get_source_ref(sys._getframe(1))
@@ -771,10 +779,65 @@ def _operand_to_body(
771
779
  raise ValueError(f"Unexpected operand type: {type(to_operand)}")
772
780
 
773
781
 
782
+ def assign_amplitude_poly_sin(indicator: QBit, expr: Callable, *vars: QNum) -> None:
783
+ """
784
+ Encodes the value of the sine/cosine of a polynomial into the amplitude of the
785
+ respective computational basis state:
786
+ \\( |x_1, x_2, \\ldots, x_n\\rangle|0\\rangle \\rightarrow cos(poly(x_1, x_2, \\ldots, x_n)) + sin(poly(x_1, x_2, \\ldots, x_n))|x_1, x_2, \\ldots, x_n\\rangle|1\\rangle \\)
787
+
788
+ Args:
789
+ indicator: The quantum indicator qubit
790
+ expr: A polynomial function over `len(vars)` QNums
791
+ *vars: Quantum numerics
792
+ """
793
+ phase(-expr(*vars))
794
+ within_apply(
795
+ lambda: H(indicator),
796
+ lambda: control(indicator, lambda: phase(2 * expr(*vars))),
797
+ )
798
+ S(indicator)
799
+
800
+
801
+ def _get_qnum_values(num: QNum) -> list[float]:
802
+ size = num.size
803
+ is_signed = num.is_signed
804
+ fraction_digits = num.fraction_digits
805
+ if (
806
+ not isinstance(size, int)
807
+ or not isinstance(is_signed, bool)
808
+ or not isinstance(fraction_digits, int)
809
+ ):
810
+ raise ClassiqValueError(f"QNum argument {str(num)!r} has symbolic attributes")
811
+
812
+ return qnum_values(size, is_signed, fraction_digits)
813
+
814
+
815
+ def lookup_table(func: RealFunction, targets: QNum | list[QNum]) -> list[float]:
816
+ """
817
+ Reduces a classical function into a lookup table over all the possible values
818
+ of the quantum numbers.
819
+
820
+ Args:
821
+ func: A Python function
822
+ targets: One or more initialized quantum numbers
823
+
824
+ Returns:
825
+ The function's lookup table
826
+
827
+ Notes:
828
+ The QNum arguments must have generative attributes
829
+ """
830
+ if not isinstance(targets, list):
831
+ targets = [targets]
832
+ target_vals = [_get_qnum_values(target) for target in targets]
833
+ return [func(*vals[::-1]) for vals in product(*target_vals[::-1])]
834
+
835
+
774
836
  __all__ = [
775
837
  "allocate",
776
838
  "assign",
777
839
  "assign_amplitude",
840
+ "assign_amplitude_poly_sin",
778
841
  "bind",
779
842
  "block",
780
843
  "control",
@@ -782,6 +845,7 @@ __all__ = [
782
845
  "inplace_add",
783
846
  "inplace_xor",
784
847
  "invert",
848
+ "lookup_table",
785
849
  "phase",
786
850
  "power",
787
851
  "repeat",
classiq/qmod/utilities.py CHANGED
@@ -3,7 +3,6 @@ import inspect
3
3
  import itertools
4
4
  import keyword
5
5
  import sys
6
- from collections import Counter
7
6
  from collections.abc import Callable, Iterable
8
7
  from enum import Enum as PythonEnum
9
8
  from types import FrameType
@@ -195,13 +194,4 @@ def qnum_attributes(max_size: int) -> list[tuple[int, bool, int]]:
195
194
  ]
196
195
 
197
196
 
198
- _VAR_NAME_COUNTER: Counter[str] = Counter()
199
-
200
-
201
- def get_temp_var_name(var_name: str = "temp") -> str:
202
- n = _VAR_NAME_COUNTER[var_name]
203
- _VAR_NAME_COUNTER[var_name] += 1
204
- return f"{var_name}_{n}"
205
-
206
-
207
197
  RealFunction = Callable[Params, float]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: classiq
3
- Version: 0.95.0
3
+ Version: 0.96.0
4
4
  Summary: Classiq's Python SDK for quantum computing
5
5
  Keywords: quantum computing,quantum circuits,quantum algorithms,QAD,QDL
6
6
  Author: Classiq Technologies
@@ -3,7 +3,7 @@ classiq/_analyzer_extras/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
3
3
  classiq/_analyzer_extras/_ipywidgets_async_extension.py,sha256=cxdrzSOEQ8_2rLXcScDnhZoZAHqPmIhY-DhBPWLcNII,2200
4
4
  classiq/_analyzer_extras/interactive_hardware.py,sha256=9ZnQX_MZCF21s2skWXUjm4mYCBCeytJtxcnyTE1XU4g,3438
5
5
  classiq/_internals/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- classiq/_internals/api_wrapper.py,sha256=6GL6Zl9b66mmzvFBrsWp-uVZ3mAkofadxZN7hkRDBHw,20039
6
+ classiq/_internals/api_wrapper.py,sha256=erBYv-ppjNzTB9DDBIx8zPUwqgvbnUGO8t88C1Jd4-c,17377
7
7
  classiq/_internals/async_utils.py,sha256=mcBzGZQYG3EdI7NkBwAO_MGsbF4RFMEUjN1Yoz1CiKE,3327
8
8
  classiq/_internals/authentication/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  classiq/_internals/authentication/auth0.py,sha256=6zkfNJypASlMAKimRLYDZAZEUI5KaM4lNWyai3ufXX4,4628
@@ -68,7 +68,7 @@ classiq/applications/combinatorial_optimization/examples/__init__.py,sha256=A0-j
68
68
  classiq/applications/hamiltonian/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
69
  classiq/applications/hamiltonian/pauli_decomposition.py,sha256=Jdc1eKYb-rwacVbGkoifyGq1qHmfk-jLsFTr8MtwvR8,5255
70
70
  classiq/applications/iqae/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
- classiq/applications/iqae/iqae.py,sha256=LV3tCuVFLpqKeL1ItyeigXmxZ4OY9KoUGPMHD6u8ui8,7315
71
+ classiq/applications/iqae/iqae.py,sha256=9tQLFVP2u6J8GdZCm5qpUk3pCtfkUO-T99b2TRv6dS4,7465
72
72
  classiq/applications/qnn/__init__.py,sha256=_DQQo81JQ-LR0VY2AooqpRMj9ej9ubZfVl6ESoBPoqE,433
73
73
  classiq/applications/qnn/circuit_utils.py,sha256=QWRYnHhDgbFuEQIUYhFfShNFGgbsIB-ZcLkubztLsZQ,4345
74
74
  classiq/applications/qnn/datasets/__init__.py,sha256=HRQHIXGZOYqa4tIwUR3o31GiWVCtJOGW2xGV-gKAqUo,812
@@ -80,9 +80,9 @@ classiq/applications/qnn/datasets/dataset_xor.py,sha256=fN73XTbjtxQCm5KW0A4KAD2w
80
80
  classiq/applications/qnn/datasets/datasets_utils.py,sha256=LgerS3HPe82gVTMg6YLWFmKt5adZCHxxr7lPYNCqJpI,1363
81
81
  classiq/applications/qnn/gradients/__init__.py,sha256=md5sLINVaPeZUHJUe1ZtIcqLN_V_I2RKfBe3mO3zZs4,102
82
82
  classiq/applications/qnn/gradients/quantum_gradient.py,sha256=FtyrLbpN4lqOlrj86LFtUGvTUZs_Jajblzrau5a0-CE,1169
83
- classiq/applications/qnn/gradients/simple_quantum_gradient.py,sha256=QT1wh9SpSFtRH0-OxRsWxCKHlDjLumNwyVAcmR9r78w,5020
84
- classiq/applications/qnn/qlayer.py,sha256=X9cKYggtdlB75uFBwcdJSU-pKcp2EUVbJwTfaAWZDCQ,9026
85
- classiq/applications/qnn/torch_utils.py,sha256=y33WNDwKYQcjouPoESWVrEUnKmcOoH_mv10wW7iquGQ,4393
83
+ classiq/applications/qnn/gradients/simple_quantum_gradient.py,sha256=5TGzxvWPtqpIKmZAJROXBYio1-1wNLhW4_eraTDKbII,4959
84
+ classiq/applications/qnn/qlayer.py,sha256=HZLstEnVhK8ve5LX2O2ssIaUZEG0j8GJg4jMPqdPrHc,9000
85
+ classiq/applications/qnn/torch_utils.py,sha256=eLxHZKqT7aamUkH8veOAFblBxQKe_0kM0TxMGejJ7DU,4439
86
86
  classiq/applications/qnn/types.py,sha256=ng51NBh-dXguC6yPGvDetww-O_75OAkcE8FFwWOCQ_Y,862
87
87
  classiq/applications/qsp/__init__.py,sha256=8Zr-aJ3SQMD7f4YaUikbKB6gDD0gOhPD_ZO9poaEtqY,169
88
88
  classiq/applications/qsp/qsp.py,sha256=7H2_oSZzt1C4dE8SKiRiH6h9P7sj2DZwi6jxpcGX4-U,13579
@@ -122,16 +122,15 @@ classiq/evaluators/qmod_type_inference/classical_type_inference.py,sha256=rPxvqR
122
122
  classiq/evaluators/qmod_type_inference/quantum_type_inference.py,sha256=3gMh44K7BiTY8W78AcytUPR-1n2xjiUyQ58JcgzKwdM,12609
123
123
  classiq/evaluators/quantum_type_utils.py,sha256=oTouwtHBM_xugCaa4kqd6L7YujRDMRxxqirtnzhzrJk,2792
124
124
  classiq/evaluators/type_type_match.py,sha256=XOI6oJiHkLdcx-RX9yyE2ARXFLbaWYW1Tq2YSlVAOJc,3269
125
- classiq/execution/__init__.py,sha256=tjAsQFbm8_9yj6cHXK_E0Eajs1F7REjcKstddpsvkDI,1524
125
+ classiq/execution/__init__.py,sha256=vv6Gb5j8mmYw9czw4r2rX6OfZWdVMcMVXY2gPDCHsro,1391
126
126
  classiq/execution/all_hardware_devices.py,sha256=KpLefEISE03FDdgFPGggXeG7NAxBW4090gN4272Dl-E,368
127
127
  classiq/execution/execution_session.py,sha256=W1GzbdIyhndEmSqk_DQQLDFoTUTs82y418_qaOgsGRc,25570
128
- classiq/execution/iqcc.py,sha256=fG92ZwgZl_tAih0vndZpIKksVCQuLTk5pJy2X4LRkxA,4298
129
128
  classiq/execution/jobs.py,sha256=fw52prvnA9gLb10flBM2cCP7a5FN5f2xHc0i6knpJ1I,12059
130
129
  classiq/execution/qnn.py,sha256=zA-I-wvVkjyoigGvcG2W2KVbyKF5Z4X6hIQ3IPI-1xA,2436
131
- classiq/execution/user_budgets.py,sha256=k80pj6-rhkKi92dwrwnAyQbfqc5z9sAaShtArv8OyyE,4029
130
+ classiq/execution/user_budgets.py,sha256=fZvHfwXEkcygoMT8N0XwauHkxCmZX93d1OVL0ZJ8ysU,3996
132
131
  classiq/executor.py,sha256=5j4bLYP4acxKTenFYnSEGf9tBDCjdpBiaBp86l78U_o,2278
133
132
  classiq/interface/__init__.py,sha256=cg7hD_XVu1_jJ1fgwmT0rMIoZHopNVeB8xtlmMx-E_A,83
134
- classiq/interface/_version.py,sha256=Hf8uksvpcfwUi31VXM5_c5n06QLj9nyULCr8wkWmbmU,197
133
+ classiq/interface/_version.py,sha256=2BCf7M-1i8AXPhX0CDXXhI7qzz7Bbqqh8if5GpiYBcs,197
135
134
  classiq/interface/analyzer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
136
135
  classiq/interface/analyzer/analysis_params.py,sha256=34pFb5X5rPeZOe3TNxBq6oT5YJKcJ9ORyZ_7KRP-alA,2991
137
136
  classiq/interface/analyzer/cytoscape_graph.py,sha256=Ky2tSKdnCnA26896DPy64HSVudLnE3FzdGDUUf0nkI0,2345
@@ -142,11 +141,11 @@ classiq/interface/applications/iqae/generic_iqae.py,sha256=IdbdB3vJ6kUe2exSaHuSf
142
141
  classiq/interface/applications/iqae/iqae_result.py,sha256=S13A_mQKRTBaqO2NKJEJlgLl06I2Fz_C6F_4Xlp4fzQ,1770
143
142
  classiq/interface/ast_node.py,sha256=t1UtCIRn8vvjSlnw_ak4cbCHReo2X6AYBRn_uvKwmz4,925
144
143
  classiq/interface/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
145
- classiq/interface/backend/backend_preferences.py,sha256=1zRN1Lltt-9gS5pJKSPOBChJErqaWvjn5tMBOx8PNFo,20571
144
+ classiq/interface/backend/backend_preferences.py,sha256=1aOBYAN9bRbSJ6IBoRYY52W3Lu7Z2wCUm2WEV-snX14,19563
146
145
  classiq/interface/backend/ionq/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
147
146
  classiq/interface/backend/ionq/ionq_quantum_program.py,sha256=CbbM_SnnS3k0U6iznqRLSfjHSdbuAuXLcxvSDP6PcVY,1213
148
147
  classiq/interface/backend/pydantic_backend.py,sha256=XfG1u_8ZEq382P5LTHYEhjkDH7UZYY_1sl1O-RImSmk,1610
149
- classiq/interface/backend/quantum_backend_providers.py,sha256=VSSGvmrRKFCmatylkq-tzwCR5MeUEtSvImr6IDuinFI,7598
148
+ classiq/interface/backend/quantum_backend_providers.py,sha256=dY8rXM5N_WruDNkVMTZSiAbfSBB6GwdkhLYxc0UgQrE,7540
150
149
  classiq/interface/chemistry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
151
150
  classiq/interface/chemistry/ansatz_library.py,sha256=9HbqdeAgJ0xd3xsPZwfLtS1KsFggSVucLI3E0IknkL0,322
152
151
  classiq/interface/chemistry/operator.py,sha256=PDm5q7jBVVT7yJYaWKdxLFuDPxQ8n4_cZXEiJd6SX1I,10239
@@ -179,7 +178,6 @@ classiq/interface/debug_info/debug_info.py,sha256=XyvpcH23tHoQ2uue3dGyV-zasjRNv7
179
178
  classiq/interface/enum_utils.py,sha256=QxkxLGgON8vdSzLZzHFlPEBJoGOqoIwpESEfLfRqN0w,312
180
179
  classiq/interface/exceptions.py,sha256=mK2fJtonRmcQ-zThyey5MhEGA1O0mkBpTGqz3z0OxTU,4390
181
180
  classiq/interface/execution/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
182
- classiq/interface/execution/iqcc.py,sha256=__KIPbVdD3ow2u1rq8OKJE5V2wm3-hBoVPMIkwfY5v0,806
183
181
  classiq/interface/execution/primitives.py,sha256=Zqu5j2s8E7a0B6LyIRX4eEgq3hHqAjA5ptWg0gVLy5Q,1476
184
182
  classiq/interface/executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
185
183
  classiq/interface/executor/constants.py,sha256=DtSx-1HArWE0hHjOZHY9WJBevt3hP7M8SrYO3eM3dgo,31
@@ -220,7 +218,7 @@ classiq/interface/generator/arith/extremum_operations.py,sha256=SVUoZFkNZCfI2wLC
220
218
  classiq/interface/generator/arith/logical_ops.py,sha256=0BfMHlcQIWpmxDU0szlYa51ewnqUgVp6qak5jjwtzco,2647
221
219
  classiq/interface/generator/arith/machine_precision.py,sha256=uh1qwWL056mSdcANKddz5G720plWvAxlXIp7a32Tdtg,68
222
220
  classiq/interface/generator/arith/number_utils.py,sha256=mh5pLrCA9sICklL8G6WC1kTjgGPh7sqvmCa8Q-V82FQ,4537
223
- classiq/interface/generator/arith/register_user_input.py,sha256=lpnTDXs1JE8UiIlVokEe9eBI86BXlpgQ-M7-bcDF1es,5160
221
+ classiq/interface/generator/arith/register_user_input.py,sha256=nAPLslctQYYS4_ASDRYulY2PehtIi9Ih1_bi3JQyWF8,5132
224
222
  classiq/interface/generator/arith/unary_ops.py,sha256=mj-9dHtaXeFDreslFmPugCTKxlUsZ5ToqBpy0YbahBY,5369
225
223
  classiq/interface/generator/arith/uncomputation_methods.py,sha256=AbBAgOYTEJ2ufDyJLDew7RKCZPMS8vb7K0Ld6adInXk,136
226
224
  classiq/interface/generator/builtin_api_builder.py,sha256=xDn-gRte0n8fNB03hwPjQE8MZhfDJyNrJrmymtahohg,418
@@ -276,7 +274,7 @@ classiq/interface/generator/hamiltonian_evolution/qdrift.py,sha256=IFF015sz0gaqX
276
274
  classiq/interface/generator/hamiltonian_evolution/suzuki_trotter.py,sha256=JCYnbixIv5tZzDU4CTPW0m44Il7-NeAow4MgjAw0-K4,1957
277
275
  classiq/interface/generator/hardware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
278
276
  classiq/interface/generator/hardware/hardware_data.py,sha256=P9Y1I5Oobd5I8Ihrfd3kytWf-a7Ru8U09eiCcY3HpQE,8643
279
- classiq/interface/generator/hardware_efficient_ansatz.py,sha256=a_NXOtWMl314OcK9r17ccfC44GeaNVEHxSrD375GEZo,5080
277
+ classiq/interface/generator/hardware_efficient_ansatz.py,sha256=nLY0lpVZEdbywbR-RsV_BurXiQ1mayETkYwtRhmm4Ic,5052
280
278
  classiq/interface/generator/identity.py,sha256=XDiA47DP7JirPaUMUqIQQgyahjWw7N3LGjF0LnZ5V_0,1263
281
279
  classiq/interface/generator/mcmt_method.py,sha256=wKS3ivhErKhxmes6Mb1sUwaJgcg48wVCk63oP2za1vQ,232
282
280
  classiq/interface/generator/mcu.py,sha256=Xkyi6VaStSoxmsSqaUrMgQJVcxXGq3dHPP4WbxPkUxA,3231
@@ -294,7 +292,7 @@ classiq/interface/generator/partitioned_register.py,sha256=wFWbncJ7lAEhbrT0WEm_x
294
292
  classiq/interface/generator/preferences/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
295
293
  classiq/interface/generator/preferences/optimization.py,sha256=7iEWWNFSxqi4XMb4JmOcfeN8KqvNMEcSjQw8P8yrdOA,1066
296
294
  classiq/interface/generator/preferences/qasm_to_qmod_params.py,sha256=K1MFAUK_uhRfedjfm_bV-ApZsqmJWzeRD37-hd3yaTg,417
297
- classiq/interface/generator/quantum_function_call.py,sha256=Mo7LZjk21W_4WJ0Oiz2MSyBcWcBFZd_0OgY00yUnvvY,24155
295
+ classiq/interface/generator/quantum_function_call.py,sha256=_EBr9TR12XwVTd0FVWrbjZrAK963xu6yCcwgNBKQJTg,24127
298
296
  classiq/interface/generator/quantum_program.py,sha256=CQMe12Ns473EXuZRk6gXP4lyP59xj6AxGzAGzFmTEXY,7241
299
297
  classiq/interface/generator/randomized_benchmarking.py,sha256=D6KI_1fMF5oBydaal2WLmTSit6xSMtz0yDAIZMMO89Q,635
300
298
  classiq/interface/generator/range_types.py,sha256=bmm2NjRxaCoVJT5WMLjPDCrjGCbjzgjodlCDUNiGA68,2028
@@ -336,7 +334,7 @@ classiq/interface/generator/validations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5J
336
334
  classiq/interface/generator/validations/flow_graph.py,sha256=wEdGgHqQjDOdwji4MfMgi4Ig4Lme003wCEgkxnbHU8g,6187
337
335
  classiq/interface/generator/validations/validator_functions.py,sha256=ODvbPavjxx2skGdNdgT5d9ZsZjsp9XkHBUPK7oZBElY,1418
338
336
  classiq/interface/generator/visitor.py,sha256=009l7QuESO4eFxwppI-cz1MJlFRsCCIPXW9eDaPeCVY,3445
339
- classiq/interface/hardware.py,sha256=yh9DTGkgVKu1AdZIY-yatemluVkzC_esc-o6ijZyLeI,2422
337
+ classiq/interface/hardware.py,sha256=_f8BGX0GI4qCbECNlXJFkFg1DxmVDtt3CK0rLJLOyt4,2404
340
338
  classiq/interface/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
341
339
  classiq/interface/helpers/classproperty.py,sha256=bCUTBCcZSZ7GRlfhyEuTlsAJclgMOCyjFtjJxmBYzj8,266
342
340
  classiq/interface/helpers/custom_encoders.py,sha256=X3QEHAJ9_4yB7B6bk-y0CEmtFPwnrjnENqQ8PlgGYN4,128
@@ -396,7 +394,7 @@ classiq/interface/pyomo_extension/pyomo_sympy_bimap.py,sha256=ED3DFL7hKnrrEoV4V3
396
394
  classiq/interface/pyomo_extension/set_pprint.py,sha256=jlyYUHfQXwyzPQIzstnTeIK6T62BcSPn3eJdD1Qjy7E,344
397
395
  classiq/interface/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
398
396
  classiq/interface/server/global_versions.py,sha256=EyUtBCoGHjgS4jybiHI8wOZq3WOqvta2WYZc5MARkoA,274
399
- classiq/interface/server/routes.py,sha256=d1sNJE9WoBUykRJsGCgTWP3az8j__0C0LvXrpyLu36w,3804
397
+ classiq/interface/server/routes.py,sha256=Of0wZl_RBJwW_8t2DZiZBJkZwRqY6BKxoW7eCmGHgsA,3181
400
398
  classiq/interface/source_reference.py,sha256=A44UHfPyUeOog8K4G1ftNLiU8WyYvUpkeVyA1PBLhWI,1844
401
399
  classiq/model_expansions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
402
400
  classiq/model_expansions/arithmetic.py,sha256=N_y3KSS3UgVTVXAPfCWbWJ93o80b1tXD99dh90xbQqg,4949
@@ -407,7 +405,7 @@ classiq/model_expansions/capturing/mangling_utils.py,sha256=Vqk6T4s9e9km54oD8P_g
407
405
  classiq/model_expansions/closure.py,sha256=kqVeK2H8c42DIHji2dcBGCTEMF3VjV66FlnL7mPSWnk,4123
408
406
  classiq/model_expansions/debug_flag.py,sha256=JWzl9FFq2CLcvTg_sh-K8Dp_xXvewsTuFKhPjTCrsrs,107
409
407
  classiq/model_expansions/function_builder.py,sha256=DNj7NUtM3vYL-eCYWTGWhqgH89hbms6WkQTaZDze5UI,9090
410
- classiq/model_expansions/generative_functions.py,sha256=KB2_r_P7q35ncCeGTJiYAm_nEcJf6brQkaqPsuBpgIo,8387
408
+ classiq/model_expansions/generative_functions.py,sha256=JUqDl6aSphEM5LdOjxuf0LLVcxOcfB4GycP65zbq6NI,8194
411
409
  classiq/model_expansions/interpreters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
412
410
  classiq/model_expansions/interpreters/base_interpreter.py,sha256=4xT7uPNKoJIkSk3mOtWMLKKg_0P8Vb5ORdxi9sAiUZU,14626
413
411
  classiq/model_expansions/interpreters/frontend_generative_interpreter.py,sha256=YKoZsv9rB1KZBQqKjpVh73CIla6QrsEB1dpa-Hlnrx4,3836
@@ -445,22 +443,21 @@ classiq/model_expansions/visitors/symbolic_param_inference.py,sha256=goLFicRmxFu
445
443
  classiq/model_expansions/visitors/uncomputation_signature_inference.py,sha256=AYHoSNd1nWl2mFdLAceqkggqSdbu4SpYVtjgOioQAPg,12911
446
444
  classiq/model_expansions/visitors/variable_references.py,sha256=z6_vcra7sTak5mEhONXs77p7xO34Y8ZeeYCMuSfAui8,6587
447
445
  classiq/open_library/__init__.py,sha256=bmg_qqXCXo85hcU7_QCce-qYGrpAVSFNwTKCClsclrg,114
448
- classiq/open_library/functions/__init__.py,sha256=RWZqK-VhLGVp_5HPSMd3wqfjpIYc3r2n8vz2HTxj1Jg,3924
446
+ classiq/open_library/functions/__init__.py,sha256=ISiQ8342FRuHULa6j5qAyQ4h2inxQcnbwl2eUUx1cDQ,3849
449
447
  classiq/open_library/functions/amplitude_amplification.py,sha256=WH2dqYbmmWHZX7beu7-EipnC6Gzn4En4D2gmB2sXvZI,3997
450
448
  classiq/open_library/functions/amplitude_estimation.py,sha256=iCkca5SQN_HQoJWk1_tLT56fHT72hu5QIt2pxSZQRko,1766
451
- classiq/open_library/functions/amplitude_loading.py,sha256=E21BMj_82e8EmR8uOC9zB1zcuQIFbSZcAcWvnI14MpE,2429
449
+ classiq/open_library/functions/amplitude_loading.py,sha256=aJoAjqil2eKn_9X-tLYvoi1LfKyPE1rdTuW1o3c2Fdo,2791
452
450
  classiq/open_library/functions/discrete_sine_cosine_transform.py,sha256=F-yD4paGBFueWRK_Tr36aIxxBuzvXte1JtvizxKet68,4634
453
451
  classiq/open_library/functions/grover.py,sha256=e5LlbHj-nfR_iAhmRei4BuFJOjDFJrb2rBwzdwB-xfg,4688
454
452
  classiq/open_library/functions/hea.py,sha256=Nc9pj-4mGLZVQQKCaVRgrcPd4eViuz3Ji5ZeYzaCozg,4889
455
- classiq/open_library/functions/lcu.py,sha256=wzkavQZfIl1IsKPUou-sN6flb23YjT_4uR_khqG25Vk,4105
453
+ classiq/open_library/functions/lcu.py,sha256=MZcxrxWVSngyw888RpH4Yum9eaQC0vwAKwq5K5_kygU,5268
456
454
  classiq/open_library/functions/linear_pauli_rotation.py,sha256=rjQTglfF1MVk1-Wmk6QWhUPOC7bOPRtBTttz7EjCfcc,2679
457
- classiq/open_library/functions/lookup_table.py,sha256=LUUn5ur1HqmvG-YhO8mUdVsTVUcN5BoY1da5xwbXTHk,2186
458
455
  classiq/open_library/functions/modular_exponentiation.py,sha256=Elpxo5K88SKz55ujyThLLfDuS5Jei59bgyiL_yKQo4A,8552
459
456
  classiq/open_library/functions/qaoa_penalty.py,sha256=bnsBlnLwmjAPB4CZ9m1SVPP-eGTnAKXXJwNB-_RuS_Y,4248
460
457
  classiq/open_library/functions/qft_functions.py,sha256=7pdPBq48QvyQkxHrF3rEKTf0J50qUu_2bN17lfSc7I0,1382
461
458
  classiq/open_library/functions/qpe.py,sha256=e7MBpOthBn73BdqhWpNGT0lkd6Jw3ZG7tE6n--IM0jc,2140
462
459
  classiq/open_library/functions/qsvt.py,sha256=-W9QkRWw07nS5_oN1Yaq7z7LjrwFmtf1HhVAV69Lqy4,16481
463
- classiq/open_library/functions/state_preparation.py,sha256=73rLbRwI86Kiz2EUICd-VodqPvAwUiWqEIKMLZzwALs,22764
460
+ classiq/open_library/functions/state_preparation.py,sha256=h4Vn4CXoCsivGNPpDWefatWHOvcXGxCC7cwEwCuGqRo,22771
464
461
  classiq/open_library/functions/swap_test.py,sha256=hAjiJjZGeJP2qzEkVYmBVlEK44VcNibWZ-KqJwPEcFY,1048
465
462
  classiq/open_library/functions/utility_functions.py,sha256=-0r7dUdh1KJa93QORRlmPFM8ZDObyreB5Q5Jx4d9RBM,2539
466
463
  classiq/open_library/functions/variational.py,sha256=KYoqPKYRjgUXk_10RvogV0YiCG5kl7GZBHBJeeX82II,1715
@@ -471,8 +468,8 @@ classiq/qmod/builtins/classical_execution_primitives.py,sha256=b4gN4CZGrwOXTMPUC
471
468
  classiq/qmod/builtins/classical_functions.py,sha256=uTmHUfYbdi0HMc4DLGC5mMxTVpYu-wFZDD1CmZljx9M,455
472
469
  classiq/qmod/builtins/constants.py,sha256=FURSVt0dlIAw_xkGMyj89z4eub7vUdvUrPzaLTGUQxk,222
473
470
  classiq/qmod/builtins/enums.py,sha256=sfVZXLPZA0k98-Krm6PHRP6bC0mknXiL12l1_9Vp0IA,2399
474
- classiq/qmod/builtins/functions/__init__.py,sha256=kHR4_LlGV8_vAp9JrcPx0vzl8K5osUV2JT442WzmTRo,2607
475
- classiq/qmod/builtins/functions/allocation.py,sha256=Q6vazUA7ouKyZcoZ4F209wMuc4WymCBTuYdFWadSFvQ,6721
471
+ classiq/qmod/builtins/functions/__init__.py,sha256=vKtDGwA7YC-Kz9DEP8IKqPViH8HH9IOxa9UNgPGaXiw,2633
472
+ classiq/qmod/builtins/functions/allocation.py,sha256=sPDC4yKa1HyNlJvUXyqPd0GEemhHd4cpGMWAd-v9osc,7413
476
473
  classiq/qmod/builtins/functions/arithmetic.py,sha256=ikR4cDEYn0xyg1QS_F_ZFwtMLPezSN9XGuyc_C0pXnc,1846
477
474
  classiq/qmod/builtins/functions/benchmarking.py,sha256=TYY1VRd5DHl-mKTKeW5wF1txZgFsb3yPXM_rdgoLWCo,250
478
475
  classiq/qmod/builtins/functions/exponentiation.py,sha256=1y3l6ko8dP0f7SicjLzRkNYTKNudBr-K_lDVvaXzJ8s,8715
@@ -480,7 +477,7 @@ classiq/qmod/builtins/functions/mcx.py,sha256=MLx60OURHmqN2z0FKJKN_JiCvSgzk0m7ms
480
477
  classiq/qmod/builtins/functions/mid_circuit_measurement.py,sha256=UYtVbsl1vZSBU7x64-3s5EgbZ28fbvGx86j30rsts3w,415
481
478
  classiq/qmod/builtins/functions/operators.py,sha256=3IWFjUFhljY5CEe2ZU9Z8m33FzwM9E80IADcDcxVuNI,270
482
479
  classiq/qmod/builtins/functions/standard_gates.py,sha256=nkDSQWWcCtHMgxi8dQMqeZbx-XhJrQrC7obxxwYYMDQ,15847
483
- classiq/qmod/builtins/operations.py,sha256=OHTnPzS0yEEeBfn5yNAcjdzOzYvengEnw0rLFwxhWWQ,28555
480
+ classiq/qmod/builtins/operations.py,sha256=ztwP6_PfuMQuvr4mlBInNCQXE37g66xZ7V8VdhNwd0I,30527
484
481
  classiq/qmod/builtins/structs.py,sha256=HMtbIi5IpEeekqSwigxY84EkKBUf8NtIiEvGkas4d94,5752
485
482
  classiq/qmod/cfunc.py,sha256=BVHvgVXAZS1SyE0g8Q-1YEMhNO566V0hnl4LZJS3Eg0,1088
486
483
  classiq/qmod/classical_function.py,sha256=QqG4Lg8qvd_OpfCsvI0Yv62DCG7tnY2otiXKPqy72EI,1115
@@ -525,12 +522,12 @@ classiq/qmod/symbolic.py,sha256=HtaHB7xz-KGt-tWmVw6Q4wlEq0MPLr99fPcbzqzdWoM,8178
525
522
  classiq/qmod/symbolic_expr.py,sha256=z49EyU_bzqc8qOlaOWcWH8A87ACS6aIkYzsLC0DmUBU,7601
526
523
  classiq/qmod/symbolic_type.py,sha256=27tY6pJMFt3EmXIKDJPrNFIUuanIlEu4OueseARbk10,260
527
524
  classiq/qmod/type_attribute_remover.py,sha256=NZmTXAsngWqthXjE8n-n6yE72fiWTFM12-TXXJ1kJ-Q,1242
528
- classiq/qmod/utilities.py,sha256=mP1eRQhD2RHN8DbNA5ufipYRHLlhHvCHclTFk3mf8VA,5679
525
+ classiq/qmod/utilities.py,sha256=iS1adFBvnYm31PVkNIx2d6Ir5EqYoqo70B_t2pdPz7I,5443
529
526
  classiq/qmod/write_qmod.py,sha256=8xiZKCpy0y5c246DRow22-2YQm7F_eSTXY2KJRFAeds,3495
530
527
  classiq/quantum_program.py,sha256=9r1AvhPHDZb4lBEem5T5-mMqbojjyRWHysbJhAoNx80,2056
531
528
  classiq/synthesis.py,sha256=RedYU2XVovqd1nmZU4Nb3b705gBlDarXDqQ1A7ug6C0,9852
532
529
  classiq/visualization.py,sha256=SvLkPNN-RFd74wnH83eBNANjX11phBTo0wedTazr7VQ,975
533
- classiq-0.95.0.dist-info/licenses/LICENSE.txt,sha256=pIUwTWPybNElw1us8qbLyUuGDCH1_YioM4ol5tg0Zzw,13367
534
- classiq-0.95.0.dist-info/WHEEL,sha256=X16MKk8bp2DRsAuyteHJ-9qOjzmnY0x1aj0P1ftqqWA,78
535
- classiq-0.95.0.dist-info/METADATA,sha256=-sY5mtXDbe_cKXYIrkBpENRaGMbWeOMv4-c9HlFBS4U,3744
536
- classiq-0.95.0.dist-info/RECORD,,
530
+ classiq-0.96.0.dist-info/licenses/LICENSE.txt,sha256=pIUwTWPybNElw1us8qbLyUuGDCH1_YioM4ol5tg0Zzw,13367
531
+ classiq-0.96.0.dist-info/WHEEL,sha256=X16MKk8bp2DRsAuyteHJ-9qOjzmnY0x1aj0P1ftqqWA,78
532
+ classiq-0.96.0.dist-info/METADATA,sha256=KVbYqgHjBtihYnewywLFGyvLdLzGb0f31abRTIlSZOs,3744
533
+ classiq-0.96.0.dist-info/RECORD,,
classiq/execution/iqcc.py DELETED
@@ -1,128 +0,0 @@
1
- import time
2
- import webbrowser
3
-
4
- from classiq.interface.exceptions import ClassiqError
5
- from classiq.interface.execution.iqcc import (
6
- IQCCAuthItemDetails,
7
- IQCCInitAuthData,
8
- IQCCListAuthMethods,
9
- IQCCListAuthTargets,
10
- IQCCProbeAuthData,
11
- )
12
-
13
- from classiq._internals.api_wrapper import ApiWrapper
14
- from classiq._internals.async_utils import syncify_function
15
-
16
-
17
- async def list_iqcc_auth_scopes_async() -> list[IQCCAuthItemDetails]:
18
- """List available authentication scopes in IQCC Bounday.
19
-
20
- Returns:
21
- The available authentication scopes.
22
- """
23
- response = await ApiWrapper().call_iqcc_list_auth_scopes()
24
- return response.items
25
-
26
-
27
- list_iqcc_auth_scopes = syncify_function(list_iqcc_auth_scopes_async)
28
-
29
-
30
- async def list_iqcc_auth_methods_async(auth_scope_id: str) -> list[IQCCAuthItemDetails]:
31
- """List available authentication methods in IQCC Bounday for a specific scope.
32
-
33
- Args:
34
- auth_scope_id: The ID of the IQCC Boundary authentication scope.
35
-
36
- Returns:
37
- The available authentication methods.
38
- """
39
- response = await ApiWrapper().call_iqcc_list_auth_methods(
40
- IQCCListAuthMethods(auth_scope_id=auth_scope_id)
41
- )
42
- return response.items
43
-
44
-
45
- list_iqcc_auth_methods = syncify_function(list_iqcc_auth_methods_async)
46
-
47
-
48
- async def generate_iqcc_token_async(
49
- auth_scope_id: str,
50
- auth_method_id: str,
51
- timeout: float = 120,
52
- probe_interval: float = 1,
53
- print_auth_url: bool = True,
54
- ) -> str:
55
- """Interactively generate a token for use in IQCC backends.
56
-
57
- Args:
58
- auth_scope_id: The ID of the IQCC Boundary authentication scope.
59
- auth_method_id: The ID of the IQCC Boundary authentication method.
60
- timeout: Number of seconds to wait for the interactive authentication to complete.
61
- probe_interval: Number of seconds to wait between probes of the authentication.
62
- print_auth_url: Whether to print the authentication URL, useful for headless machines with no browser.
63
-
64
- Returns:
65
- The authentication token string to use directly in `IQCCBackendPreferences`.
66
-
67
- Raises:
68
- ClassiqError: In case timeout has reached before a successful authentication.
69
- """
70
- initiate_response = await ApiWrapper().call_iqcc_init_auth(
71
- IQCCInitAuthData(auth_scope_id=auth_scope_id, auth_method_id=auth_method_id)
72
- )
73
-
74
- if print_auth_url:
75
- print("Please proceed with authentication on your web browser.") # noqa: T201
76
- print("If no window has opened, use this link to authenticate:") # noqa: T201
77
- print(initiate_response.auth_url) # noqa: T201
78
-
79
- webbrowser.open_new_tab(initiate_response.auth_url)
80
-
81
- start_time = time.monotonic()
82
- while True:
83
- time.sleep(probe_interval)
84
- probe_response = await ApiWrapper().call_iqcc_probe_auth(
85
- IQCCProbeAuthData(
86
- auth_scope_id=auth_scope_id,
87
- auth_method_id=auth_method_id,
88
- token_id=initiate_response.token_id,
89
- )
90
- )
91
- if probe_response is not None:
92
- return probe_response.auth_token
93
-
94
- if time.monotonic() - start_time > timeout:
95
- raise ClassiqError(
96
- f"Timeout has reached while probing IQCC authentication. Please try again and make sure to authenticate within {timeout} seconds, or increase the timeout."
97
- )
98
-
99
-
100
- generate_iqcc_token = syncify_function(generate_iqcc_token_async)
101
-
102
-
103
- async def list_iqcc_auth_targets_async(
104
- auth_scope_id: str,
105
- auth_method_id: str,
106
- auth_token: str,
107
- ) -> list[IQCCAuthItemDetails]:
108
- """List available authentication targets in IQCC Boundary for the user.
109
-
110
- Args:
111
- auth_scope_id: The ID of the IQCC Boundary authentication scope.
112
- auth_method_id: The ID of the IQCC Boundary authentication method.
113
- auth_token: The authentication token string returned from `generate_iqcc_token_async`.
114
-
115
- Returns:
116
- The available authentication targets.
117
- """
118
- response = await ApiWrapper().call_iqcc_list_auth_targets(
119
- IQCCListAuthTargets(
120
- auth_scope_id=auth_scope_id,
121
- auth_method_id=auth_method_id,
122
- auth_token=auth_token,
123
- )
124
- )
125
- return response.items
126
-
127
-
128
- list_iqcc_auth_target = syncify_function(list_iqcc_auth_targets_async)
@@ -1,42 +0,0 @@
1
- from pydantic import BaseModel, Field
2
-
3
- from classiq.interface.helpers.versioned_model import VersionedModel
4
-
5
-
6
- class IQCCInitAuthData(VersionedModel):
7
- auth_scope_id: str
8
- auth_method_id: str
9
-
10
-
11
- class IQCCInitAuthResponse(VersionedModel):
12
- auth_url: str
13
- token_id: str
14
-
15
-
16
- class IQCCProbeAuthData(IQCCInitAuthData):
17
- token_id: str
18
-
19
-
20
- class IQCCProbeAuthResponse(VersionedModel):
21
- auth_token: str
22
-
23
-
24
- class IQCCAuthItemDetails(BaseModel):
25
- id: str
26
- name: str
27
- description: str
28
- scope_id: str | None = Field(default=None)
29
-
30
-
31
- class IQCCAuthItemsDetails(VersionedModel):
32
- items: list[IQCCAuthItemDetails]
33
-
34
-
35
- class IQCCListAuthMethods(VersionedModel):
36
- auth_scope_id: str
37
-
38
-
39
- class IQCCListAuthTargets(VersionedModel):
40
- auth_scope_id: str
41
- auth_method_id: str
42
- auth_token: str
@@ -1,71 +0,0 @@
1
- from itertools import product
2
-
3
- from classiq.interface.exceptions import ClassiqValueError
4
-
5
- from classiq.qmod.builtins.operations import assign, bind, within_apply
6
- from classiq.qmod.qmod_variable import QNum
7
- from classiq.qmod.symbolic import subscript
8
- from classiq.qmod.utilities import RealFunction, get_temp_var_name, qnum_values
9
-
10
-
11
- def _get_qnum_values(num: QNum) -> list[float]:
12
- size = num.size
13
- is_signed = num.is_signed
14
- fraction_digits = num.fraction_digits
15
- if (
16
- not isinstance(size, int)
17
- or not isinstance(is_signed, bool)
18
- or not isinstance(fraction_digits, int)
19
- ):
20
- raise ClassiqValueError(f"QNum argument {str(num)!r} has symbolic attributes")
21
-
22
- return qnum_values(size, is_signed, fraction_digits)
23
-
24
-
25
- def get_lookup_table(func: RealFunction, *targets: QNum) -> list[float]:
26
- """
27
- Reduces a classical function into a lookup table over all the possible values
28
- of the quantum numbers.
29
-
30
- Args:
31
- func: A Python function
32
- *targets: One or more initialized quantum numbers
33
-
34
- Returns:
35
- The function's lookup table
36
-
37
- Notes:
38
- The QNum arguments must have generative attributes
39
- """
40
- target_vals = [_get_qnum_values(target) for target in targets]
41
- return [func(*vals[::-1]) for vals in product(*target_vals[::-1])]
42
-
43
-
44
- def span_lookup_table(func: RealFunction, *targets: QNum) -> QNum:
45
- """
46
- Applies a classical function to quantum numbers.
47
-
48
- Works by reducing the function into a lookup table over all the possible values
49
- of the quantum numbers.
50
-
51
- Args:
52
- func: A Python function
53
- *targets: One or more initialized quantum numbers
54
-
55
- Returns:
56
- The quantum result of applying func to targets
57
-
58
- Notes:
59
- The QNum arguments must have generative attributes
60
- """
61
- lookup_table = get_lookup_table(func, *targets)
62
-
63
- index_size = sum(target.size for target in targets)
64
- index: QNum = QNum(get_temp_var_name(), size=index_size)
65
- result: QNum = QNum(get_temp_var_name("result"))
66
-
67
- within_apply(
68
- lambda: bind(list(targets), index),
69
- lambda: assign(subscript(lookup_table, index), result),
70
- )
71
- return result