qilisdk 0.1.0__py3-none-any.whl → 0.1.1__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/__init__.py CHANGED
@@ -12,36 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- import sys
16
- from typing import List
15
+ from qilisdk import analog, common, digital, extras, utils
17
16
 
18
- from qilisdk.common import Algorithm, Model, Optimizer, Result
19
-
20
- from ._optionals import ImportedFeature, OptionalFeature, Symbol, import_optional_dependencies
21
-
22
- # Put your always-available, core symbols here
23
- __all__ = ["Algorithm", "Model", "Optimizer", "Result"]
24
-
25
- # Define your optional features
26
- OPTIONAL_FEATURES: List[OptionalFeature] = [
27
- OptionalFeature(
28
- name="cuda-backend",
29
- dependencies=["cudaq"],
30
- symbols=[Symbol(path="qilisdk.extras.cuda.cuda_backend", name="CudaBackend")],
31
- ),
32
- OptionalFeature(
33
- name="qaas",
34
- dependencies=["httpx", "keyring", "pydantic", "pydantic-settings"],
35
- symbols=[Symbol(path="qilisdk.extras.qaas.qaas_backend", name="QaaSBackend")],
36
- ),
37
- # Add more OptionalFeature() entries for other extras if needed
38
- ]
39
-
40
- current_module = sys.modules[__name__]
41
-
42
- # Dynamically import (or stub) each feature's symbols and attach them
43
- for feature in OPTIONAL_FEATURES:
44
- imported_feature: ImportedFeature = import_optional_dependencies(feature)
45
- for symbol_name, symbol_obj in imported_feature.symbols.items():
46
- setattr(current_module, symbol_name, symbol_obj)
47
- __all__ += [symbol_name] # noqa: PLE0604
17
+ __all__ = ["analog", "common", "digital", "extras", "utils"]
qilisdk/__init__.pyi CHANGED
@@ -12,19 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from qilisdk.analog import Hamiltonian
16
- from qilisdk.common import Algorithm, Model, Optimizer, Result
17
- from qilisdk.digital import DigitalSimulationMethod
18
- from qilisdk.extras.cuda import CudaBackend
19
- from qilisdk.extras.qaas.qaas_backend import QaaSBackend
15
+ from qilisdk import analog, common, digital, extras, utils
20
16
 
21
- __all__ = [
22
- "Algorithm",
23
- "CudaBackend",
24
- "DigitalSimulationMethod",
25
- "Hamiltonian",
26
- "Model",
27
- "Optimizer",
28
- "QaaSBackend",
29
- "Result",
30
- ]
17
+ __all__ = ["analog", "common", "digital", "extras", "utils"]
@@ -12,6 +12,23 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from .algorithms import TimeEvolution
15
16
  from .hamiltonian import Hamiltonian, I, X, Y, Z
17
+ from .quantum_objects import QuantumObject, basis, bra, expect, ket, tensor
18
+ from .schedule import Schedule
16
19
 
17
- __all__ = ["Hamiltonian", "I", "X", "Y", "Z"]
20
+ __all__ = [
21
+ "Hamiltonian",
22
+ "I",
23
+ "QuantumObject",
24
+ "Schedule",
25
+ "TimeEvolution",
26
+ "X",
27
+ "Y",
28
+ "Z",
29
+ "basis",
30
+ "bra",
31
+ "expect",
32
+ "ket",
33
+ "tensor",
34
+ ]
@@ -16,7 +16,7 @@ from pprint import pformat
16
16
  import numpy as np
17
17
 
18
18
  from qilisdk.analog.quantum_objects import QuantumObject
19
- from qilisdk.common import Result
19
+ from qilisdk.common.result import Result
20
20
  from qilisdk.yaml import yaml
21
21
 
22
22
 
@@ -12,9 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from .algorithm import Algorithm
16
- from .model import Model
17
- from .optimizer import Optimizer, SciPyOptimizer
18
- from .result import Result
15
+ from .optimizer import SciPyOptimizer
19
16
 
20
- __all__ = ["Algorithm", "Model", "Optimizer", "Result", "SciPyOptimizer"]
17
+ __all__ = ["SciPyOptimizer"]
@@ -12,9 +12,9 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from .ansatz import HardwareEfficientAnsatz
15
16
  from .circuit import Circuit
16
- from .digital_backend import DigitalBackend, DigitalSimulationMethod
17
- from .digital_result import DigitalResult
17
+ from .digital_backend import DigitalSimulationMethod
18
18
  from .gates import (
19
19
  CNOT,
20
20
  CZ,
@@ -24,10 +24,6 @@ from .gates import (
24
24
  U1,
25
25
  U2,
26
26
  U3,
27
- Adjoint,
28
- BasicGate,
29
- Controlled,
30
- Exponential,
31
27
  Gate,
32
28
  H,
33
29
  M,
@@ -37,6 +33,7 @@ from .gates import (
37
33
  Y,
38
34
  Z,
39
35
  )
36
+ from .vqe import VQE
40
37
 
41
38
  __all__ = [
42
39
  "CNOT",
@@ -47,16 +44,12 @@ __all__ = [
47
44
  "U1",
48
45
  "U2",
49
46
  "U3",
50
- "Adjoint",
51
- "BasicGate",
47
+ "VQE",
52
48
  "Circuit",
53
- "Controlled",
54
- "DigitalBackend",
55
- "DigitalResult",
56
49
  "DigitalSimulationMethod",
57
- "Exponential",
58
50
  "Gate",
59
51
  "H",
52
+ "HardwareEfficientAnsatz",
60
53
  "M",
61
54
  "S",
62
55
  "T",
@@ -15,7 +15,7 @@ import heapq
15
15
  import operator
16
16
  from pprint import pformat
17
17
 
18
- from qilisdk.common import Result
18
+ from qilisdk.common.result import Result
19
19
  from qilisdk.yaml import yaml
20
20
 
21
21
 
@@ -11,3 +11,30 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+ import sys
15
+
16
+ from qilisdk._optionals import ImportedFeature, OptionalFeature, Symbol, import_optional_dependencies
17
+
18
+ __all__ = []
19
+
20
+ OPTIONAL_FEATURES: list[OptionalFeature] = [
21
+ OptionalFeature(
22
+ name="cuda",
23
+ dependencies=["cudaq"],
24
+ symbols=[Symbol(path="qilisdk.extras.cuda.cuda_backend", name="CudaBackend")],
25
+ ),
26
+ OptionalFeature(
27
+ name="qaas",
28
+ dependencies=["httpx", "keyring", "pydantic", "pydantic-settings"],
29
+ symbols=[Symbol(path="qilisdk.extras.qaas.qaas_backend", name="QaaSBackend")],
30
+ ),
31
+ ]
32
+
33
+ current_module = sys.modules[__name__]
34
+
35
+ # Dynamically import (or stub) each feature's symbols and attach them
36
+ for feature in OPTIONAL_FEATURES:
37
+ imported_feature: ImportedFeature = import_optional_dependencies(feature)
38
+ for symbol_name, symbol_obj in imported_feature.symbols.items():
39
+ setattr(current_module, symbol_name, symbol_obj)
40
+ __all__ += [symbol_name] # noqa: PLE0604
@@ -0,0 +1,18 @@
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 .cuda.cuda_backend import CudaBackend
16
+ from .qaas.qaas_backend import QaaSBackend
17
+
18
+ __all__ = ["CudaBackend", "QaaSBackend"]
@@ -11,8 +11,3 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
-
15
- from .cuda_backend import CudaBackend
16
- from .cuda_digital_result import CudaDigitalResult
17
-
18
- __all__ = ["CudaBackend", "CudaDigitalResult"]
@@ -31,10 +31,7 @@ from qilisdk.digital import (
31
31
  U1,
32
32
  U2,
33
33
  U3,
34
- Adjoint,
35
- BasicGate,
36
34
  Circuit,
37
- Controlled,
38
35
  H,
39
36
  M,
40
37
  S,
@@ -45,6 +42,7 @@ from qilisdk.digital import (
45
42
  )
46
43
  from qilisdk.digital.digital_backend import DigitalBackend, DigitalSimulationMethod
47
44
  from qilisdk.digital.exceptions import UnsupportedGateError
45
+ from qilisdk.digital.gates import Adjoint, BasicGate, Controlled
48
46
 
49
47
  from .cuda_analog_result import CudaAnalogResult
50
48
  from .cuda_digital_result import CudaDigitalResult
@@ -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 QaaSAnalogResult(AnalogResult): ...
@@ -30,13 +30,13 @@ from .models import Device, Token
30
30
  from .qaas_settings import QaaSSettings
31
31
 
32
32
  if TYPE_CHECKING:
33
- from qilisdk.analog.analog_result import AnalogResult
34
33
  from qilisdk.analog.hamiltonian import Hamiltonian, PauliOperator
35
34
  from qilisdk.analog.quantum_objects import QuantumObject
36
35
  from qilisdk.analog.schedule import Schedule
37
36
  from qilisdk.common.algorithm import Algorithm
38
37
  from qilisdk.digital.circuit import Circuit
39
38
 
39
+ from .qaas_analog_result import QaaSAnalogResult
40
40
  from .qaas_digital_result import QaaSDigitalResult
41
41
 
42
42
  logging.basicConfig(
@@ -147,7 +147,7 @@ class QaaSBackend(DigitalBackend, AnalogBackend):
147
147
  initial_state: QuantumObject,
148
148
  observables: list[PauliOperator | Hamiltonian],
149
149
  store_intermediate_results: bool = False,
150
- ) -> AnalogResult:
150
+ ) -> QaaSAnalogResult:
151
151
  raise NotImplementedError
152
152
 
153
153
  def run(self, algorithm: Algorithm) -> None:
@@ -0,0 +1,538 @@
1
+ Metadata-Version: 2.4
2
+ Name: qilisdk
3
+ Version: 0.1.1
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
+ Author-email: Qilimanjaro Quantum Tech <info@qilimanjaro.tech>
6
+ License-File: LICENCE
7
+ Keywords: analog quantum computing,digital quantum computing,qilimanjaro,quantum computing
8
+ Classifier: Development Status :: 1 - Planning
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Classifier: Topic :: Scientific/Engineering :: Physics
20
+ Classifier: Topic :: Scientific/Engineering :: Quantum Computing
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: dill>=0.3.9
23
+ Requires-Dist: numpy>=2.2.4
24
+ Requires-Dist: ruamel-yaml>=0.18.10
25
+ Requires-Dist: scipy>=1.15.1
26
+ Provides-Extra: cuda
27
+ Requires-Dist: cudaq==0.9.1; extra == 'cuda'
28
+ Provides-Extra: qaas
29
+ Requires-Dist: httpx>=0.28.1; extra == 'qaas'
30
+ Requires-Dist: keyring>=25.6.0; extra == 'qaas'
31
+ Requires-Dist: pydantic-settings>=2.8.0; extra == 'qaas'
32
+ Requires-Dist: pydantic>=2.10.6; extra == 'qaas'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # QiliSDK
36
+
37
+ [![Python Versions](https://img.shields.io/pypi/pyversions/qilisdk.svg)](https://pypi.org/project/qilisdk/)
38
+ [![PyPI Version](https://img.shields.io/pypi/v/qilisdk.svg)](https://pypi.org/project/qilisdk/)
39
+ [![License](https://img.shields.io/pypi/l/qilisdk.svg)](#license)
40
+
41
+ **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.
42
+
43
+ ---
44
+
45
+ ## Table of Contents
46
+ - [QiliSDK](#qilisdk)
47
+ - [Table of Contents](#table-of-contents)
48
+ - [Installation](#installation)
49
+ - [Base Installation](#base-installation)
50
+ - [Optional Extras](#optional-extras)
51
+ - [Usage](#usage)
52
+ - [Digital Quantum Circuits](#digital-quantum-circuits)
53
+ - [Hamiltonian and Analog Operations](#hamiltonian-and-analog-operations)
54
+ - [Optimizers](#optimizers)
55
+ - [Quantum-as-a-Service (QaaS)](#quantum-as-a-service-qaas)
56
+ - [CUDA-Accelerated Simulation](#cuda-accelerated-simulation)
57
+ - [Time Evolution](#time-evolution)
58
+ - [Variational Quantum Eigensolver (VQE)](#variational-quantum-eigensolver-vqe)
59
+ - [Open QASM Serialization](#open-qasm-serialization)
60
+ - [YAML Serialization](#yaml-serialization)
61
+ - [Development](#development)
62
+ - [Prerequisites](#prerequisites)
63
+ - [Setup \& Dependency Management](#setup--dependency-management)
64
+ - [Testing](#testing)
65
+ - [Linting \& Formatting](#linting--formatting)
66
+ - [Type Checking](#type-checking)
67
+ - [Changelog Management](#changelog-management)
68
+ - [Contributing](#contributing)
69
+ - [License](#license)
70
+ - [Acknowledgments](#acknowledgments)
71
+
72
+ ---
73
+
74
+ ## Installation
75
+
76
+ QiliSDK is available via [PyPI](https://pypi.org/project/qilisdk/). You can install the core package as well as optional extras for additional features.
77
+
78
+ ### Base Installation
79
+
80
+ Install the core QiliSDK package using pip:
81
+
82
+ ```bash
83
+ pip install qilisdk
84
+ ```
85
+
86
+ ### Optional Extras
87
+
88
+ QiliSDK supports optional modules for additional functionality:
89
+
90
+ - **QaaS (Quantum-as-a-Service):**
91
+ To interface with Qilimanjaro’s cloud-based quantum services, install the QaaS extra:
92
+
93
+ ```bash
94
+ pip install qilisdk[qaas]
95
+ ```
96
+
97
+ - **CUDA Acceleration:**
98
+ For GPU-accelerated quantum simulation using NVIDIA GPUs, install the CUDA extra:
99
+
100
+ ```bash
101
+ pip install qilisdk[cuda]
102
+ ```
103
+
104
+ You can also install both optional dependencies using a single command:
105
+
106
+ ```bash
107
+ pip install qilisdk[cuda,qaas]
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Usage
113
+
114
+ QiliSDK is designed to simplify both digital and analog quantum computing workflows. This guide provides example code snippets for creating quantum circuits, performing Hamiltonian arithmetic, optimization, simulation on various backends (including CUDA and cloud-based QaaS), and using additional utility functions.
115
+
116
+ ### Digital Quantum Circuits
117
+
118
+ Create and simulate quantum circuits with a flexible gate framework. The following example demonstrates how to assemble a circuit, adjust gate parameters, and execute it with the Qibo backend:
119
+
120
+ ```python
121
+ import numpy as np
122
+ from qilisdk.digital import Circuit, H, RX, CNOT, M
123
+
124
+ # Create a circuit with 2 qubits
125
+ circuit = Circuit(2)
126
+ circuit.add(H(0)) # Apply Hadamard on qubit 0
127
+ circuit.add(RX(0, theta=np.pi)) # Apply RX rotation on qubit 0
128
+ circuit.add(CNOT(0, 1)) # Add a CNOT gate between qubit 0 and 1
129
+
130
+ # Retrieve the current gate parameters
131
+ print("Initial parameters:", circuit.get_parameter_values())
132
+
133
+ # Update circuit parameters (e.g., update RX rotation angle)
134
+ circuit.set_parameter_values([2 * np.pi])
135
+
136
+ # Execute the circuit simulation using CudaBackend
137
+ backend = CudaBackend()
138
+ results = backend.execute(circuit)
139
+
140
+ # Display the simulation output and measurement probabilities
141
+ print("Simulation Results:")
142
+ print(results)
143
+ print("Probabilities:", results.probabilities)
144
+ ```
145
+
146
+ ### Hamiltonian and Analog Operations
147
+
148
+ Utilize the `Hamiltonian` class for Pauli operator arithmetic. Build expressions, iterate through terms, and even round-trip using the parse feature:
149
+
150
+ ```python
151
+ from qilisdk.analog import Hamiltonian, X, Y, Z, I
152
+
153
+ # Build a Hamiltonian expression using Pauli operators
154
+ H_expr = (Z(0) + X(0)) * (Z(0) - X(0))
155
+ print("Hamiltonian Expression:", H_expr)
156
+
157
+ # Iterate over Hamiltonian terms
158
+ for coeff, ops in H_expr:
159
+ print("Coefficient:", coeff, "Operators:", ops)
160
+
161
+ # Parse a Hamiltonian from its string representation
162
+ parsed_H = Hamiltonian.parse("-2j Y(0)")
163
+ assert H_expr == parsed_H, "The Hamiltonian does not match after parsing."
164
+ ```
165
+
166
+ ### Optimizers
167
+
168
+ Run optimization routines using the `SciPyOptimizer` and integrate them with a variational algorithm (VQE). In the example below, a simple quadratic cost function is minimized:
169
+
170
+ ```python
171
+ from qilisdk.common import SciPyOptimizer
172
+
173
+ def cost_function(params):
174
+ # A simple quadratic cost: minimum at [1, 1, 1]
175
+ return sum((p - 1) ** 2 for p in params)
176
+
177
+ # Initialize the optimizer with the BFGS method
178
+ optimizer = SciPyOptimizer(method="BFGS")
179
+ initial_parameters = [0, 0, 0]
180
+ result = optimizer.optimize(cost_function, initial_parameters)
181
+
182
+ print("Optimal cost:", result.optimal_cost)
183
+ print("Optimal Parameters:", result.optimal_parameters)
184
+ ```
185
+
186
+ ### Quantum-as-a-Service (QaaS)
187
+
188
+ QiliSDK now includes a draft backend for interfacing with Qilimanjaro's QaaS platform. This module supports secure login and a unified interface for both digital circuits and analog evolutions:
189
+
190
+ ```python
191
+ from qilisdk.extras import QaaSBackend
192
+
193
+ # Login to QaaSBackend with credentials (or use environment variables)
194
+ # This only needs to be run once.
195
+ QaaSBackend.login(username="your_username", apikey="your_apikey")
196
+
197
+ # Instantiate QaaSBackend
198
+ qaas_backend = QaaSBackend()
199
+
200
+ # Execute a pre-built circuit (see Digital Quantum Circuits section)
201
+ results = qaas_backend.execute(circuit)
202
+ print("QaaS Simulation Results:", results)
203
+ ```
204
+
205
+ ### CUDA-Accelerated Simulation
206
+
207
+ For users with NVIDIA GPUs, the `CudaBackend` provides GPU-accelerated simulation using several simulation methods. For example, using the TENSOR_NETWORK method:
208
+
209
+ ```python
210
+ from qilisdk.extras import CudaBackend
211
+ from qilisdk.digital import Circuit, H, M, DigitalSimulationMethod
212
+
213
+ # Build a single-qubit circuit
214
+ circuit = Circuit(nqubits=1)
215
+ circuit.add(H(0))
216
+ circuit.add(M(0))
217
+
218
+ # Initialize CudaBackend with the TENSOR_NETWORK simulation method
219
+ cuda_backend = CudaBackend(digital_simulation_method=DigitalSimulationMethod.TENSOR_NETWORK)
220
+ results = cuda_backend.execute(circuit, nshots=1000)
221
+ print("CUDA Backend Results:", results)
222
+ ```
223
+
224
+ ### Time Evolution
225
+
226
+ For analog simulations, the new `TimeEvolution` and `Schedule` classes allow you to simulate time-dependent quantum dynamics. The following example uses a linear schedule to interpolate between two Hamiltonians on a CUDA backend:
227
+
228
+ ```python
229
+ import numpy as np
230
+ from qilisdk.analog import TimeEvolution, Schedule, tensor, ket, X, Z, Y
231
+ from qilisdk.extras import CudaBackend
232
+
233
+ T = 10 # Total evolution time
234
+ dt = 0.1 # Time-step
235
+ steps = np.linspace(0, T, int(T / dt))
236
+ nqubits = 1
237
+
238
+ # Define two Hamiltonians for the simulation
239
+ H1 = sum(X(i) for i in range(nqubits))
240
+ H2 = sum(Z(i) for i in range(nqubits))
241
+
242
+ # Create a schedule for the time evolution
243
+ schedule = Schedule(
244
+ T,
245
+ dt,
246
+ hamiltonians={"h1": H1, "h2": H2},
247
+ schedule={
248
+ t: {"h1": 1 - steps[t] / T, "h2": steps[t] / T}
249
+ for t in range(len(steps))
250
+ },
251
+ )
252
+
253
+ # Prepare an initial state (equal superposition)
254
+ state = tensor([(ket(0) + ket(1)).unit() for _ in range(nqubits)]).unit()
255
+
256
+ # Perform time evolution on the CUDA backend with observables to monitor
257
+ time_evolution = TimeEvolution(
258
+ backend=CudaBackend(),
259
+ schedule=schedule,
260
+ initial_state=state,
261
+ observables=[Z(0), X(0), Y(0)],
262
+ )
263
+ results = time_evolution.evolve(store_intermediate_results=True)
264
+ print("Time Evolution Results:", results)
265
+ ```
266
+
267
+ ### Variational Quantum Eigensolver (VQE)
268
+
269
+ The VQE algorithm integrates ansatz design, cost function evaluation, and classical optimization. Below is an illustrative example that sets up a VQE instance using a hardware-efficient ansatz and the SciPy optimizer:
270
+
271
+ ```python
272
+ import numpy as np
273
+ from qilisdk.common import SciPyOptimizer
274
+ from qilisdk.digital import HardwareEfficientAnsatz, VQE
275
+ from qilisdk.extras import CudaBackend
276
+
277
+
278
+ # Define problem parameters
279
+ n_items = 4
280
+ weights = [np.random.randint(1, 5) for _ in range(n_items)]
281
+ values = [np.random.randint(1, 10) for _ in range(n_items)]
282
+ max_weight_perc = 0.6
283
+ max_w = int(max_weight_perc * sum(weights))
284
+ nqubits = n_items
285
+
286
+ # Initialize a hardware-efficient ansatz
287
+ ansatz = HardwareEfficientAnsatz(
288
+ n_qubits=nqubits,
289
+ connectivity="Full",
290
+ layers=1,
291
+ one_qubit_gate="U3",
292
+ two_qubit_gate="CNOT"
293
+ )
294
+
295
+ # Use a CUDA backend for simulation
296
+ backend = CudaBackend()
297
+
298
+ LM = sum(values)
299
+
300
+ def cost_function(result):
301
+ # Get the most probable outcomes from the digital result
302
+ most_probable = result.get_probabilities()
303
+ final_cost = 0
304
+ for bitstring, prob in most_probable:
305
+ x_n = [int(bit) for bit in bitstring]
306
+ total_weight = sum(weights[i] * x_n[i] for i in range(n_items))
307
+ penalty = (total_weight - max_w) if total_weight > max_w else 0
308
+ reward = -sum(values[i] * x_n[i] for i in range(n_items))
309
+ final_cost += prob * (LM * penalty + reward)
310
+ return final_cost
311
+
312
+ optimizer = SciPyOptimizer(
313
+ method="Powell",
314
+ bounds=[(0, np.pi)] * ansatz.nparameters
315
+ )
316
+
317
+ # Initialize and execute the VQE algorithm
318
+ vqe = VQE(ansatz, [0.5] * ansatz.nparameters, cost_function)
319
+ results = vqe.execute(backend, optimizer, store_intermediate_results=True)
320
+
321
+ print("Optimal Cost:", results.optimal_cost)
322
+ print("Optimal Parameters:", results.optimal_parameters)
323
+ print("Intermediate Optimization Steps:")
324
+ for intermediate in results.intermediate_results:
325
+ print("Cost:", intermediate.cost)
326
+ ```
327
+
328
+ ### Open QASM Serialization
329
+
330
+ Serialize and deserialize quantum circuits using Open QASM 2.0 grammar. The utility functions below allow conversion to a QASM string or file and vice versa:
331
+
332
+ ```python
333
+ from qilisdk.digital import Circuit, CNOT, RX, H, M
334
+ from qilisdk.utils import to_qasm2, from_qasm2, to_qasm2_file, from_qasm2_file
335
+
336
+ # Create a sample circuit
337
+ circuit = Circuit(3)
338
+ circuit.add(H(0))
339
+ circuit.add(CNOT(0, 1))
340
+ circuit.add(RX(2, theta=3.1415))
341
+ circuit.add(M(0, 1, 2))
342
+
343
+ # Serialize to QASM string
344
+ qasm_code = to_qasm2(circuit)
345
+ print("Generated QASM:")
346
+ print(qasm_code)
347
+
348
+ # Deserialize back to a circuit
349
+ reconstructed_circuit = from_qasm2(qasm_code)
350
+
351
+ # Save to and load from a file
352
+ to_qasm2_file(circuit, "circuit.qasm")
353
+ reconstructed_circuit = from_qasm2_file("circuit.qasm")
354
+ ```
355
+
356
+ ### YAML Serialization
357
+
358
+ Easily save and restore circuits, hamiltonians, simulation and execution results, and virtually any other class in YAML format using the provided serialization functions:
359
+
360
+ ```python
361
+ from qilisdk.digital import Circuit, H, CNOT, M
362
+ from qilisdk.utils import serialize, deserialize, serialize_to, deserialize_from
363
+
364
+ circuit = Circuit(2)
365
+ circuit.add(H(0))
366
+ circuit.add(CNOT(0, 1))
367
+ circuit.add(M(0, 1))
368
+
369
+ # Serialize a circuit to a YAML string
370
+ yaml_string = serialize(circuit)
371
+
372
+ # Deserialize back into a Circuit object
373
+ restored_circuit = deserialize(yaml_string, cls=Circuit)
374
+
375
+ # Alternatively, work with files:
376
+ serialize_to(circuit, 'circuit.yml')
377
+ restored_circuit = deserialize_from('circuit.yml', cls=Circuit)
378
+ ```
379
+
380
+ ---
381
+
382
+ ## Development
383
+
384
+ This section covers how to set up a local development environment for qilisdk, run tests, enforce code style, manage dependencies, and contribute to the project. We use a number of tools to maintain code quality and consistency:
385
+
386
+ - **[uv](https://pypi.org/project/uv/)** for dependency management and packaging.
387
+ - **[ruff](https://beta.ruff.rs/docs/)** for linting and code formatting.
388
+ - **[mypy](http://mypy-lang.org/)** for static type checking.
389
+ - **[towncrier](https://github.com/twisted/towncrier)** for automated changelog generation.
390
+
391
+ ### Prerequisites
392
+
393
+ - Python **3.10+** (we test against multiple versions, but 3.10 is the minimum for local dev).
394
+ - [Git](https://git-scm.com/) for version control.
395
+ - [uv](https://pypi.org/project/uv/) for dependency management.
396
+
397
+ ### Setup & Dependency Management
398
+
399
+ 1. **Clone the repository**:
400
+ ```bash
401
+ git clone https://github.com/qilimanjaro-tech/qilisdk.git
402
+ cd qilisdk
403
+ ```
404
+
405
+ 2. **Install [uv](https://pypi.org/project/uv/) globally** (if not already):
406
+ ```bash
407
+ curl -LsSf https://astral.sh/uv/install.sh | sh
408
+ ```
409
+
410
+ 3. **Sync dependencies**:
411
+ - We maintain a `pyproject.toml` listing all dev and optional requirements.
412
+ - To install the dev environment locally, run:
413
+ ```bash
414
+ uv sync
415
+ ```
416
+ This sets up a virtual environment and installs all pinned dependencies (including `ruff`, `mypy`, `towncrier`, etc.).
417
+ - To install extra dependencies such as `qibo-backend`, run:
418
+ ```bash
419
+ uv sync --extra qibo-backend -extra ...
420
+ ```
421
+ This sets up a virtual environment and installs all pinned dependencies (previous), plus the specified extras.
422
+
423
+ 4. **Activate the virtual environment**:
424
+ - uv typically creates and manages its own environment, e.g., `.venv/`.
425
+ - Run:
426
+ ```bash
427
+ source .venv/bin/activate
428
+ ```
429
+ *(Exact command can vary depending on your shell and OS.)*
430
+
431
+ Now you can run all development commands (tests, linting, etc.) within this environment.
432
+
433
+ ### Testing
434
+
435
+ TODO: to_be_filled
436
+
437
+ ### Linting & Formatting
438
+
439
+ We enforce code style and best practices using [**ruff**](https://beta.ruff.rs/docs/). ruff handles:
440
+
441
+ - Lint checks (similar to flake8, pylint).
442
+ - Formatting (similar to black or isort).
443
+ - Automated fixes for certain issues.
444
+
445
+ To check linting:
446
+
447
+ ```bash
448
+ ruff check
449
+ ```
450
+
451
+ To automatically fix lint issues (where possible):
452
+
453
+ ```bash
454
+ ruff check --fix
455
+ ```
456
+
457
+ To automatically format your code:
458
+
459
+ ```bash
460
+ ruff format
461
+ ```
462
+
463
+ *(We recommend running `ruff check --fix` and `ruff format` before committing any changes.)*
464
+
465
+ ### Type Checking
466
+
467
+ We use [**mypy**](http://mypy-lang.org/) for static type checking. This helps ensure our code is type-safe and maintainable.
468
+
469
+ ```bash
470
+ mypy qilisdk
471
+ ```
472
+
473
+ If you have extra modules or tests you want type-checked, specify them:
474
+
475
+ ```bash
476
+ mypy qilisdk tests
477
+ ```
478
+
479
+ *(We encourage developers to annotate new functions, classes, and methods with type hints.)*
480
+
481
+ ### Changelog Management
482
+
483
+ We manage our changelog using [**towncrier**](https://github.com/twisted/towncrier). Instead of editing `CHANGELOG.md` directly, **each pull request** includes a small *news fragment* file in the `changes/` directory describing the user-facing changes.
484
+
485
+ For example, if you create a PR with id #123 adding a new feature, you add:
486
+ ```
487
+ changes/123.feature.rst
488
+ ```
489
+ Inside this file, you briefly describe the new feature:
490
+ ```rst
491
+ Added a new `cool_feature` in the `qilisdk.extras` module.
492
+ ```
493
+ Instead of manually creating the file, you can run:
494
+ ```bash
495
+ towncrier create --no-edit
496
+ ```
497
+ When we cut a new release, we update the version in `pyproject.toml` file and run:
498
+ ```bash
499
+ towncrier
500
+ ```
501
+ This aggregates all the news fragments into the `CHANGELOG.md` under the new version and removes the used fragments.
502
+
503
+ ### Contributing
504
+
505
+ We welcome contributions! Here’s the workflow:
506
+
507
+ 1. **Fork** this repository and create a feature branch.
508
+ 2. **Write** your changes (code, docs, or tests).
509
+ 3. **Add a news fragment** (if applicable) in `changes/` describing the user-facing impact.
510
+ 4. **Run** the following checks locally:
511
+ ```bash
512
+ ruff check --fix
513
+ ruff format
514
+ mypy qilisdk
515
+ pytest tests
516
+ ```
517
+ 5. **Commit** and push your branch to your fork. `pre-commit` will also run the checks automatically.
518
+ 6. **Open a Pull Request** against the `main` branch here.
519
+
520
+ Our CI will run tests, linting, and type checks. Please make sure your branch passes these checks before requesting a review.
521
+
522
+ ---
523
+
524
+ ## License
525
+
526
+ This project is licensed under the [Apache License](LICENSE).
527
+
528
+ ---
529
+
530
+ ## Acknowledgments
531
+
532
+ - Thanks to all the contributors who help develop qilisdk!
533
+ - [uv](https://pypi.org/project/uv/) for making dependency management smoother.
534
+ - [ruff](https://beta.ruff.rs/docs/), [mypy](http://mypy-lang.org/), and [towncrier](https://github.com/twisted/towncrier) for their amazing tooling.
535
+
536
+ ---
537
+
538
+ Feel free to open [issues](https://github.com/qilimanjaro-tech/qilisdk/issues) or [pull requests](https://github.com/qilimanjaro-tech/qilisdk/pulls) if you have questions or contributions. Happy coding!
@@ -1,47 +1,49 @@
1
- qilisdk/__init__.py,sha256=O3tFo8LdNtcDjkgP5uoEc9V8cxMzCeMbY-FBFSXJfdk,1823
2
- qilisdk/__init__.pyi,sha256=oiX2eVc8cHCGuip0Too3tnN7OD48H5QnGbatryFQHMs,1008
1
+ qilisdk/__init__.py,sha256=iwacKJYttlh9DgQgNmnAjkU9CyjDQG42X3gr9Dg1kME,710
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
5
  qilisdk/yaml.py,sha256=HX-erLJnHfZK8WQrNPhzZAfJDP93L0eKtlzd1S4_Q18,2701
6
- qilisdk/analog/__init__.py,sha256=44Z3QEELqCjm1BDAAE9i16_pZoo8zaGLkbTIsPo4TOw,685
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
9
- qilisdk/analog/analog_result.py,sha256=pi4TOvBbBpt1_8PrRRzS2iYByQy-qUXwpNeBf2RqEwM,4698
9
+ qilisdk/analog/analog_result.py,sha256=aaTGQmKm8-cuFvs_lhCAP0JOaUxsmsNcVbn_M5rvkm4,4705
10
10
  qilisdk/analog/exceptions.py,sha256=66nF1b3God6LgJ1IQd0thC3iyr6z1iMcZTfmDsSr4LE,686
11
11
  qilisdk/analog/hamiltonian.py,sha256=ELQXIauk_foOQbOChTFIV4fYzTwqHhSP1tMw8PwytaQ,25126
12
12
  qilisdk/analog/quantum_objects.py,sha256=_M7hkZOD-NW0FjoTtkrFFDVICxQ2cH7OP0xlfqjtuTE,18833
13
13
  qilisdk/analog/schedule.py,sha256=AHpiBPN1YZb9J2WNw6MyRPjRWAyqLVIiGFj5y_rwDmA,12807
14
- qilisdk/common/__init__.py,sha256=Djp6uVxpw9U5pBRGcUD0C1EvU_MRo2fhodeGgXV0pmo,798
14
+ qilisdk/common/__init__.py,sha256=sB9yxB1512KdJuWGSHx7TWvIxLMFBX1m7zm6NVkWEAA,657
15
15
  qilisdk/common/algorithm.py,sha256=_MBdMHIJogTPnR8QRCvpf364lxQNDqGWWyZpsgplcyI,636
16
16
  qilisdk/common/backend.py,sha256=dPzjqplkDTfCbLvY68M5z0ALxmgugWeCjVLuG_EqW70,609
17
17
  qilisdk/common/model.py,sha256=lwK0xW_sitLj7bw7aNh5xrMWVE2HoKIk2irkGpsc8as,607
18
18
  qilisdk/common/optimizer.py,sha256=jIBntTMw5qw03RRp5gzQe4BO9bh_z3Oeh_qfwbot0bI,5860
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
- qilisdk/digital/__init__.py,sha256=PW29pvoLPt4OgESbiW-hgcH9FLbwuWfwrpoeSo94WWo,1268
21
+ qilisdk/digital/__init__.py,sha256=vAk9BGKUxKc5faOppR64kUnJxV2WKxJK_FGpGyxuheY,1144
22
22
  qilisdk/digital/ansatz.py,sha256=lKiEo8PXG5QoxXB7b2Sp0oF3JL2meHrew66d9iOwWMk,5830
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
- qilisdk/digital/digital_result.py,sha256=0f1h4JHWRPkKEBCerYptmLN7yG5_IN4YchUPNEH6ZOY,5286
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
29
  qilisdk/digital/vqe.py,sha256=ynEL2oTTDZayeR3nDxV3vI4J0SCQQ_qY4uZcDUbTimo,6627
30
- qilisdk/extras/__init__.py,sha256=LDSTo7NstSbHMvvqvx7ZLxh0HFTEXg1O_B76SyEEHk8,588
31
- qilisdk/extras/cuda/__init__.py,sha256=hesw7M0_AoWBaeW4iGb-rq5eD16b7aP7VKI_oE7ACN0,726
30
+ qilisdk/extras/__init__.py,sha256=kki6xpa5TInawohC_vNacHZ4UAWxrEoK_lpl5eUkRpk,1543
31
+ qilisdk/extras/__init__.pyi,sha256=xQ4zOPeSaNM5zGfb07fK4lcbAu4y95YfgSlHs5TkR3Y,717
32
+ qilisdk/extras/cuda/__init__.py,sha256=LDSTo7NstSbHMvvqvx7ZLxh0HFTEXg1O_B76SyEEHk8,588
32
33
  qilisdk/extras/cuda/cuda_analog_result.py,sha256=0IoBZpkPfxS5CDps1Z6uRH1ATWG689klYR1RvGyUhBU,737
33
- qilisdk/extras/cuda/cuda_backend.py,sha256=71hDYkl04WSNkwvEodAq9S-pT_qxAz7bWONdkQ59G0w,16382
34
+ qilisdk/extras/cuda/cuda_backend.py,sha256=ew8Dethe1bIFrSRd0rv-cl7joozrHrPNV1IBn7LtOhQ,16403
34
35
  qilisdk/extras/cuda/cuda_digital_result.py,sha256=bgHCrmcUVCBngo443PhfLkMxAT8Kk24FRubU3bJsdsQ,742
35
36
  qilisdk/extras/qaas/__init__.py,sha256=LDSTo7NstSbHMvvqvx7ZLxh0HFTEXg1O_B76SyEEHk8,588
36
37
  qilisdk/extras/qaas/keyring.py,sha256=xjJj6wrRALj31foctYTGZ07wgusVyIGuzeKxU-MNAA0,1774
37
38
  qilisdk/extras/qaas/models.py,sha256=EfNX1DSRAUaanYjdmIXkktduxoKWvXrJnobFQs-HXBM,1584
38
- qilisdk/extras/qaas/qaas_backend.py,sha256=u69Jl-LPvDw3BV_gQGZAwLeTKVhqyBUM_YgoLZmbfB8,5831
39
+ qilisdk/extras/qaas/qaas_analog_result.py,sha256=MLWKtRWLwKZl7Q-tWv615-P_LKFxJIRrK_ni_jQvaP8,738
40
+ qilisdk/extras/qaas/qaas_backend.py,sha256=vP-FLsSQjET4-DARmeXHOogdXArVpCOelJl4pgXeQy8,5830
39
41
  qilisdk/extras/qaas/qaas_digital_result.py,sha256=9EaZujlXvdmqdfVD-laDJq_I8YO5bc3XHRvEobOYR1U,743
40
42
  qilisdk/extras/qaas/qaas_settings.py,sha256=Vl-OPs0ijht7GqxjztY-Id3nEinfE48j_J-d9mJ4Ctk,935
41
43
  qilisdk/utils/__init__.py,sha256=cFdezrFwesp9azZEBG_CWq3_Qp1yH8do_PyJbIIdSkU,920
42
44
  qilisdk/utils/openqasm2.py,sha256=QGQi2rrkYB_cqRgCyp3V3uDyfnVvcdMxykIiK0-sqXM,8316
43
45
  qilisdk/utils/serialization.py,sha256=vp-q2SZ9cBq3NX-gfT3ZDt0tzF3KnxkhV0cM7imJ2zo,3870
44
- qilisdk-0.1.0.dist-info/METADATA,sha256=2n4gy_pBnb3rf9NhpUX52zoKMP3LrmpU8dMydImZsYI,8161
45
- qilisdk-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
46
- qilisdk-0.1.0.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
47
- qilisdk-0.1.0.dist-info/RECORD,,
46
+ qilisdk-0.1.1.dist-info/METADATA,sha256=5b1v-c6eoSFicRoWRbkOpESHMjmK8LjTB4DrGPfOynk,18039
47
+ qilisdk-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
48
+ qilisdk-0.1.1.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
49
+ qilisdk-0.1.1.dist-info/RECORD,,
@@ -1,237 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: qilisdk
3
- Version: 0.1.0
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
- Author-email: Qilimanjaro Quantum Tech <info@qilimanjaro.tech>
6
- License-File: LICENCE
7
- Keywords: analog quantum computing,digital quantum computing,qilimanjaro,quantum computing
8
- Classifier: Development Status :: 1 - Planning
9
- Classifier: Environment :: Console
10
- Classifier: Intended Audience :: Developers
11
- Classifier: Intended Audience :: Science/Research
12
- Classifier: License :: OSI Approved :: Apache Software License
13
- Classifier: Operating System :: POSIX :: Linux
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Topic :: Scientific/Engineering
19
- Classifier: Topic :: Scientific/Engineering :: Physics
20
- Classifier: Topic :: Scientific/Engineering :: Quantum Computing
21
- Requires-Python: >=3.10
22
- Requires-Dist: dill>=0.3.9
23
- Requires-Dist: numpy>=2.2.4
24
- Requires-Dist: ruamel-yaml>=0.18.10
25
- Requires-Dist: scipy>=1.15.1
26
- Provides-Extra: cuda
27
- Requires-Dist: cudaq==0.9.1; extra == 'cuda'
28
- Provides-Extra: qaas
29
- Requires-Dist: httpx>=0.28.1; extra == 'qaas'
30
- Requires-Dist: keyring>=25.6.0; extra == 'qaas'
31
- Requires-Dist: pydantic-settings>=2.8.0; extra == 'qaas'
32
- Requires-Dist: pydantic>=2.10.6; extra == 'qaas'
33
- Description-Content-Type: text/markdown
34
-
35
- # qilisdk
36
-
37
- [![Python Versions](https://img.shields.io/pypi/pyversions/qilisdk.svg)](https://pypi.org/project/qilisdk/)
38
- [![PyPI Version](https://img.shields.io/pypi/v/qilisdk.svg)](https://pypi.org/project/qilisdk/)
39
- [![License](https://img.shields.io/pypi/l/qilisdk.svg)](#license)
40
-
41
- **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.
42
-
43
- > **Note**: The instructions below focus on developing and contributing to qilisdk. For installation and usage as an end user, see the [Usage](#usage) section (placeholder).
44
-
45
- ---
46
-
47
- ## Table of Contents
48
- - [qilisdk](#qilisdk)
49
- - [Table of Contents](#table-of-contents)
50
- - [Development](#development)
51
- - [Prerequisites](#prerequisites)
52
- - [Setup \& Dependency Management](#setup--dependency-management)
53
- - [Testing](#testing)
54
- - [Linting \& Formatting](#linting--formatting)
55
- - [Type Checking](#type-checking)
56
- - [Changelog Management](#changelog-management)
57
- - [Contributing](#contributing)
58
- - [Usage](#usage)
59
- - [License](#license)
60
- - [Acknowledgments](#acknowledgments)
61
-
62
- ---
63
-
64
- ## Development
65
-
66
- This section covers how to set up a local development environment for qilisdk, run tests, enforce code style, manage dependencies, and contribute to the project. We use a number of tools to maintain code quality and consistency:
67
-
68
- - **[uv](https://pypi.org/project/uv/)** for dependency management and packaging.
69
- - **[ruff](https://beta.ruff.rs/docs/)** for linting and code formatting.
70
- - **[mypy](http://mypy-lang.org/)** for static type checking.
71
- - **[towncrier](https://github.com/twisted/towncrier)** for automated changelog generation.
72
-
73
- ### Prerequisites
74
-
75
- - Python **3.10+** (we test against multiple versions, but 3.10 is the minimum for local dev).
76
- - [Git](https://git-scm.com/) for version control.
77
- - [uv](https://pypi.org/project/uv/) for dependency management.
78
-
79
- ### Setup & Dependency Management
80
-
81
- 1. **Clone the repository**:
82
- ```bash
83
- git clone https://github.com/qilimanjaro-tech/qilisdk.git
84
- cd qilisdk
85
- ```
86
-
87
- 2. **Install [uv](https://pypi.org/project/uv/) globally** (if not already):
88
- ```bash
89
- curl -LsSf https://astral.sh/uv/install.sh | sh
90
- ```
91
-
92
- 3. **Sync dependencies**:
93
- - We maintain a `pyproject.toml` listing all dev and optional requirements.
94
- - To install the dev environment locally, run:
95
- ```bash
96
- uv sync
97
- ```
98
- This sets up a virtual environment and installs all pinned dependencies (including `ruff`, `mypy`, `towncrier`, etc.).
99
- - To install extra dependencies such as `qibo-backend`, run:
100
- ```bash
101
- uv sync --extra qibo-backend -extra ...
102
- ```
103
- This sets up a virtual environment and installs all pinned dependencies (previous), plus the specified extras.
104
-
105
- 4. **Activate the virtual environment**:
106
- - uv typically creates and manages its own environment, e.g., `.venv/`.
107
- - Run:
108
- ```bash
109
- source .venv/bin/activate
110
- ```
111
- *(Exact command can vary depending on your shell and OS.)*
112
-
113
- Now you can run all development commands (tests, linting, etc.) within this environment.
114
-
115
- ### Testing
116
-
117
- TODO: to_be_filled
118
-
119
- ### Linting & Formatting
120
-
121
- We enforce code style and best practices using [**ruff**](https://beta.ruff.rs/docs/). ruff handles:
122
-
123
- - Lint checks (similar to flake8, pylint).
124
- - Formatting (similar to black or isort).
125
- - Automated fixes for certain issues.
126
-
127
- To check linting:
128
-
129
- ```bash
130
- ruff check
131
- ```
132
-
133
- To automatically fix lint issues (where possible):
134
-
135
- ```bash
136
- ruff check --fix
137
- ```
138
-
139
- To automatically format your code:
140
-
141
- ```bash
142
- ruff format
143
- ```
144
-
145
- *(We recommend running `ruff check --fix` and `ruff format` before committing any changes.)*
146
-
147
- ### Type Checking
148
-
149
- We use [**mypy**](http://mypy-lang.org/) for static type checking. This helps ensure our code is type-safe and maintainable.
150
-
151
- ```bash
152
- mypy qilisdk
153
- ```
154
-
155
- If you have extra modules or tests you want type-checked, specify them:
156
-
157
- ```bash
158
- mypy qilisdk tests
159
- ```
160
-
161
- *(We encourage developers to annotate new functions, classes, and methods with type hints.)*
162
-
163
- ### Changelog Management
164
-
165
- We manage our changelog using [**towncrier**](https://github.com/twisted/towncrier). Instead of editing `CHANGELOG.md` directly, **each pull request** includes a small *news fragment* file in the `changes/` directory describing the user-facing changes.
166
-
167
- For example, if you create a PR with id #123 adding a new feature, you add:
168
- ```
169
- changes/123.feature.rst
170
- ```
171
- Inside this file, you briefly describe the new feature:
172
- ```rst
173
- Added a new `cool_feature` in the `qilisdk.extras` module.
174
- ```
175
- Instead of manually creating the file, you can run:
176
- ```bash
177
- towncrier create --no-edit
178
- ```
179
- When we cut a new release, we update the version in `pyproject.toml` file and run:
180
- ```bash
181
- towncrier
182
- ```
183
- This aggregates all the news fragments into the `CHANGELOG.md` under the new version and removes the used fragments.
184
-
185
- ### Contributing
186
-
187
- We welcome contributions! Here’s the workflow:
188
-
189
- 1. **Fork** this repository and create a feature branch.
190
- 2. **Write** your changes (code, docs, or tests).
191
- 3. **Add a news fragment** (if applicable) in `changes/` describing the user-facing impact.
192
- 4. **Run** the following checks locally:
193
- ```bash
194
- ruff check --fix
195
- ruff format
196
- mypy qilisdk
197
- pytest tests
198
- ```
199
- 5. **Commit** and push your branch to your fork. `pre-commit` will also run the checks automatically.
200
- 6. **Open a Pull Request** against the `main` branch here.
201
-
202
- Our CI will run tests, linting, and type checks. Please make sure your branch passes these checks before requesting a review.
203
-
204
- ---
205
-
206
- ## Usage
207
-
208
- *(Placeholder for end users. Provide a brief snippet on how to install qilisdk and use its main features. For example:)*
209
-
210
- ```bash
211
- pip install qilisdk
212
- ```
213
-
214
- ```python
215
- from qilisdk import core_feature
216
-
217
- result = core_feature.do_something()
218
- print(result)
219
- ```
220
-
221
- ---
222
-
223
- ## License
224
-
225
- This project is licensed under the [Apache License](LICENSE).
226
-
227
- ---
228
-
229
- ## Acknowledgments
230
-
231
- - Thanks to all the contributors who help develop qilisdk!
232
- - [uv](https://pypi.org/project/uv/) for making dependency management smoother.
233
- - [ruff](https://beta.ruff.rs/docs/), [mypy](http://mypy-lang.org/), and [towncrier](https://github.com/twisted/towncrier) for their amazing tooling.
234
-
235
- ---
236
-
237
- Feel free to open [issues](https://github.com/qilimanjaro-tech/qilisdk/issues) or [pull requests](https://github.com/qilimanjaro-tech/qilisdk/pulls) if you have questions or contributions. Happy coding!