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 HardwareEfficient
from qiboml.models.decoding import Expectation

nqubits = 2
circuit = HardwareEfficient(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(lr=0.05)
for iteration in range(100):
    with tf.GradientTape() as tape:
        cost = ks_model(x)
    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.0.2.tar.gz (25.0 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.0.2-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qiboml-0.0.2.tar.gz
Algorithm Hash digest
SHA256 83abf21b7d80a1c2f4c8b98c19d090046af18591db564ecc17c1546f622ae286
MD5 d3f152b790ef76cf4387257ff3a508ec
BLAKE2b-256 54b7f929c996c58ae819f7d7b6a9ef90ee290c4092075baca0dea1524bd922e9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for qiboml-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 58f95ff5916560e263c079bcaf07da2f41f0be23cf7c7f3fa972d83ddbe4d0b0
MD5 12b2aefba349fa48ae792f74830a5a9b
BLAKE2b-256 033d5e51d4a80b4144bd9dbb4b982fe5dbfc8b685f03d75c26d204d44cb7d46c

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