luna-quantum 1.0.8rc2__cp313-cp313-win_amd64.whl → 1.0.8rc4__cp313-cp313-win_amd64.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 luna-quantum might be problematic. Click here for more details.

Files changed (31) hide show
  1. luna_quantum/__init__.py +19 -1
  2. luna_quantum/__init__.pyi +14 -1
  3. luna_quantum/_core.cp313-win_amd64.pyd +0 -0
  4. luna_quantum/_core.pyi +185 -84
  5. luna_quantum/_utility.py +148 -0
  6. luna_quantum/_utility.pyi +20 -0
  7. luna_quantum/exceptions/luna_quantum_call_type_error.py +9 -0
  8. luna_quantum/factories/usecase_factory.py +32 -0
  9. luna_quantum/solve/domain/solve_job.py +42 -8
  10. luna_quantum/solve/interfaces/usecases/__init__.py +4 -0
  11. luna_quantum/solve/interfaces/usecases/solve_job_get_by_id_usecase_i.py +27 -0
  12. luna_quantum/solve/parameters/algorithms/quantum_gate/__init__.py +1 -1
  13. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/__init__.py +9 -25
  14. luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/__init__.py +29 -0
  15. luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/config.py +58 -0
  16. luna_quantum/solve/parameters/algorithms/quantum_gate/{flex_qaoa/flex_qaoa.py → flexqaoa/flexqaoa.py} +48 -86
  17. luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/optimizers.py +53 -0
  18. luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/pipeline.py +164 -0
  19. luna_quantum/solve/parameters/backends/__init__.py +2 -0
  20. luna_quantum/solve/parameters/backends/aqarios_gpu.py +17 -0
  21. luna_quantum/solve/parameters/errors.py +30 -0
  22. luna_quantum/solve/usecases/solve_job_get_by_id_usecase.py +44 -0
  23. luna_quantum/solve/usecases/solve_job_get_result_usecase.py +21 -11
  24. {luna_quantum-1.0.8rc2.dist-info → luna_quantum-1.0.8rc4.dist-info}/METADATA +1 -1
  25. {luna_quantum-1.0.8rc2.dist-info → luna_quantum-1.0.8rc4.dist-info}/RECORD +28 -20
  26. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/config.py +0 -80
  27. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/optimizers.py +0 -99
  28. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/pipeline.py +0 -87
  29. {luna_quantum-1.0.8rc2.dist-info → luna_quantum-1.0.8rc4.dist-info}/WHEEL +0 -0
  30. {luna_quantum-1.0.8rc2.dist-info → luna_quantum-1.0.8rc4.dist-info}/licenses/LICENSE +0 -0
  31. {luna_quantum-1.0.8rc2.dist-info → luna_quantum-1.0.8rc4.dist-info}/licenses/NOTICE +0 -0
@@ -0,0 +1,148 @@
1
+ """Utility module for internals."""
2
+
3
+ import sys
4
+
5
+ if sys.version_info < (3, 13):
6
+ from warnings import warn
7
+
8
+ class DeprecationWarning(Warning): ... # noqa: A001
9
+
10
+ class deprecated: # noqa: N801
11
+ """Indicate that a class, function or overload is deprecated.
12
+
13
+ When this decorator is applied to an object, the type checker
14
+ will generate a diagnostic on usage of the deprecated object.
15
+
16
+ Usage:
17
+
18
+ @deprecated("Use B instead")
19
+ class A:
20
+ pass
21
+
22
+ @deprecated("Use g instead")
23
+ def f():
24
+ pass
25
+
26
+ @overload
27
+ @deprecated("int support is deprecated")
28
+ def g(x: int) -> int: ...
29
+ @overload
30
+ def g(x: str) -> int: ...
31
+
32
+ The warning specified by *category* will be emitted at runtime
33
+ on use of deprecated objects. For functions, that happens on calls;
34
+ for classes, on instantiation and on creation of subclasses.
35
+ If the *category* is ``None``, no warning is emitted at runtime.
36
+ The *stacklevel* determines where the
37
+ warning is emitted. If it is ``1`` (the default), the warning
38
+ is emitted at the direct caller of the deprecated object; if it
39
+ is higher, it is emitted further up the stack.
40
+ Static type checker behavior is not affected by the *category*
41
+ and *stacklevel* arguments.
42
+
43
+ The deprecation message passed to the decorator is saved in the
44
+ ``__deprecated__`` attribute on the decorated object.
45
+ If applied to an overload, the decorator
46
+ must be after the ``@overload`` decorator for the attribute to
47
+ exist on the overload as returned by ``get_overloads()``.
48
+
49
+ See PEP 702 for details.
50
+
51
+ """
52
+
53
+ def __init__(
54
+ self,
55
+ message: str,
56
+ /,
57
+ *,
58
+ category: type[Warning] | None = DeprecationWarning, # noqa: PYI011,RUF100
59
+ stacklevel: int = 1,
60
+ ) -> None:
61
+ if not isinstance(message, str):
62
+ raise TypeError( # noqa: TRY003
63
+ f"Expected an object of type str for 'message', not {type(message).__name__!r}" # noqa: E501
64
+ )
65
+ self.message = message
66
+ self.category = category
67
+ self.stacklevel = stacklevel
68
+
69
+ def __call__(self, arg, /): # noqa: C901,ANN001,ANN204
70
+ # Make sure the inner functions created below don't
71
+ # retain a reference to self.
72
+ msg = self.message
73
+ category = self.category
74
+ stacklevel = self.stacklevel
75
+ if category is None:
76
+ arg.__deprecated__ = msg
77
+ return arg
78
+ elif isinstance(arg, type): # noqa: RET505
79
+ import functools # noqa: PLC0415
80
+ from types import MethodType # noqa: PLC0415
81
+
82
+ original_new = arg.__new__
83
+
84
+ @functools.wraps(original_new)
85
+ def __new__(cls, /, *args, **kwargs): # noqa: N807,ANN001,ANN202,ANN003,ANN002
86
+ if cls is arg:
87
+ warn(msg, category=category, stacklevel=stacklevel + 1)
88
+ if original_new is not object.__new__:
89
+ return original_new(cls, *args, **kwargs)
90
+ # Mirrors a similar check in object.__new__.
91
+ elif cls.__init__ is object.__init__ and (args or kwargs): # noqa: RET505
92
+ raise TypeError(f"{cls.__name__}() takes no arguments") # noqa: TRY003
93
+ else:
94
+ return original_new(cls)
95
+
96
+ arg.__new__ = staticmethod(__new__)
97
+
98
+ original_init_subclass = arg.__init_subclass__
99
+ # We need slightly different behavior if __init_subclass__
100
+ # is a bound method (likely if it was implemented in Python)
101
+ if isinstance(original_init_subclass, MethodType):
102
+ original_init_subclass = original_init_subclass.__func__
103
+
104
+ @functools.wraps(original_init_subclass)
105
+ def __init_subclass__(*args, **kwargs): # noqa: ANN002,ANN202,ANN003,N807
106
+ warn(msg, category=category, stacklevel=stacklevel + 1)
107
+ return original_init_subclass(*args, **kwargs)
108
+
109
+ arg.__init_subclass__ = classmethod(__init_subclass__)
110
+ # Or otherwise, which likely means it's a builtin such as
111
+ # object's implementation of __init_subclass__.
112
+ else:
113
+
114
+ @functools.wraps(original_init_subclass)
115
+ def __init_subclass__(*args, **kwargs): # noqa: ANN202,ANN002,ANN003,N807
116
+ warn(msg, category=category, stacklevel=stacklevel + 1)
117
+ return original_init_subclass(*args, **kwargs)
118
+
119
+ arg.__init_subclass__ = __init_subclass__
120
+
121
+ arg.__deprecated__ = __new__.__deprecated__ = msg
122
+ __init_subclass__.__deprecated__ = msg
123
+ return arg
124
+ elif callable(arg):
125
+ import functools # noqa: PLC0415
126
+ import inspect # noqa: PLC0415
127
+
128
+ @functools.wraps(arg)
129
+ def wrapper(*args, **kwargs): # noqa: ANN002,ANN003,ANN202
130
+ warn(msg, category=category, stacklevel=stacklevel + 1)
131
+ return arg(*args, **kwargs)
132
+
133
+ if inspect.iscoroutinefunction(arg):
134
+ wrapper = inspect.markcoroutinefunction(wrapper)
135
+
136
+ arg.__deprecated__ = wrapper.__deprecated__ = msg
137
+ return wrapper
138
+ else:
139
+ raise TypeError( # noqa: TRY003
140
+ "@deprecated decorator with non-None category must be applied to "
141
+ f"a class or callable, not {arg!r}"
142
+ )
143
+
144
+ else:
145
+ from warnings import deprecated
146
+
147
+
148
+ __all__ = ["deprecated"]
@@ -0,0 +1,20 @@
1
+ import sys
2
+
3
+ if sys.version_info < (3, 13): # noqa: PYI066
4
+ class DeprecationWarning(Warning): ... # noqa: A001
5
+
6
+ class deprecated: # noqa: N801
7
+ def __init__(
8
+ self,
9
+ message: str,
10
+ /,
11
+ *,
12
+ category: type[Warning] | None = ...,
13
+ stacklevel: int = 1,
14
+ ) -> None: ...
15
+ def __call__(self, arg, /): ... # noqa: ANN001,ANN204
16
+
17
+ else:
18
+ from warnings import deprecated
19
+
20
+ __all__ = ["deprecated"]
@@ -0,0 +1,9 @@
1
+ from luna_quantum.client.schemas.enums.call_style import CallStyle
2
+ from luna_quantum.exceptions.base_luna_quantum_error import BaseLunaQuantumError
3
+
4
+
5
+ class LunaQuantumCallStyleError(BaseLunaQuantumError):
6
+ """Luna Quantum call style error."""
7
+
8
+ def __init__(self, call_style: CallStyle) -> None:
9
+ super().__init__(f"The call style '{call_style}' is not supported.")
@@ -3,6 +3,7 @@ from typing import ClassVar
3
3
  from luna_quantum.client.interfaces.services.luna_solve_i import ILunaSolve
4
4
  from luna_quantum.solve.interfaces.usecases import (
5
5
  IModelLoadMetadataByHashUseCase,
6
+ ISolveJobGetByIdUseCase,
6
7
  )
7
8
  from luna_quantum.solve.interfaces.usecases.model_delete_usecase_i import (
8
9
  IModelDeleteUseCase,
@@ -64,6 +65,7 @@ class UseCaseFactory:
64
65
  _solve_job_delete_class: ClassVar[type[ISolveJobDeleteUseCase]]
65
66
  _solve_job_get_result_class: ClassVar[type[ISolveJobGetResultUseCase]]
66
67
  _solve_job_fetch_updates_class: ClassVar[type[ISolveJobFetchUpdatesUseCase]]
68
+ _solve_job_get_by_id_class: ClassVar[type[ISolveJobGetByIdUseCase]]
67
69
 
68
70
  @classmethod
69
71
  def set_model_fetch_class(
@@ -232,6 +234,19 @@ class UseCaseFactory:
232
234
  """
233
235
  cls._solve_job_fetch_updates_class = solve_job_fetch_updates_class
234
236
 
237
+ @classmethod
238
+ def set_solve_job_get_id_class(
239
+ cls, solve_job_get_by_id_class: type[ISolveJobGetByIdUseCase]
240
+ ) -> None:
241
+ """Set the implementation class for fetching solve job updates.
242
+
243
+ Parameters
244
+ ----------
245
+ solve_job_get_by_id_class : Type[ISolveJobGetByIdUseCase]
246
+ The class implementing ISolveJobGetByIdUseCase
247
+ """
248
+ cls._solve_job_get_by_id_class = solve_job_get_by_id_class
249
+
235
250
  @classmethod
236
251
  def model_load_by_id(cls, client: ILunaSolve) -> IModelLoadByIdUseCase:
237
252
  """
@@ -437,6 +452,23 @@ class UseCaseFactory:
437
452
  """
438
453
  return cls._solve_job_fetch_updates_class(client=client)
439
454
 
455
+ @classmethod
456
+ def solve_job_get_by_id(cls, client: ILunaSolve) -> ISolveJobGetByIdUseCase:
457
+ """
458
+ Get the use-case to retrieve a solve-job by its id.
459
+
460
+ Parameters
461
+ ----------
462
+ client : ILunaSolve
463
+ The client used to retrieve a solve-job.
464
+
465
+ Returns
466
+ -------
467
+ ISolveJobGetByIdUseCase
468
+ An instance of the class responsible for retrieving a solve job by its id.
469
+ """
470
+ return cls._solve_job_get_by_id_class(client=client)
471
+
440
472
  @classmethod
441
473
  def model_load_metadata_by_hash(
442
474
  cls, client: ILunaSolve
@@ -1,18 +1,23 @@
1
- from logging import Logger
2
- from typing import Any, ClassVar, Literal
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any, ClassVar, Literal
3
4
 
4
5
  from pydantic import BaseModel, PrivateAttr
5
6
 
6
- from luna_quantum._core import Solution
7
- from luna_quantum.aqm_overwrites.model import Model
8
- from luna_quantum.client.interfaces.services.luna_solve_i import ILunaSolve
9
7
  from luna_quantum.client.schemas.enums.call_style import CallStyle
10
- from luna_quantum.client.schemas.enums.model_format import ModelFormat
11
- from luna_quantum.client.schemas.enums.status import StatusEnum
12
- from luna_quantum.client.schemas.wrappers import PydanticDatetimeWrapper
8
+ from luna_quantum.client.schemas.enums.model_format import ModelFormat # noqa: TC001
9
+ from luna_quantum.client.schemas.enums.status import StatusEnum # noqa: TC001
10
+ from luna_quantum.client.schemas.wrappers import PydanticDatetimeWrapper # noqa: TC001
13
11
  from luna_quantum.factories.luna_solve_client_factory import LunaSolveClientFactory
14
12
  from luna_quantum.util.log_utils import Logging
15
13
 
14
+ if TYPE_CHECKING:
15
+ from logging import Logger
16
+
17
+ from luna_quantum._core import Solution
18
+ from luna_quantum.aqm_overwrites.model import Model
19
+ from luna_quantum.client.interfaces.services.luna_solve_i import ILunaSolve
20
+
16
21
 
17
22
  class SolveJob(BaseModel):
18
23
  """A model to represent a job for solving model problems."""
@@ -194,3 +199,32 @@ class SolveJob(BaseModel):
194
199
  )
195
200
 
196
201
  UseCaseFactory.solve_job_delete(client=c).__call__(solve_job_id=self.id)
202
+
203
+ @staticmethod
204
+ def get_by_id(solve_job_id: str, client: ILunaSolve | None = None) -> SolveJob:
205
+ """
206
+ Retrieve a solve-job by its ID.
207
+
208
+ Para>meters
209
+ ----------
210
+ solve_job_id: str
211
+ Get the solve-job id for which a SolveJob should be retrieved.
212
+ client : Optional[ILunaSolve], optional
213
+ The client to be used for job deletion. If not provided, a default client
214
+ is retrieved using `ClientFactory`.
215
+
216
+ Returns
217
+ -------
218
+ SolveJob
219
+ The solve-job object.
220
+
221
+
222
+ """
223
+ c: ILunaSolve = LunaSolveClientFactory.get_client(client)
224
+ from luna_quantum.factories.usecase_factory import ( # noqa: PLC0415
225
+ UseCaseFactory,
226
+ )
227
+
228
+ return UseCaseFactory.solve_job_get_by_id(client=c).__call__(
229
+ solve_job_id=solve_job_id
230
+ )
@@ -34,6 +34,9 @@ from .solve_job_delete_usecase_i import (
34
34
  from .solve_job_fetch_updates_usecase_i import (
35
35
  ISolveJobFetchUpdatesUseCase,
36
36
  )
37
+ from .solve_job_get_by_id_usecase_i import (
38
+ ISolveJobGetByIdUseCase,
39
+ )
37
40
  from .solve_job_get_result_usecase_i import (
38
41
  ISolveJobGetResultUseCase,
39
42
  )
@@ -51,5 +54,6 @@ __all__ = [
51
54
  "ISolveJobCreateUseCase",
52
55
  "ISolveJobDeleteUseCase",
53
56
  "ISolveJobFetchUpdatesUseCase",
57
+ "ISolveJobGetByIdUseCase",
54
58
  "ISolveJobGetResultUseCase",
55
59
  ]
@@ -0,0 +1,27 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import ABC, abstractmethod
4
+ from typing import TYPE_CHECKING
5
+
6
+ if TYPE_CHECKING:
7
+ from luna_quantum.client.interfaces.services.luna_solve_i import ILunaSolve
8
+ from luna_quantum.solve.domain.solve_job import SolveJob
9
+
10
+
11
+ class ISolveJobGetByIdUseCase(ABC):
12
+ """Represent an abstract base to retrieve a solve-job by its id."""
13
+
14
+ @abstractmethod
15
+ def __init__(self, client: ILunaSolve) -> None:
16
+ pass
17
+
18
+ @abstractmethod
19
+ def __call__(self, solve_job_id: str) -> SolveJob:
20
+ """
21
+ Represent an abstract base for callable objects to retrieve solve jobs.
22
+
23
+ Parameters
24
+ ----------
25
+ solve_job_id : str
26
+ The id of the solve-job to retrieve.
27
+ """
@@ -1,4 +1,4 @@
1
- from .flex_qaoa import FlexQAOA
1
+ from .flexqaoa import FlexQAOA
2
2
  from .qaoa import QAOA
3
3
  from .qaoa_fo import QAOA_FO
4
4
  from .vqe import VQE
@@ -1,26 +1,10 @@
1
- from .config import AdvancedConfig, XYMixer
2
- from .flex_qaoa import FlexQAOA
3
- from .optimizers import (
4
- CombinedOptimizerParams,
5
- InterpolateOptimizerParams,
6
- LinearOptimizerParams,
7
- )
8
- from .pipeline import (
9
- IndicatorFunctionParams,
10
- OneHotParams,
11
- PipelineParams,
12
- QuadraticPenaltyParams,
13
- )
1
+ import warnings
14
2
 
15
- __all__ = [
16
- "AdvancedConfig",
17
- "CombinedOptimizerParams",
18
- "FlexQAOA",
19
- "IndicatorFunctionParams",
20
- "InterpolateOptimizerParams",
21
- "LinearOptimizerParams",
22
- "OneHotParams",
23
- "PipelineParams",
24
- "QuadraticPenaltyParams",
25
- "XYMixer",
26
- ]
3
+ from luna_quantum.solve.parameters.algorithms.quantum_gate.flexqaoa import * # noqa: F403
4
+
5
+ warnings.warn(
6
+ "The module `flex_qaoa` is deprecated and will be removed in the future. "
7
+ "Use 'flexqaoa' instead.",
8
+ DeprecationWarning,
9
+ stacklevel=2,
10
+ )
@@ -0,0 +1,29 @@
1
+ from .config import CustomConfig
2
+ from .flexqaoa import FlexQAOA
3
+ from .optimizers import (
4
+ CombinedOptimizerParams,
5
+ InterpolateOptimizerParams,
6
+ )
7
+ from .pipeline import (
8
+ IndicatorFunctionConfig,
9
+ InequalityToEqualityConfig,
10
+ PenaltySetting,
11
+ PipelineParams,
12
+ QuadraticPenaltyConfig,
13
+ SetpackingAsOnehotConfig,
14
+ XYMixerConfig,
15
+ )
16
+
17
+ __all__ = [
18
+ "CombinedOptimizerParams",
19
+ "CustomConfig",
20
+ "FlexQAOA",
21
+ "IndicatorFunctionConfig",
22
+ "InequalityToEqualityConfig",
23
+ "InterpolateOptimizerParams",
24
+ "PenaltySetting",
25
+ "PipelineParams",
26
+ "QuadraticPenaltyConfig",
27
+ "SetpackingAsOnehotConfig",
28
+ "XYMixerConfig",
29
+ ]
@@ -0,0 +1,58 @@
1
+ from typing import Literal
2
+
3
+ from pydantic import BaseModel, Field, PositiveInt
4
+
5
+
6
+ class CustomConfig(BaseModel):
7
+ """Additional FlexQAOA circuit configuration.
8
+
9
+ Attributes
10
+ ----------
11
+ max_qubits : PositiveInt | None
12
+ Maximum number of qubits allowed for the circuit. If `None`, no limit is
13
+ applied. Default: `None`.
14
+ minimize_qubits : bool
15
+ Minimize the number of used qubits in the circuit if set to `True`. Otherwise,
16
+ minimize circuit depth. Default: `False`.
17
+ wstate : Literal["log", "bilinear", "linear"]
18
+ WState generation cricuit. Choice between:
19
+
20
+ - `"log"`: Logarithmic-depth binary tree circuit.
21
+ - `"linear"`: Linear circuit construction.
22
+ - `"bilinear"`: Bi-linear circuit construction, starts in the middle and
23
+ linearly constructs the circuit outwards.
24
+
25
+ Default: `"log"`
26
+ qft_synth : Literal["line", "full"]
27
+ QFT synthesis method. Choice between:
28
+
29
+ - `"full"`: Shorter circuit depth implementation that requires all-to-all
30
+ connectivity.
31
+ - `"line"`: Longer circuit depth implementation that requires linear
32
+ connectivity.
33
+
34
+ Default: `"full"`
35
+ """
36
+
37
+ max_qubits: PositiveInt | None = Field(
38
+ default=None,
39
+ description="Maximum number of qubits allowed for the circuit. If `None`, no "
40
+ "limit is applied.",
41
+ )
42
+ minimize_qubits: bool = Field(
43
+ default=False,
44
+ description="Minimize the number of used qubits in the circuit "
45
+ "if set to `True`. Otherwise, minimize circuit depth.",
46
+ )
47
+ wstate: Literal["log", "bilinear", "linear"] = Field(
48
+ default="log",
49
+ description="WState generation cricuit. Choice between: Logarithmic-depth (log)"
50
+ " binary tree circuit and linear or bilinear construction. bilinear places the "
51
+ "start in the middle and linearly constructs the circuit outwards.",
52
+ )
53
+ qft_synth: Literal["line", "full"] = Field(
54
+ default="full",
55
+ description="QFT synthesis method. Shorter depth (full) implementation requires"
56
+ " all-to-all connectivity. Longer (line) implementation requires only linear "
57
+ "connectivity.",
58
+ )