Skip to main content

Quantum Machine Learning using Qibo

Project description

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

Documentation

docs

📖 The Qiboml documentation can be found in our organization webpage.

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$:

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 for citation instructions.

Contacts

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

Matrix

If you have a question about the project, please contact us with 📫.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qiboml-0.1.0.tar.gz (39.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qiboml-0.1.0-py3-none-any.whl (49.5 kB view details)

Uploaded Python 3

File details

Details for the file qiboml-0.1.0.tar.gz.

File metadata

  • Download URL: qiboml-0.1.0.tar.gz
  • Upload date:
  • Size: 39.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qiboml-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2984e64ff0a06f0e268066b5bff826eb4ca5398143abc8669f1804bb0961be5
MD5 69ce359d78ca7c4a4ef6b36f37539a7c
BLAKE2b-256 8f31261debe3c7bd399fb06487004a9a25c65af4c506ef826d137a65b2589ce6

See more details on using hashes here.

File details

Details for the file qiboml-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qiboml-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 49.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qiboml-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22f86b6b72b9013c5f6dd0e08328b880cfdc866dc1fe930542a3a76d46159392
MD5 168ceb2a406c913ac2fbebe031b71c32
BLAKE2b-256 22fdd87bc5db9b3938d396f3e617ccf80020fe4eae57ea5d453d0c701aeadb33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page