luna-quantum 1.0.0__cp312-cp312-win_amd64.whl → 1.0.1rc10__cp312-cp312-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.
- luna_quantum/__init__.py +32 -17
- luna_quantum/__init__.pyi +23 -14
- luna_quantum/_core.cp312-win_amd64.pyd +0 -0
- luna_quantum/_core.pyi +1041 -375
- luna_quantum/algorithms/__init__.py +1 -0
- luna_quantum/backends/__init__.py +1 -0
- luna_quantum/client/rest_client/qpu_token_rest_client.py +7 -3
- luna_quantum/client/schemas/circuit.py +5 -6
- luna_quantum/client/schemas/create/__init__.py +10 -1
- luna_quantum/client/schemas/create/circuit.py +5 -6
- luna_quantum/client/schemas/create/qpu_token.py +2 -5
- luna_quantum/client/schemas/create/qpu_token_time_quota.py +3 -6
- luna_quantum/client/schemas/create/qpu_token_time_quota_update.py +15 -0
- luna_quantum/client/schemas/create/solve_job_create.py +1 -1
- luna_quantum/client/schemas/qpu_token/qpu_token.py +9 -16
- luna_quantum/client/schemas/qpu_token/token_provider.py +3 -6
- luna_quantum/errors.py +34 -1
- luna_quantum/errors.pyi +83 -26
- luna_quantum/solve/domain/solve_job.py +2 -2
- luna_quantum/solve/parameters/algorithms/base_params/quantum_annealing_params.py +1 -0
- luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +4 -2
- luna_quantum/solve/parameters/algorithms/quantum_annealing/quantum_annealing.py +38 -22
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/optimizers.py +4 -2
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +1 -3
- luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +2 -3
- luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +0 -16
- luna_quantum/solve/parameters/backends/__init__.py +1 -1
- luna_quantum/solve/parameters/backends/dwave_qpu.py +4 -2
- luna_quantum/solve/parameters/backends/ibm.py +8 -2
- luna_quantum/solve/parameters/backends/qctrl.py +4 -3
- luna_quantum/solve/use_cases/hamiltonian_cycle.py +2 -2
- luna_quantum/solve/usecases/solve_job_get_result_usecase.py +1 -3
- luna_quantum/translator.py +23 -1
- luna_quantum/translator.pyi +76 -43
- luna_quantum/utils.py +29 -11
- {luna_quantum-1.0.0.dist-info → luna_quantum-1.0.1rc10.dist-info}/METADATA +2 -4
- {luna_quantum-1.0.0.dist-info → luna_quantum-1.0.1rc10.dist-info}/RECORD +40 -37
- {luna_quantum-1.0.0.dist-info → luna_quantum-1.0.1rc10.dist-info}/WHEEL +1 -1
- {luna_quantum-1.0.0.dist-info → luna_quantum-1.0.1rc10.dist-info}/licenses/LICENSE +1 -1
- {luna_quantum-1.0.0.dist-info → luna_quantum-1.0.1rc10.dist-info}/licenses/NOTICE +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from luna_quantum.solve.parameters.algorithms import * # noqa: F403
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from luna_quantum.solve.parameters.backends import * # noqa: F403
|
|
@@ -9,7 +9,11 @@ from luna_quantum.client.interfaces.clients.qpu_token_rest_client_i import (
|
|
|
9
9
|
IQpuTokenRestClient,
|
|
10
10
|
)
|
|
11
11
|
from luna_quantum.client.schemas import QpuTokenOut
|
|
12
|
-
from luna_quantum.client.schemas.create import
|
|
12
|
+
from luna_quantum.client.schemas.create import (
|
|
13
|
+
QpuTokenIn,
|
|
14
|
+
QpuTokenTimeQuotaIn,
|
|
15
|
+
QpuTokenTimeQuotaUpdate,
|
|
16
|
+
)
|
|
13
17
|
from luna_quantum.client.schemas.enums.qpu_token_type import QpuTokenTypeEnum
|
|
14
18
|
from luna_quantum.client.schemas.qpu_token.qpu_token_time_quota import (
|
|
15
19
|
QpuTokenTimeQuotaOut,
|
|
@@ -348,12 +352,12 @@ class QpuTokenRestClient(IQpuTokenRestClient):
|
|
|
348
352
|
won't be updated.
|
|
349
353
|
Default: None
|
|
350
354
|
"""
|
|
351
|
-
data =
|
|
355
|
+
data = QpuTokenTimeQuotaUpdate(quota=quota, start=start, end=end)
|
|
352
356
|
|
|
353
357
|
endpoint = self._get_endpoint_by_type(QpuTokenTypeEnum.GROUP)
|
|
354
358
|
response = self._client.patch(
|
|
355
359
|
f"{endpoint}/quota/group/{qpu_token_name}",
|
|
356
|
-
content=
|
|
360
|
+
content=data.model_dump_json(),
|
|
357
361
|
**kwargs,
|
|
358
362
|
)
|
|
359
363
|
response.raise_for_status()
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import Any
|
|
4
4
|
|
|
5
5
|
from pydantic import BaseModel
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
)
|
|
7
|
+
from luna_quantum.client.schemas.enums.circuit import (
|
|
8
|
+
CircuitProviderEnum,
|
|
9
|
+
CircuitStatusEnum,
|
|
10
|
+
)
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
class CircuitJob(BaseModel):
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
from luna_quantum.client.schemas.create.circuit import CircuitIn
|
|
2
2
|
from luna_quantum.client.schemas.create.qpu_token import QpuTokenIn
|
|
3
3
|
from luna_quantum.client.schemas.create.qpu_token_time_quota import QpuTokenTimeQuotaIn
|
|
4
|
+
from luna_quantum.client.schemas.create.qpu_token_time_quota_update import (
|
|
5
|
+
QpuTokenTimeQuotaUpdate,
|
|
6
|
+
)
|
|
4
7
|
from luna_quantum.client.schemas.create.qubo import QUBOIn
|
|
5
8
|
|
|
6
|
-
__all__ = [
|
|
9
|
+
__all__ = [
|
|
10
|
+
"CircuitIn",
|
|
11
|
+
"QUBOIn",
|
|
12
|
+
"QpuTokenIn",
|
|
13
|
+
"QpuTokenTimeQuotaIn",
|
|
14
|
+
"QpuTokenTimeQuotaUpdate",
|
|
15
|
+
]
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import Any
|
|
4
4
|
|
|
5
5
|
from pydantic import BaseModel
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
)
|
|
7
|
+
from luna_quantum.client.schemas.enums.circuit import CircuitProviderEnum
|
|
8
|
+
from luna_quantum.client.schemas.qpu_token.token_provider import (
|
|
9
|
+
RestAPITokenProvider,
|
|
10
|
+
)
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
class CircuitIn(BaseModel):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from pydantic import BaseModel,
|
|
1
|
+
from pydantic import BaseModel, ConfigDict
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class QpuTokenIn(BaseModel):
|
|
@@ -19,7 +19,4 @@ class QpuTokenIn(BaseModel):
|
|
|
19
19
|
provider: str
|
|
20
20
|
token: str
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
"""Pydantic configuration class."""
|
|
24
|
-
|
|
25
|
-
extra = Extra.forbid
|
|
22
|
+
model_config = ConfigDict(extra="forbid")
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
|
-
|
|
5
3
|
from pydantic import BaseModel
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
from datetime import datetime
|
|
5
|
+
from luna_quantum.client.schemas.wrappers import PydanticDatetimeWrapper
|
|
9
6
|
|
|
10
7
|
|
|
11
8
|
class QpuTokenTimeQuotaIn(BaseModel):
|
|
@@ -25,5 +22,5 @@ class QpuTokenTimeQuotaIn(BaseModel):
|
|
|
25
22
|
"""
|
|
26
23
|
|
|
27
24
|
quota: int
|
|
28
|
-
start:
|
|
29
|
-
end:
|
|
25
|
+
start: PydanticDatetimeWrapper | None
|
|
26
|
+
end: PydanticDatetimeWrapper | None
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from pydantic import BaseModel, ConfigDict
|
|
2
|
+
|
|
3
|
+
from luna_quantum.client.schemas.wrappers.datetime_wrapper import (
|
|
4
|
+
PydanticDatetimeWrapper,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class QpuTokenTimeQuotaUpdate(BaseModel):
|
|
9
|
+
"""Data structure to update the time quota of a qpu token."""
|
|
10
|
+
|
|
11
|
+
quota: int | None = None
|
|
12
|
+
start: PydanticDatetimeWrapper | None = None
|
|
13
|
+
end: PydanticDatetimeWrapper | None = None
|
|
14
|
+
|
|
15
|
+
model_config = ConfigDict(extra="forbid")
|
|
@@ -2,10 +2,10 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from enum import Enum
|
|
4
4
|
|
|
5
|
-
from pydantic import BaseModel,
|
|
5
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
6
6
|
|
|
7
7
|
from luna_quantum.client.schemas.enums.qpu_token_type import (
|
|
8
|
-
QpuTokenTypeEnum,
|
|
8
|
+
QpuTokenTypeEnum,
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
|
|
@@ -129,24 +129,21 @@ class TokenProvider(BaseModel):
|
|
|
129
129
|
aws_secret_access_key: QpuToken | None = None
|
|
130
130
|
aws_session_token: QpuToken | None = None
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
"""Pydantic configuration class."""
|
|
134
|
-
|
|
135
|
-
extra = Extra.forbid
|
|
132
|
+
model_config = ConfigDict(extra="forbid")
|
|
136
133
|
|
|
137
134
|
|
|
138
135
|
class QpuTokenOut(BaseModel):
|
|
139
136
|
"""
|
|
140
|
-
|
|
137
|
+
pydantic model for qpu token out.
|
|
141
138
|
|
|
142
|
-
|
|
139
|
+
it contains the data received from the api call.
|
|
143
140
|
|
|
144
141
|
Attributes
|
|
145
142
|
----------
|
|
146
|
-
name:
|
|
147
|
-
|
|
143
|
+
name: optional[str]
|
|
144
|
+
name of the qpu token.
|
|
148
145
|
provider: str
|
|
149
|
-
|
|
146
|
+
name of provider.
|
|
150
147
|
|
|
151
148
|
"""
|
|
152
149
|
|
|
@@ -154,8 +151,4 @@ class QpuTokenOut(BaseModel):
|
|
|
154
151
|
provider: str
|
|
155
152
|
token_type: QpuTokenTypeEnum
|
|
156
153
|
|
|
157
|
-
|
|
158
|
-
"""Pydantic configuration class."""
|
|
159
|
-
|
|
160
|
-
extra = Extra.ignore
|
|
161
|
-
from_attributes = True
|
|
154
|
+
model_config = ConfigDict(extra="forbid", from_attributes=True)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from pydantic import BaseModel,
|
|
3
|
+
from pydantic import BaseModel, ConfigDict
|
|
4
4
|
|
|
5
5
|
from luna_quantum.client.schemas.qpu_token.qpu_token import (
|
|
6
6
|
QpuToken,
|
|
@@ -92,6 +92,8 @@ class RestAPITokenProvider(BaseModel):
|
|
|
92
92
|
qctrl: _RestQpuToken | None = None
|
|
93
93
|
aws: AWSQpuTokens | None = None
|
|
94
94
|
|
|
95
|
+
model_config = ConfigDict(extra="forbid")
|
|
96
|
+
|
|
95
97
|
@classmethod
|
|
96
98
|
def from_sdk_token_provider(
|
|
97
99
|
cls, token_provider: TokenProvider
|
|
@@ -128,8 +130,3 @@ class RestAPITokenProvider(BaseModel):
|
|
|
128
130
|
qctrl=_RestQpuToken.from_qpu_token(token_provider.qctrl),
|
|
129
131
|
aws=aws,
|
|
130
132
|
)
|
|
131
|
-
|
|
132
|
-
class Config:
|
|
133
|
-
"""Pydantic config class."""
|
|
134
|
-
|
|
135
|
-
extra = Extra.forbid
|
luna_quantum/errors.py
CHANGED
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
"""
|
|
2
|
+
Define error types for validation, failures, and runtime evaluation issues.
|
|
3
|
+
|
|
4
|
+
This module defines the set of custom exception classes used throughout the system
|
|
5
|
+
to handle errors related to model translation, environment management, solution
|
|
6
|
+
evaluation, and sampling.
|
|
7
|
+
|
|
8
|
+
The exceptions are categorized as follows:
|
|
9
|
+
|
|
10
|
+
1. **Model Errors**:
|
|
11
|
+
- Raised when a model does not meet certain structural or semantic requirements,
|
|
12
|
+
such as being quadratic, unconstrained, or having the correct variable types.
|
|
13
|
+
|
|
14
|
+
2. **Translation Errors**:
|
|
15
|
+
- Raised when issues occur during translation between formats, including both
|
|
16
|
+
model and solution translation failures.
|
|
17
|
+
|
|
18
|
+
3. **Variable and Constraint Errors**:
|
|
19
|
+
- Raised when there are issues related to variable creation, lookup, duplication,
|
|
20
|
+
or constraint naming.
|
|
21
|
+
|
|
22
|
+
4. **Environment Errors**:
|
|
23
|
+
- Raised when conflicts or inconsistencies occur in managing active environments,
|
|
24
|
+
such as having multiple active environments or none at all.
|
|
25
|
+
|
|
26
|
+
5. **Sampling and Evaluation Errors**:
|
|
27
|
+
- Raised during post-processing or evaluation of samples, particularly when the
|
|
28
|
+
sample does not conform to expected formats or contains incompatible data.
|
|
29
|
+
|
|
30
|
+
These error classes enable precise and meaningful error handling, helping developers
|
|
31
|
+
diagnose and respond to failures consistently and effectively.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
from ._core.errors import * # type: ignore[reportMissingImports] # noqa: F403
|
luna_quantum/errors.pyi
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
class VariableOutOfRangeError(Exception):
|
|
2
|
-
"""
|
|
3
|
-
|
|
2
|
+
"""Referenced variable is out of bounds for the environment.
|
|
3
|
+
|
|
4
|
+
Raised when a variable referenced in an expression is out of bounds for the
|
|
5
|
+
environment.
|
|
4
6
|
|
|
5
7
|
This error typically occurs when querying coefficients (linear, quadratic,
|
|
6
8
|
or higher-order) from an `Expression` using a `Variable` whose index does not
|
|
@@ -12,6 +14,8 @@ class VariableOutOfRangeError(Exception):
|
|
|
12
14
|
- A raw index or tuple refers to a non-existent variable ID
|
|
13
15
|
"""
|
|
14
16
|
|
|
17
|
+
def __str__(self, /) -> str: ...
|
|
18
|
+
|
|
15
19
|
class VariableExistsError(Exception):
|
|
16
20
|
"""
|
|
17
21
|
Raised when trying to create a variable with a name that already exists.
|
|
@@ -20,10 +24,12 @@ class VariableExistsError(Exception):
|
|
|
20
24
|
a variable with the same name will raise this exception.
|
|
21
25
|
"""
|
|
22
26
|
|
|
27
|
+
def __str__(self, /) -> str: ...
|
|
28
|
+
|
|
23
29
|
class VariableNotExistingError(Exception):
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
"""Raised when trying to get a variable with a name that does not exist."""
|
|
31
|
+
|
|
32
|
+
def __str__(self, /) -> str: ...
|
|
27
33
|
|
|
28
34
|
class VariableCreationError(Exception):
|
|
29
35
|
"""
|
|
@@ -32,6 +38,8 @@ class VariableCreationError(Exception):
|
|
|
32
38
|
For example, binary and spin variables cannot be created with bounds.
|
|
33
39
|
"""
|
|
34
40
|
|
|
41
|
+
def __str__(self, /) -> str: ...
|
|
42
|
+
|
|
35
43
|
class VariablesFromDifferentEnvsError(Exception):
|
|
36
44
|
"""
|
|
37
45
|
Raised when multiple variables from different environments are used together.
|
|
@@ -40,6 +48,8 @@ class VariablesFromDifferentEnvsError(Exception):
|
|
|
40
48
|
`Environment`. Mixing across environments is disallowed to ensure consistency.
|
|
41
49
|
"""
|
|
42
50
|
|
|
51
|
+
def __str__(self, /) -> str: ...
|
|
52
|
+
|
|
43
53
|
class DifferentEnvsError(Exception):
|
|
44
54
|
"""
|
|
45
55
|
Raised when two incompatible environments are passed to a model or operation.
|
|
@@ -48,14 +58,20 @@ class DifferentEnvsError(Exception):
|
|
|
48
58
|
or in structural operations that require consistency across multiple environments.
|
|
49
59
|
"""
|
|
50
60
|
|
|
61
|
+
def __str__(self, /) -> str: ...
|
|
62
|
+
|
|
51
63
|
class NoActiveEnvironmentFoundError(Exception):
|
|
52
|
-
"""
|
|
53
|
-
|
|
64
|
+
"""Variable or Expression created without an environment (or context).
|
|
65
|
+
|
|
66
|
+
Raised when a variable or expression is created without an active environment
|
|
67
|
+
context.
|
|
54
68
|
|
|
55
69
|
This typically happens when not using `with Environment(): ...` and no environment
|
|
56
70
|
was explicitly provided.
|
|
57
71
|
"""
|
|
58
72
|
|
|
73
|
+
def __str__(self, /) -> str: ...
|
|
74
|
+
|
|
59
75
|
class MultipleActiveEnvironmentsError(Exception):
|
|
60
76
|
"""
|
|
61
77
|
Raised when multiple environments are active simultaneously.
|
|
@@ -64,6 +80,8 @@ class MultipleActiveEnvironmentsError(Exception):
|
|
|
64
80
|
at a time. This is enforced to maintain clarity and safety.
|
|
65
81
|
"""
|
|
66
82
|
|
|
83
|
+
def __str__(self, /) -> str: ...
|
|
84
|
+
|
|
67
85
|
class DecodeError(Exception):
|
|
68
86
|
"""
|
|
69
87
|
Raised when decoding or deserialization of binary data fails.
|
|
@@ -72,8 +90,11 @@ class DecodeError(Exception):
|
|
|
72
90
|
by `aqmodels.encode()`.
|
|
73
91
|
"""
|
|
74
92
|
|
|
93
|
+
def __str__(self, /) -> str: ...
|
|
94
|
+
|
|
75
95
|
class VariableNamesError(Exception):
|
|
76
|
-
"""
|
|
96
|
+
"""The provided variable names are invalid.
|
|
97
|
+
|
|
77
98
|
Raised when the QuboTranslator tries to create a model from a QUBO matrix, but
|
|
78
99
|
the provided variable names are invalid.
|
|
79
100
|
|
|
@@ -81,15 +102,17 @@ class VariableNamesError(Exception):
|
|
|
81
102
|
the number of names has to match the number of variables in the QUBO matrix.
|
|
82
103
|
"""
|
|
83
104
|
|
|
105
|
+
def __str__(self, /) -> str: ...
|
|
106
|
+
|
|
84
107
|
class IllegalConstraintNameError(Exception):
|
|
85
|
-
"""
|
|
86
|
-
|
|
87
|
-
|
|
108
|
+
"""Raised when a constraint is tried to be created with an illegal name."""
|
|
109
|
+
|
|
110
|
+
def __str__(self, /) -> str: ...
|
|
88
111
|
|
|
89
112
|
class TranslationError(Exception):
|
|
90
|
-
"""
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
"""Raised when an error occurred during translation."""
|
|
114
|
+
|
|
115
|
+
def __str__(self, /) -> str: ...
|
|
93
116
|
|
|
94
117
|
class ModelNotQuadraticError(TranslationError):
|
|
95
118
|
"""
|
|
@@ -99,16 +122,23 @@ class ModelNotQuadraticError(TranslationError):
|
|
|
99
122
|
expressions. This error signals that unsupported terms were detected.
|
|
100
123
|
"""
|
|
101
124
|
|
|
125
|
+
def __str__(self, /) -> str: ...
|
|
126
|
+
|
|
102
127
|
class ModelNotUnconstrainedError(TranslationError):
|
|
103
|
-
"""
|
|
104
|
-
|
|
128
|
+
"""Operation requires an unconstrained model.
|
|
129
|
+
|
|
130
|
+
Raised when an operation requires an unconstrained model, but constraints are
|
|
131
|
+
present.
|
|
105
132
|
|
|
106
133
|
Some solution methods may only work on unconstrained models, such as when
|
|
107
134
|
transforming a symbolic model to a low-level format.
|
|
108
135
|
"""
|
|
109
136
|
|
|
137
|
+
def __str__(self, /) -> str: ...
|
|
138
|
+
|
|
110
139
|
class ModelSenseNotMinimizeError(TranslationError):
|
|
111
|
-
"""
|
|
140
|
+
"""Operation requires a model for minimization.
|
|
141
|
+
|
|
112
142
|
Raised when an operation requires a model with minimization sense, but has
|
|
113
143
|
maximization sense.
|
|
114
144
|
|
|
@@ -117,8 +147,11 @@ class ModelSenseNotMinimizeError(TranslationError):
|
|
|
117
147
|
objective by `-1` if necessary.
|
|
118
148
|
"""
|
|
119
149
|
|
|
150
|
+
def __str__(self, /) -> str: ...
|
|
151
|
+
|
|
120
152
|
class ModelVtypeError(TranslationError):
|
|
121
|
-
"""
|
|
153
|
+
"""Operation has constraints on model's variable types.
|
|
154
|
+
|
|
122
155
|
Raised when an operation has certain constraints on a model's variable types that
|
|
123
156
|
are violated.
|
|
124
157
|
|
|
@@ -126,6 +159,8 @@ class ModelVtypeError(TranslationError):
|
|
|
126
159
|
type, or where only certain variable types are permitted.
|
|
127
160
|
"""
|
|
128
161
|
|
|
162
|
+
def __str__(self, /) -> str: ...
|
|
163
|
+
|
|
129
164
|
class SolutionTranslationError(Exception):
|
|
130
165
|
"""
|
|
131
166
|
Raised when something goes wrong during the translation of a solution.
|
|
@@ -135,6 +170,8 @@ class SolutionTranslationError(Exception):
|
|
|
135
170
|
consistent with the model the solution is created for.
|
|
136
171
|
"""
|
|
137
172
|
|
|
173
|
+
def __str__(self, /) -> str: ...
|
|
174
|
+
|
|
138
175
|
class SampleIncorrectLengthError(SolutionTranslationError):
|
|
139
176
|
"""
|
|
140
177
|
Raised when a sample length is different from the number of model variables.
|
|
@@ -144,8 +181,11 @@ class SampleIncorrectLengthError(SolutionTranslationError):
|
|
|
144
181
|
variables in the model environment that is passed to the translator.
|
|
145
182
|
"""
|
|
146
183
|
|
|
184
|
+
def __str__(self, /) -> str: ...
|
|
185
|
+
|
|
147
186
|
class SampleUnexpectedVariableError(SolutionTranslationError):
|
|
148
|
-
"""
|
|
187
|
+
"""Variable not present in environment.
|
|
188
|
+
|
|
149
189
|
Raised when a sample contains a variable with a name that is not present in the
|
|
150
190
|
environment.
|
|
151
191
|
|
|
@@ -153,8 +193,11 @@ class SampleUnexpectedVariableError(SolutionTranslationError):
|
|
|
153
193
|
contain the same variables as the sample.
|
|
154
194
|
"""
|
|
155
195
|
|
|
196
|
+
def __str__(self, /) -> str: ...
|
|
197
|
+
|
|
156
198
|
class SampleIncompatibleVtypeError(SolutionTranslationError):
|
|
157
|
-
"""
|
|
199
|
+
"""A sample's assignments have incompatible vtypes.
|
|
200
|
+
|
|
158
201
|
Raised when a sample's assignments have variable types incompatible with the
|
|
159
202
|
model's variable types.
|
|
160
203
|
|
|
@@ -166,20 +209,34 @@ class SampleIncompatibleVtypeError(SolutionTranslationError):
|
|
|
166
209
|
conversions of variables outside the permitted range will fail.
|
|
167
210
|
"""
|
|
168
211
|
|
|
212
|
+
def __str__(self, /) -> str: ...
|
|
213
|
+
|
|
169
214
|
class ComputationError(Exception):
|
|
170
|
-
"""
|
|
171
|
-
|
|
172
|
-
|
|
215
|
+
"""Raised when an error occured in an internal computation."""
|
|
216
|
+
|
|
217
|
+
def __str__(self, /) -> str: ...
|
|
173
218
|
|
|
174
219
|
class EvaluationError(Exception):
|
|
175
|
-
"""
|
|
176
|
-
|
|
177
|
-
|
|
220
|
+
"""Raised when an error occured during evaluation of a model."""
|
|
221
|
+
|
|
222
|
+
def __str__(self, /) -> str: ...
|
|
223
|
+
|
|
224
|
+
class DuplicateConstraintNameError(Exception):
|
|
225
|
+
"""Raised when a duplicate constraint name is used."""
|
|
226
|
+
|
|
227
|
+
def __str__(self, /) -> str: ...
|
|
228
|
+
|
|
229
|
+
class CompilationError(Exception):
|
|
230
|
+
"""Raised when an error occured during compilation of a model in the PassManager."""
|
|
231
|
+
|
|
232
|
+
def __str__(self, /) -> str: ...
|
|
178
233
|
|
|
179
234
|
__all__ = [
|
|
235
|
+
"ComputationError",
|
|
180
236
|
"ComputationError",
|
|
181
237
|
"DecodeError",
|
|
182
238
|
"DifferentEnvsError",
|
|
239
|
+
"DuplicateConstraintNameError",
|
|
183
240
|
"EvaluationError",
|
|
184
241
|
"IllegalConstraintNameError",
|
|
185
242
|
"ModelNotQuadraticError",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
1
|
from logging import Logger
|
|
3
2
|
from typing import ClassVar, Literal
|
|
4
3
|
|
|
@@ -10,6 +9,7 @@ from luna_quantum.client.interfaces.services.luna_solve_i import ILunaSolve
|
|
|
10
9
|
from luna_quantum.client.schemas.enums.call_style import CallStyle
|
|
11
10
|
from luna_quantum.client.schemas.enums.model_format import ModelFormat
|
|
12
11
|
from luna_quantum.client.schemas.enums.status import StatusEnum
|
|
12
|
+
from luna_quantum.client.schemas.wrappers import PydanticDatetimeWrapper
|
|
13
13
|
from luna_quantum.factories.luna_solve_client_factory import LunaSolveClientFactory
|
|
14
14
|
from luna_quantum.util.log_utils import Logging
|
|
15
15
|
|
|
@@ -20,7 +20,7 @@ class SolveJob(BaseModel):
|
|
|
20
20
|
_logger: ClassVar[Logger] = Logging.get_logger(__name__)
|
|
21
21
|
id: str
|
|
22
22
|
status: StatusEnum
|
|
23
|
-
status_timeline: dict[StatusEnum,
|
|
23
|
+
status_timeline: dict[StatusEnum, PydanticDatetimeWrapper]
|
|
24
24
|
error_message: str | None = None
|
|
25
25
|
solver_job_info: str | None = None
|
|
26
26
|
used_format: ModelFormat | None = None
|
|
@@ -69,6 +69,7 @@ class QuantumAnnealingParams(BaseModel):
|
|
|
69
69
|
flux_biases: list[float] | None = None
|
|
70
70
|
flux_drift_compensation: bool = True
|
|
71
71
|
h_gain_schedule: list[tuple[float, float]] | None = None
|
|
72
|
+
|
|
72
73
|
initial_state: list[int] | None = None
|
|
73
74
|
max_answers: int | None = Field(default=None, ge=1)
|
|
74
75
|
num_reads: int = Field(default=1, ge=1)
|
|
@@ -41,14 +41,16 @@ ScipyOptimizerMethod = Literal[
|
|
|
41
41
|
class ScipyOptimizerParams(BaseModel):
|
|
42
42
|
"""Wrapper for scipy.optimize.minimize.
|
|
43
43
|
|
|
44
|
-
See
|
|
44
|
+
See [SciPy minimize documentation](
|
|
45
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html)
|
|
45
46
|
for more information of the available methods and parameters.
|
|
46
47
|
|
|
47
48
|
Attributes
|
|
48
49
|
----------
|
|
49
50
|
method: ScipyOptimizerMethod
|
|
50
51
|
Type of solver. See
|
|
51
|
-
|
|
52
|
+
[SciPy minimize documentation](
|
|
53
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html)
|
|
52
54
|
for supported methods.
|
|
53
55
|
tol: float | None
|
|
54
56
|
Tolerance for termination.
|
|
@@ -26,37 +26,53 @@ class QuantumAnnealing(QuantumAnnealingParams, LunaAlgorithm[DWaveQpu]):
|
|
|
26
26
|
|
|
27
27
|
Attributes
|
|
28
28
|
----------
|
|
29
|
-
anneal_offsets:
|
|
30
|
-
Per-qubit time offsets for the annealing path
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Whether to automatically normalize the problem energy range.
|
|
29
|
+
anneal_offsets: list[float] | None
|
|
30
|
+
Per-qubit time offsets for the annealing path in normalized annealing time
|
|
31
|
+
units. List of floats with length equal to the number of qubits. Default is
|
|
32
|
+
None.
|
|
33
|
+
anneal_schedule: list[tuple[float, float]] | None
|
|
34
|
+
Custom schedule for the annealing process as a list of (time, s) pairs.
|
|
35
|
+
Time is in normalized units [0, 1] and s is the annealing parameter [0, 1].
|
|
37
36
|
Default is None.
|
|
37
|
+
annealing_time: float | None
|
|
38
|
+
Duration of the annealing process in microseconds. Must be within the range
|
|
39
|
+
supported by the QPU hardware. Default is None.
|
|
40
|
+
auto_scale: bool | None
|
|
41
|
+
Whether to automatically normalize the problem energy range to use the full
|
|
42
|
+
range of h and J values supported by the hardware. Default is None.
|
|
38
43
|
fast_anneal: bool
|
|
39
|
-
Use accelerated annealing protocol. Default is
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
Use accelerated annealing protocol for shorter annealing times. Default is
|
|
45
|
+
False.
|
|
46
|
+
flux_biases: list[float] | None
|
|
47
|
+
Custom flux bias offsets for each qubit in units of Φ₀ (flux quantum).
|
|
48
|
+
List length must equal the number of qubits. Default is None.
|
|
42
49
|
flux_drift_compensation: bool
|
|
43
|
-
Whether to compensate for drift in qubit flux over time
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
Whether to compensate for drift in qubit flux over time using real-time
|
|
51
|
+
calibration data. Default is True.
|
|
52
|
+
h_gain_schedule: list[tuple[float, float]] | None
|
|
53
|
+
Schedule for h-gain during annealing as a list of (time, gain) pairs.
|
|
54
|
+
Time is in normalized units [0, 1]. Default is None.
|
|
55
|
+
initial_state: list[int] | None
|
|
56
|
+
Starting state for the annealing process. List of {-1, +1} values with
|
|
57
|
+
length equal to the number of qubits. Default is None.
|
|
48
58
|
max_answers: int | None
|
|
49
|
-
Maximum number of unique answer states to return.
|
|
59
|
+
Maximum number of unique answer states to return. Must be ≤ num_reads.
|
|
60
|
+
Default is None.
|
|
50
61
|
num_reads: int
|
|
51
|
-
Number of annealing cycles to perform.
|
|
62
|
+
Number of annealing cycles to perform. Must be positive integer.
|
|
63
|
+
Default is 1.
|
|
52
64
|
programming_thermalization: float | None
|
|
53
|
-
Wait time after programming the QPU
|
|
65
|
+
Wait time after programming the QPU in microseconds to allow the system
|
|
66
|
+
to thermalize. Default is None.
|
|
54
67
|
readout_thermalization: float | None
|
|
55
|
-
Wait time after each anneal before reading results
|
|
68
|
+
Wait time after each anneal before reading results in microseconds.
|
|
69
|
+
Default is None.
|
|
56
70
|
reduce_intersample_correlation: bool
|
|
57
|
-
Whether to add delay between samples
|
|
71
|
+
Whether to add delay between samples to reduce correlation between
|
|
72
|
+
consecutive measurements. Default is False.
|
|
58
73
|
reinitialize_state: bool | None
|
|
59
|
-
Whether to reset to a new initial state between reads
|
|
74
|
+
Whether to reset to a new initial state between reads to reduce correlation.
|
|
75
|
+
Default is None.
|
|
60
76
|
"""
|
|
61
77
|
|
|
62
78
|
@property
|
|
@@ -14,14 +14,16 @@ class LinearOptimizerParams(ScipyOptimizerParams):
|
|
|
14
14
|
ScipyOptimizer.
|
|
15
15
|
|
|
16
16
|
Wrapper for scipy.optimize.minimize. See
|
|
17
|
-
|
|
17
|
+
[SciPy minimize documentation](
|
|
18
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html)
|
|
18
19
|
for more information of the available methods and parameters.
|
|
19
20
|
|
|
20
21
|
Attributes
|
|
21
22
|
----------
|
|
22
23
|
method: ScipyOptimizerMethod
|
|
23
24
|
Type of solver. See
|
|
24
|
-
|
|
25
|
+
[SciPy minimize documentation](
|
|
26
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html)
|
|
25
27
|
for supported methods.
|
|
26
28
|
tol: float | None
|
|
27
29
|
Tolerance for termination.
|