qilisdk 0.1.1__py3-none-any.whl → 0.1.2__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.
- qilisdk/digital/ansatz.py +18 -1
- qilisdk/digital/vqe.py +1 -0
- qilisdk/extras/qaas/models.py +76 -1
- qilisdk/extras/qaas/qaas_backend.py +118 -18
- qilisdk/extras/qaas/qaas_time_evolution_result.py +20 -0
- qilisdk/extras/qaas/qaas_vqe_result.py +20 -0
- qilisdk/yaml.py +34 -2
- {qilisdk-0.1.1.dist-info → qilisdk-0.1.2.dist-info}/METADATA +1 -1
- {qilisdk-0.1.1.dist-info → qilisdk-0.1.2.dist-info}/RECORD +11 -9
- {qilisdk-0.1.1.dist-info → qilisdk-0.1.2.dist-info}/WHEEL +0 -0
- {qilisdk-0.1.1.dist-info → qilisdk-0.1.2.dist-info}/licenses/LICENCE +0 -0
qilisdk/digital/ansatz.py
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
from abc import ABC, abstractmethod
|
|
15
|
-
from typing import ClassVar, Literal, Union
|
|
15
|
+
from typing import Any, ClassVar, Literal, Union
|
|
16
16
|
|
|
17
17
|
from qilisdk.digital.circuit import Circuit
|
|
18
18
|
from qilisdk.digital.gates import CNOT, CZ, U1, U2, U3, M
|
|
@@ -103,6 +103,23 @@ class HardwareEfficientAnsatz(Ansatz):
|
|
|
103
103
|
"grouped": self._construct_layer_grouped,
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
def __getstate__(self) -> dict[str, Any]:
|
|
107
|
+
state = self.__dict__.copy()
|
|
108
|
+
# Exclude the mapping that contains bound methods (not serializable).
|
|
109
|
+
state.pop("construct_layer_handlers", None)
|
|
110
|
+
return state
|
|
111
|
+
|
|
112
|
+
def __setstate__(self, state) -> None: # noqa: ANN001
|
|
113
|
+
"""
|
|
114
|
+
Restore the object's state after deserialization and reinitialize any attributes that were omitted.
|
|
115
|
+
"""
|
|
116
|
+
self.__dict__.update(state)
|
|
117
|
+
# Reconstruct the mapping with the proper bound methods.
|
|
118
|
+
self.construct_layer_handlers = {
|
|
119
|
+
"interposed": self._construct_layer_interposed,
|
|
120
|
+
"grouped": self._construct_layer_grouped,
|
|
121
|
+
}
|
|
122
|
+
|
|
106
123
|
@property
|
|
107
124
|
def nparameters(self) -> int:
|
|
108
125
|
"""
|
qilisdk/digital/vqe.py
CHANGED
qilisdk/extras/qaas/models.py
CHANGED
|
@@ -16,9 +16,20 @@ from enum import Enum
|
|
|
16
16
|
|
|
17
17
|
from pydantic import BaseModel, ConfigDict, Field
|
|
18
18
|
|
|
19
|
+
from qilisdk.analog import Hamiltonian, QuantumObject, Schedule, TimeEvolution
|
|
20
|
+
from qilisdk.analog.hamiltonian import PauliOperator
|
|
21
|
+
from qilisdk.common.optimizer import Optimizer
|
|
22
|
+
from qilisdk.digital import VQE, Circuit
|
|
23
|
+
from qilisdk.yaml import yaml
|
|
24
|
+
|
|
25
|
+
from .qaas_analog_result import QaaSAnalogResult
|
|
26
|
+
from .qaas_digital_result import QaaSDigitalResult
|
|
27
|
+
from .qaas_time_evolution_result import QaaSTimeEvolutionResult
|
|
28
|
+
from .qaas_vqe_result import QaaSVQEResult
|
|
29
|
+
|
|
19
30
|
|
|
20
31
|
class QaaSModel(BaseModel):
|
|
21
|
-
model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)
|
|
32
|
+
model_config = ConfigDict(validate_by_name=True, validate_by_alias=True, arbitrary_types_allowed=True)
|
|
22
33
|
|
|
23
34
|
|
|
24
35
|
class LoginPayload(BaseModel): ...
|
|
@@ -51,7 +62,71 @@ class DeviceStatus(str, Enum):
|
|
|
51
62
|
OFFLINE = "offline"
|
|
52
63
|
|
|
53
64
|
|
|
65
|
+
class DeviceType(str, Enum):
|
|
66
|
+
"""Device type"""
|
|
67
|
+
|
|
68
|
+
QUANTUM_DIGITAL = "quantum_device"
|
|
69
|
+
QUANTUM_ANALOG = "quantum_analog_device"
|
|
70
|
+
SIMULATOR = "simulator_device"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@yaml.register_class
|
|
54
74
|
class Device(QaaSModel):
|
|
55
75
|
id: int = Field(...)
|
|
56
76
|
name: str = Field(...)
|
|
57
77
|
status: DeviceStatus = Field(...)
|
|
78
|
+
type: DeviceType = Field(...)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class ExecutePayloadType(str, Enum):
|
|
82
|
+
DIGITAL = "digital"
|
|
83
|
+
ANALOG = "analog"
|
|
84
|
+
VQE = "vqe"
|
|
85
|
+
TIME_EVOLUTION = "time_evolution"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@yaml.register_class
|
|
89
|
+
class DigitalPayload(QaaSModel):
|
|
90
|
+
circuit: Circuit = Field(...)
|
|
91
|
+
nshots: int = Field(...)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@yaml.register_class
|
|
95
|
+
class AnalogPayload(QaaSModel):
|
|
96
|
+
schedule: Schedule = Field(...)
|
|
97
|
+
initial_state: QuantumObject = Field(...)
|
|
98
|
+
observables: list[PauliOperator | Hamiltonian] = Field(...)
|
|
99
|
+
store_intermediate_results: bool = Field(...)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@yaml.register_class
|
|
103
|
+
class VQEPayload(QaaSModel):
|
|
104
|
+
vqe: VQE = Field(...)
|
|
105
|
+
optimizer: Optimizer = Field(...)
|
|
106
|
+
nshots: int = Field(...)
|
|
107
|
+
store_intermediate_results: bool = Field(...)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@yaml.register_class
|
|
111
|
+
class TimeEvolutionPayload(QaaSModel):
|
|
112
|
+
time_evolution: TimeEvolution = Field()
|
|
113
|
+
store_intermediate_results: bool = Field()
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@yaml.register_class
|
|
117
|
+
class ExecutePayload(QaaSModel):
|
|
118
|
+
type: ExecutePayloadType = Field(...)
|
|
119
|
+
device_id: int = Field(...)
|
|
120
|
+
digital_payload: DigitalPayload | None = None
|
|
121
|
+
analog_payload: AnalogPayload | None = None
|
|
122
|
+
vqe_payload: VQEPayload | None = None
|
|
123
|
+
time_evolution_payload: TimeEvolutionPayload | None = None
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@yaml.register_class
|
|
127
|
+
class ExecuteResponse(QaaSModel):
|
|
128
|
+
type: ExecutePayloadType = Field(...)
|
|
129
|
+
digital_result: QaaSDigitalResult | None = None
|
|
130
|
+
analog_result: QaaSAnalogResult | None = None
|
|
131
|
+
vqe_result: QaaSVQEResult | None = None
|
|
132
|
+
time_evolution_result: QaaSTimeEvolutionResult | None = None
|
|
@@ -17,27 +17,38 @@ import json
|
|
|
17
17
|
import logging
|
|
18
18
|
from base64 import urlsafe_b64encode
|
|
19
19
|
from datetime import datetime, timezone
|
|
20
|
-
from typing import TYPE_CHECKING
|
|
20
|
+
from typing import TYPE_CHECKING, cast
|
|
21
21
|
|
|
22
22
|
import httpx
|
|
23
|
-
from pydantic import ValidationError
|
|
23
|
+
from pydantic import TypeAdapter, ValidationError
|
|
24
24
|
|
|
25
25
|
from qilisdk.analog.analog_backend import AnalogBackend
|
|
26
26
|
from qilisdk.digital.digital_backend import DigitalBackend
|
|
27
27
|
|
|
28
28
|
from .keyring import delete_credentials, load_credentials, store_credentials
|
|
29
|
-
from .models import
|
|
29
|
+
from .models import (
|
|
30
|
+
AnalogPayload,
|
|
31
|
+
Device,
|
|
32
|
+
DigitalPayload,
|
|
33
|
+
ExecutePayload,
|
|
34
|
+
ExecutePayloadType,
|
|
35
|
+
ExecuteResponse,
|
|
36
|
+
TimeEvolutionPayload,
|
|
37
|
+
Token,
|
|
38
|
+
VQEPayload,
|
|
39
|
+
)
|
|
30
40
|
from .qaas_settings import QaaSSettings
|
|
31
41
|
|
|
32
42
|
if TYPE_CHECKING:
|
|
33
|
-
from qilisdk.analog
|
|
34
|
-
from qilisdk.analog.
|
|
35
|
-
from qilisdk.
|
|
36
|
-
from qilisdk.
|
|
37
|
-
from qilisdk.digital.circuit import Circuit
|
|
43
|
+
from qilisdk.analog import Hamiltonian, QuantumObject, Schedule, TimeEvolution
|
|
44
|
+
from qilisdk.analog.hamiltonian import PauliOperator
|
|
45
|
+
from qilisdk.common.optimizer import Optimizer
|
|
46
|
+
from qilisdk.digital import VQE, Circuit
|
|
38
47
|
|
|
39
48
|
from .qaas_analog_result import QaaSAnalogResult
|
|
40
49
|
from .qaas_digital_result import QaaSDigitalResult
|
|
50
|
+
from .qaas_time_evolution_result import QaaSTimeEvolutionResult
|
|
51
|
+
from .qaas_vqe_result import QaaSVQEResult
|
|
41
52
|
|
|
42
53
|
logging.basicConfig(
|
|
43
54
|
format="%(levelname)s [%(asctime)s] %(name)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S", level=logging.DEBUG
|
|
@@ -55,8 +66,6 @@ class QaaSBackend(DigitalBackend, AnalogBackend):
|
|
|
55
66
|
"""
|
|
56
67
|
|
|
57
68
|
_api_url: str = "https://qilimanjaroqaas.ddns.net:8080/api/v1"
|
|
58
|
-
_authorization_request_url: str = "https://qilimanjaroqaas.ddns.net:8080/api/v1/authorisation-tokens"
|
|
59
|
-
_authorization_refresh_url: str = "https://qilimanjaroqaas.ddns.net:8080/api/v1/authorisation-tokens/refresh"
|
|
60
69
|
|
|
61
70
|
def __init__(self) -> None:
|
|
62
71
|
"""
|
|
@@ -70,6 +79,14 @@ class QaaSBackend(DigitalBackend, AnalogBackend):
|
|
|
70
79
|
"Please call QaaSBackend.login(username, apikey) or ensure environment variables are set."
|
|
71
80
|
)
|
|
72
81
|
self._username, self._token = credentials
|
|
82
|
+
self._selected_device: Device | None = None
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def selected_device(self) -> Device | None:
|
|
86
|
+
return self._selected_device
|
|
87
|
+
|
|
88
|
+
def set_device(self, device: Device) -> None:
|
|
89
|
+
self._selected_device = device
|
|
73
90
|
|
|
74
91
|
@classmethod
|
|
75
92
|
def login(
|
|
@@ -105,7 +122,7 @@ class QaaSBackend(DigitalBackend, AnalogBackend):
|
|
|
105
122
|
encoded_assertion = urlsafe_b64encode(json.dumps(assertion, indent=2).encode("utf-8")).decode("utf-8")
|
|
106
123
|
with httpx.Client(timeout=10.0) as client:
|
|
107
124
|
response = client.post(
|
|
108
|
-
QaaSBackend.
|
|
125
|
+
QaaSBackend._api_url + "/authorisation-tokens",
|
|
109
126
|
json={
|
|
110
127
|
"grantType": "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
|
111
128
|
"assertion": encoded_assertion,
|
|
@@ -134,12 +151,37 @@ class QaaSBackend(DigitalBackend, AnalogBackend):
|
|
|
134
151
|
headers={"X-Client-Version": "0.23.2", "Authorization": f"Bearer {self._token.access_token}"},
|
|
135
152
|
)
|
|
136
153
|
response.raise_for_status()
|
|
137
|
-
|
|
138
|
-
|
|
154
|
+
|
|
155
|
+
devices_list_adapter = TypeAdapter(list[Device])
|
|
156
|
+
devices = devices_list_adapter.validate_python(response.json()["items"])
|
|
157
|
+
|
|
158
|
+
# Previous two lines are the same as doing:
|
|
159
|
+
# response_json = response.json()
|
|
160
|
+
# devices = [Device(**item) for item in response_json["items"]]
|
|
161
|
+
|
|
139
162
|
return devices
|
|
140
163
|
|
|
164
|
+
def _ensure_device_selected(self) -> Device:
|
|
165
|
+
if self._selected_device is None:
|
|
166
|
+
raise ValueError("Device not selected.")
|
|
167
|
+
return self._selected_device
|
|
168
|
+
|
|
141
169
|
def execute(self, circuit: Circuit, nshots: int = 1000) -> QaaSDigitalResult:
|
|
142
|
-
|
|
170
|
+
device = self._ensure_device_selected()
|
|
171
|
+
payload = ExecutePayload(
|
|
172
|
+
type=ExecutePayloadType.DIGITAL,
|
|
173
|
+
device_id=device.id,
|
|
174
|
+
digital_payload=DigitalPayload(circuit=circuit, nshots=nshots),
|
|
175
|
+
)
|
|
176
|
+
with httpx.Client(timeout=20.0) as client:
|
|
177
|
+
response = client.post(
|
|
178
|
+
QaaSBackend._api_url + "/execute",
|
|
179
|
+
headers={"X-Client-Version": "0.23.2", "Authorization": f"Bearer {self._token.access_token}"},
|
|
180
|
+
json=payload.model_dump_json(),
|
|
181
|
+
)
|
|
182
|
+
response.raise_for_status()
|
|
183
|
+
execute_response = ExecuteResponse(**response.json())
|
|
184
|
+
return cast("QaaSDigitalResult", execute_response.digital_result)
|
|
143
185
|
|
|
144
186
|
def evolve(
|
|
145
187
|
self,
|
|
@@ -148,7 +190,65 @@ class QaaSBackend(DigitalBackend, AnalogBackend):
|
|
|
148
190
|
observables: list[PauliOperator | Hamiltonian],
|
|
149
191
|
store_intermediate_results: bool = False,
|
|
150
192
|
) -> QaaSAnalogResult:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
193
|
+
device = self._ensure_device_selected()
|
|
194
|
+
payload = ExecutePayload(
|
|
195
|
+
type=ExecutePayloadType.ANALOG,
|
|
196
|
+
device_id=device.id,
|
|
197
|
+
analog_payload=AnalogPayload(
|
|
198
|
+
schedule=schedule,
|
|
199
|
+
initial_state=initial_state,
|
|
200
|
+
observables=observables,
|
|
201
|
+
store_intermediate_results=store_intermediate_results,
|
|
202
|
+
),
|
|
203
|
+
)
|
|
204
|
+
with httpx.Client(timeout=20.0) as client:
|
|
205
|
+
response = client.post(
|
|
206
|
+
QaaSBackend._api_url + "/execute",
|
|
207
|
+
headers={"X-Client-Version": "0.23.2", "Authorization": f"Bearer {self._token.access_token}"},
|
|
208
|
+
json=payload.model_dump_json(),
|
|
209
|
+
)
|
|
210
|
+
response.raise_for_status()
|
|
211
|
+
execute_response = ExecuteResponse(**response.json())
|
|
212
|
+
return cast("QaaSAnalogResult", execute_response.analog_result)
|
|
213
|
+
|
|
214
|
+
def run_vqe(
|
|
215
|
+
self, vqe: VQE, optimizer: Optimizer, nshots: int = 1000, store_intermediate_results: bool = False
|
|
216
|
+
) -> QaaSVQEResult:
|
|
217
|
+
device = self._ensure_device_selected()
|
|
218
|
+
payload = ExecutePayload(
|
|
219
|
+
type=ExecutePayloadType.VQE,
|
|
220
|
+
device_id=device.id,
|
|
221
|
+
vqe_payload=VQEPayload(
|
|
222
|
+
vqe=vqe, optimizer=optimizer, nshots=nshots, store_intermediate_results=store_intermediate_results
|
|
223
|
+
),
|
|
224
|
+
)
|
|
225
|
+
with httpx.Client(timeout=20.0) as client:
|
|
226
|
+
response = client.post(
|
|
227
|
+
QaaSBackend._api_url + "/execute",
|
|
228
|
+
headers={"X-Client-Version": "0.23.2", "Authorization": f"Bearer {self._token.access_token}"},
|
|
229
|
+
json=payload.model_dump_json(),
|
|
230
|
+
)
|
|
231
|
+
response.raise_for_status()
|
|
232
|
+
execute_response = ExecuteResponse(**response.json())
|
|
233
|
+
return cast("QaaSVQEResult", execute_response.vqe_result)
|
|
234
|
+
|
|
235
|
+
def run_time_evolution(
|
|
236
|
+
self, time_evolution: TimeEvolution, store_intermediate_results: bool = False
|
|
237
|
+
) -> QaaSTimeEvolutionResult:
|
|
238
|
+
device = self._ensure_device_selected()
|
|
239
|
+
payload = ExecutePayload(
|
|
240
|
+
type=ExecutePayloadType.TIME_EVOLUTION,
|
|
241
|
+
device_id=device.id,
|
|
242
|
+
time_evolution_payload=TimeEvolutionPayload(
|
|
243
|
+
time_evolution=time_evolution, store_intermediate_results=store_intermediate_results
|
|
244
|
+
),
|
|
245
|
+
)
|
|
246
|
+
with httpx.Client(timeout=20.0) as client:
|
|
247
|
+
response = client.post(
|
|
248
|
+
QaaSBackend._api_url + "/execute",
|
|
249
|
+
headers={"X-Client-Version": "0.23.2", "Authorization": f"Bearer {self._token.access_token}"},
|
|
250
|
+
json=payload.model_dump_json(),
|
|
251
|
+
)
|
|
252
|
+
response.raise_for_status()
|
|
253
|
+
execute_response = ExecuteResponse(**response.json())
|
|
254
|
+
return cast("QaaSTimeEvolutionResult", execute_response.time_evolution_result)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Copyright 2025 Qilimanjaro Quantum Tech
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from qilisdk.analog.analog_result import AnalogResult
|
|
16
|
+
from qilisdk.yaml import yaml
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@yaml.register_class
|
|
20
|
+
class QaaSTimeEvolutionResult(AnalogResult): ...
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Copyright 2025 Qilimanjaro Quantum Tech
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from qilisdk.digital.vqe import VQEResult
|
|
16
|
+
from qilisdk.yaml import yaml
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@yaml.register_class
|
|
20
|
+
class QaaSVQEResult(VQEResult): ...
|
qilisdk/yaml.py
CHANGED
|
@@ -19,6 +19,7 @@ import types
|
|
|
19
19
|
|
|
20
20
|
import numpy as np
|
|
21
21
|
from dill import dumps, loads
|
|
22
|
+
from pydantic import BaseModel
|
|
22
23
|
from ruamel.yaml import YAML
|
|
23
24
|
|
|
24
25
|
|
|
@@ -39,7 +40,7 @@ def ndarray_constructor(constructor, node):
|
|
|
39
40
|
|
|
40
41
|
def function_representer(representer, data):
|
|
41
42
|
"""Represent a non-lambda function by serializing it."""
|
|
42
|
-
serialized_function = base64.b64encode(dumps(data)).decode("utf-8")
|
|
43
|
+
serialized_function = base64.b64encode(dumps(data, recurse=True)).decode("utf-8")
|
|
43
44
|
return representer.represent_scalar("!function", serialized_function)
|
|
44
45
|
|
|
45
46
|
|
|
@@ -51,7 +52,7 @@ def function_constructor(constructor, node):
|
|
|
51
52
|
|
|
52
53
|
def lambda_representer(representer, data):
|
|
53
54
|
"""Represent a lambda function by serializing its code."""
|
|
54
|
-
serialized_lambda = base64.b64encode(dumps(data)).decode("utf-8")
|
|
55
|
+
serialized_lambda = base64.b64encode(dumps(data, recurse=True)).decode("utf-8")
|
|
55
56
|
return representer.represent_scalar("!lambda", serialized_lambda)
|
|
56
57
|
|
|
57
58
|
|
|
@@ -62,6 +63,33 @@ def lambda_constructor(constructor, node):
|
|
|
62
63
|
return loads(serialized_lambda) # noqa: S301
|
|
63
64
|
|
|
64
65
|
|
|
66
|
+
def pydantic_model_representer(representer, data):
|
|
67
|
+
"""Representer for Pydantic Models."""
|
|
68
|
+
value = {"type": f"{data.__class__.__module__}.{data.__class__.__name__}", "data": data.model_dump()}
|
|
69
|
+
return representer.represent_mapping("!PydanticModel", value)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def pydantic_model_constructor(constructor, node):
|
|
73
|
+
"""Constructor for Pydantic Models."""
|
|
74
|
+
mapping = constructor.construct_mapping(node, deep=True)
|
|
75
|
+
model_type_str = mapping["type"]
|
|
76
|
+
data = mapping["data"]
|
|
77
|
+
module_name, class_name = model_type_str.rsplit(".", 1)
|
|
78
|
+
mod = __import__(module_name, fromlist=[class_name])
|
|
79
|
+
model_cls = getattr(mod, class_name)
|
|
80
|
+
return model_cls.model_validate(data)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def complex_representer(representer, data: complex):
|
|
84
|
+
value = {"real": data.real, "imag": data.imag}
|
|
85
|
+
return representer.represent_mapping("!complex", value)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def complex_constructor(constructor, node):
|
|
89
|
+
mapping = constructor.construct_mapping(node, deep=True)
|
|
90
|
+
return complex(mapping["real"], mapping["imag"])
|
|
91
|
+
|
|
92
|
+
|
|
65
93
|
yaml = YAML(typ="unsafe")
|
|
66
94
|
yaml.representer.add_representer(np.ndarray, ndarray_representer)
|
|
67
95
|
yaml.constructor.add_constructor("!ndarray", ndarray_constructor)
|
|
@@ -69,3 +97,7 @@ yaml.representer.add_representer(types.FunctionType, function_representer)
|
|
|
69
97
|
yaml.constructor.add_constructor("!function", function_constructor)
|
|
70
98
|
yaml.representer.add_representer(types.LambdaType, lambda_representer)
|
|
71
99
|
yaml.constructor.add_constructor("!lambda", lambda_constructor)
|
|
100
|
+
yaml.representer.add_representer(BaseModel, pydantic_model_representer)
|
|
101
|
+
yaml.constructor.add_constructor("!PydanticModel", pydantic_model_constructor)
|
|
102
|
+
yaml.representer.add_representer(complex, complex_representer)
|
|
103
|
+
yaml.constructor.add_constructor("!complex", complex_constructor)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: qilisdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: qilisdk is a Python framework for writing digital and analog quantum algorithms and executing them across multiple quantum backends. Its modular design streamlines the development process and enables easy integration with a variety of quantum platforms.
|
|
5
5
|
Author-email: Qilimanjaro Quantum Tech <info@qilimanjaro.tech>
|
|
6
6
|
License-File: LICENCE
|
|
@@ -2,7 +2,7 @@ qilisdk/__init__.py,sha256=iwacKJYttlh9DgQgNmnAjkU9CyjDQG42X3gr9Dg1kME,710
|
|
|
2
2
|
qilisdk/__init__.pyi,sha256=iwacKJYttlh9DgQgNmnAjkU9CyjDQG42X3gr9Dg1kME,710
|
|
3
3
|
qilisdk/_optionals.py,sha256=gl6yZ2sROY-USvNkXy6964OBOrDNKJAIyBU8D2H13z4,3594
|
|
4
4
|
qilisdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
qilisdk/yaml.py,sha256=
|
|
5
|
+
qilisdk/yaml.py,sha256=QTDiLB8-3GWOfFKxvKwfEtJjTYXRxGP3ldUAEERB51E,4055
|
|
6
6
|
qilisdk/analog/__init__.py,sha256=ExHaNL6pYH9HPY1ahskbPHqVyN9BnH8_ZxLCBS1HYp0,974
|
|
7
7
|
qilisdk/analog/algorithms.py,sha256=OiQma6y5ueNE1buXXbNexme1k1aQaIg1A00C6mX10JQ,4621
|
|
8
8
|
qilisdk/analog/analog_backend.py,sha256=GRCqlCslo8F0iB8N6Mn-_0IFJos6xRbadwVvk3lYilc,1753
|
|
@@ -19,14 +19,14 @@ qilisdk/common/optimizer.py,sha256=jIBntTMw5qw03RRp5gzQe4BO9bh_z3Oeh_qfwbot0bI,5
|
|
|
19
19
|
qilisdk/common/optimizer_result.py,sha256=Xqrej4QfuDofya-MpyfXm-FIlJqrCu7worio5oqb3rQ,3990
|
|
20
20
|
qilisdk/common/result.py,sha256=wgNCC_M0eQMArWl5nmDc0-1N5IvW1sxSnIZa7_OllCE,633
|
|
21
21
|
qilisdk/digital/__init__.py,sha256=vAk9BGKUxKc5faOppR64kUnJxV2WKxJK_FGpGyxuheY,1144
|
|
22
|
-
qilisdk/digital/ansatz.py,sha256=
|
|
22
|
+
qilisdk/digital/ansatz.py,sha256=TG-GMDDb8v2WjkynhTRgHp5OUkGborLI4rmPAf33FPs,6546
|
|
23
23
|
qilisdk/digital/circuit.py,sha256=ruE1bJJkJrCKQgbBYU0-sNHWwEI1QKiUbK76owjb32M,3628
|
|
24
24
|
qilisdk/digital/digital_algorithm.py,sha256=ncrmqd_y__1aaOA5ttOLlwCNyIBNdEpBazLapVa54-w,744
|
|
25
25
|
qilisdk/digital/digital_backend.py,sha256=PH514eEEjPAo3R_JnzsG4DVrwssIMzWHJFjcpT440TU,3393
|
|
26
26
|
qilisdk/digital/digital_result.py,sha256=PmqVOp4W1COZOFYcROxuLG7WAYjBAB6EM5BeY0J-eRY,5293
|
|
27
27
|
qilisdk/digital/exceptions.py,sha256=21RnaSBkzZOuQWcIWVB303F4nyU1ABOykhAYow4m7lA,871
|
|
28
28
|
qilisdk/digital/gates.py,sha256=Ylf9iwDNONaatzIrrPpXi6H59C7bMvrq-tWyIK5ZykU,29614
|
|
29
|
-
qilisdk/digital/vqe.py,sha256=
|
|
29
|
+
qilisdk/digital/vqe.py,sha256=HdxueeBO6MQYKyy8xo2_x50hqHd693RPvXaxEFIcEJI,6648
|
|
30
30
|
qilisdk/extras/__init__.py,sha256=kki6xpa5TInawohC_vNacHZ4UAWxrEoK_lpl5eUkRpk,1543
|
|
31
31
|
qilisdk/extras/__init__.pyi,sha256=xQ4zOPeSaNM5zGfb07fK4lcbAu4y95YfgSlHs5TkR3Y,717
|
|
32
32
|
qilisdk/extras/cuda/__init__.py,sha256=LDSTo7NstSbHMvvqvx7ZLxh0HFTEXg1O_B76SyEEHk8,588
|
|
@@ -35,15 +35,17 @@ qilisdk/extras/cuda/cuda_backend.py,sha256=ew8Dethe1bIFrSRd0rv-cl7joozrHrPNV1IBn
|
|
|
35
35
|
qilisdk/extras/cuda/cuda_digital_result.py,sha256=bgHCrmcUVCBngo443PhfLkMxAT8Kk24FRubU3bJsdsQ,742
|
|
36
36
|
qilisdk/extras/qaas/__init__.py,sha256=LDSTo7NstSbHMvvqvx7ZLxh0HFTEXg1O_B76SyEEHk8,588
|
|
37
37
|
qilisdk/extras/qaas/keyring.py,sha256=xjJj6wrRALj31foctYTGZ07wgusVyIGuzeKxU-MNAA0,1774
|
|
38
|
-
qilisdk/extras/qaas/models.py,sha256=
|
|
38
|
+
qilisdk/extras/qaas/models.py,sha256=Phf_j8LPmBUeUbe_StgM-aSz8o1HecCnfsjFbvMAlTY,3801
|
|
39
39
|
qilisdk/extras/qaas/qaas_analog_result.py,sha256=MLWKtRWLwKZl7Q-tWv615-P_LKFxJIRrK_ni_jQvaP8,738
|
|
40
|
-
qilisdk/extras/qaas/qaas_backend.py,sha256=
|
|
40
|
+
qilisdk/extras/qaas/qaas_backend.py,sha256=PvXvuL-c5VtPv0IAt2z8AS8witUbVJbVnmxJMwKFiBw,9976
|
|
41
41
|
qilisdk/extras/qaas/qaas_digital_result.py,sha256=9EaZujlXvdmqdfVD-laDJq_I8YO5bc3XHRvEobOYR1U,743
|
|
42
42
|
qilisdk/extras/qaas/qaas_settings.py,sha256=Vl-OPs0ijht7GqxjztY-Id3nEinfE48j_J-d9mJ4Ctk,935
|
|
43
|
+
qilisdk/extras/qaas/qaas_time_evolution_result.py,sha256=sj9-xe1CbuO-yOkG5ac-f49CpIM4-X6tKnd9RBVfRMU,745
|
|
44
|
+
qilisdk/extras/qaas/qaas_vqe_result.py,sha256=tQUJ904aW7BzSzd-Dxi8TvL6AIQAnDsiOGuMB8fft58,720
|
|
43
45
|
qilisdk/utils/__init__.py,sha256=cFdezrFwesp9azZEBG_CWq3_Qp1yH8do_PyJbIIdSkU,920
|
|
44
46
|
qilisdk/utils/openqasm2.py,sha256=QGQi2rrkYB_cqRgCyp3V3uDyfnVvcdMxykIiK0-sqXM,8316
|
|
45
47
|
qilisdk/utils/serialization.py,sha256=vp-q2SZ9cBq3NX-gfT3ZDt0tzF3KnxkhV0cM7imJ2zo,3870
|
|
46
|
-
qilisdk-0.1.
|
|
47
|
-
qilisdk-0.1.
|
|
48
|
-
qilisdk-0.1.
|
|
49
|
-
qilisdk-0.1.
|
|
48
|
+
qilisdk-0.1.2.dist-info/METADATA,sha256=Pr59Q2KtieNfdr9qiOac3B1Bin1bzbbapoajmejEFy0,18039
|
|
49
|
+
qilisdk-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
50
|
+
qilisdk-0.1.2.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
51
|
+
qilisdk-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|