Metadata-Version: 2.4
Name: qiboml
Version: 0.1.0
Summary: Quantum Machine Learning using Qibo
License-File: LICENSE
Author: Qiboteam
Requires-Python: >=3.10,<3.14
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Provides-Extra: keras
Provides-Extra: torch
Requires-Dist: jax (>=0.4.25,<0.5.0)
Requires-Dist: jaxlib (>=0.4.25,<0.5.0)
Requires-Dist: keras (>=3.11.0,<4.0.0) ; extra == "keras"
Requires-Dist: numpy (>=2.0.0,<3.0.0)
Requires-Dist: qibo (>=0.2.21,<0.3.0)
Requires-Dist: tensorflow (>=2.16.1,<3.0.0) ; (sys_platform == "linux" or sys_platform == "darwin") and (extra == "keras")
Requires-Dist: torch (>=2.7.0,<3.0.0) ; extra == "torch"
Project-URL: Documentation, https://qibo.science/docs/qiboml/stable
Project-URL: Homepage, https://qibo.science/
Project-URL: Repository, https://github.com/qiboteam/qiboml/
Description-Content-Type: text/markdown

# Qiboml

👋 Welcome to Qiboml, the quantum machine learning package of the Qibo ecosystem!

---

🎯 Our goal is to integrate Qibo within the most commonly used machine learning frameworks,
allowing the definition and usage of quantum or hybrid classical-quantum models
keeping the same high-level language proposed by the most used libraries (Pytorch, Tensorflow).

![qiboml](https://github.com/user-attachments/assets/5baba39f-fffc-43db-8080-f8acad340c63)


### Documentation

[![docs](https://github.com/qiboteam/qiboml/actions/workflows/publish.yml/badge.svg)](https://qibo.science/qiboml/stable/)

📖 The Qiboml documentation can be found in our [organization webpage](https://qibo.science/qiboml/stable/).


### Minimum working example

You can quickly build a QML model using one of the currently supported interfaces. For instance,
to train a VQE to find the ground state of an Hamiltonian $H=\sum_i Z_i$:

```python
from qiboml.models.ansatze import hardware_efficient
from qiboml.models.decoding import Expectation

nqubits = 2
circuit = hardware_efficient(nqubits)
# By default Expectation sets Z_0 + Z_1 + ... + Z_n as observable,
# any Hamiltonian can be used though
decoding = Expectation(nqubits)

# using pytorch
import torch
import qiboml.interfaces.pytorch as pt

pt_model = pt.QuantumModel(circuit_structure=[circuit,], decoding=decoding)
optimizer = torch.optim.Adam(pt_model.parameters(), lr=0.05)
for iteration in range(100):
    optimizer.zero_grad()
    cost = pt_model()
    cost.backward()
    optimizer.step()

# using keras
import keras
import tensorflow as tf
import qiboml.interfaces.keras as ks
tf.keras.backend.set_floatx('float64') # set the dtype to float64, which is qibo's default

ks_model = ks.QuantumModel(circuit_structure=[circuit,], decoding=decoding)
optimizer = keras.optimizers.Adam(learning_rate=0.05)
for iteration in range(100):
    with tf.GradientTape() as tape:
        cost = ks_model()
    gradients = tape.gradient(
        cost, ks_model.trainable_variables
    )
    optimizer.apply_gradients(zip(gradients, ks_model.trainable_variables))
```


### Citation policy

If you use the package please refer to [the documentation](https://qibo.science/qibo/stable/appendix/citing-qibo.html#publications) for citation instructions.

### Contacts

To get in touch with the community and the developers, consider joining the Qibo workspace on Matrix:

[![Matrix](https://img.shields.io/matrix/qibo%3Amatrix.org?logo=matrix)](https://matrix.to/#/#qiboml:matrix.org)

If you have a question about the project, please contact us with [📫](mailto:qiboteam@qibo.science).

