Skip to content

Quickstart

Quantum Optimization Quickstart

Run your first quantum optimization in a few lines of Python, on IBM Quantum with Iskay or on the Kipu Quantum Hub with Miray. Copy the code and follow along.

Get a free Hub account

The Free plan includes a 5€ trial credit.

Self-paced: ~15 min

For developers with Python. No quantum background needed; Iskay needs an IBM Quantum account, Miray a Kipu Quantum Hub account.

By the end of this session, you can

  • Define an objective as a HUBO
  • Run it with Iskay or Miray
  • Read the cost and the solution

Prerequisites

  • Python 3.11 or newer
  • An IBM Quantum account (Iskay) or a Kipu Quantum Hub account (Miray)

Combinatorial optimization is where quantum hardware is useful today. Kipu Quantum's BF-DCQO engine encodes your objective directly as a higher-order binary problem (HUBO), so you spend qubits on variables, not on reducing higher-order terms to pairwise ones. The same engine ships two ways: as Iskay, a Qiskit Function on the IBM Quantum Platform, and as Miray on the Kipu Quantum Hub, which also targets IonQ, Rigetti and QuEra.

Pick one option below. Both solve the same objective.


Step 1: Define a HUBO

A HUBO is a dictionary. Each key is a tuple of variable indices written as a string, and each value is its coefficient. Linear, quadratic and higher-order terms sit side by side:

python
hubo = {
    "()": 0.0,          # constant
    "(0,)": -1.0,       # linear
    "(1,)": -1.0,
    "(0, 1)": 2.0,      # quadratic (QUBO)
    "(0, 1, 2)": -1.5,  # cubic (HUBO), no extra qubits
}

Step 2: Connect and run

Option A: Iskay on IBM Quantum

Iskay loads as a Qiskit Function. You need your IBM Quantum Platform token and instance CRN.

python
# iskay_quickstart.py
from qiskit_ibm_catalog import QiskitFunctionsCatalog  # pip install qiskit-ibm-catalog

catalog = QiskitFunctionsCatalog(
    token=IBM_TOKEN, channel="ibm_quantum_platform", instance=INSTANCE_CRN,
)
iskay = catalog.load("kipu-quantum/iskay-quantum-optimizer")

# Objective as a QUBO/HUBO. Higher-order terms are native.
hubo = {
    "()": 0.0,          # constant
    "(0,)": -1.0,       # linear
    "(1,)": -1.0,
    "(0, 1)": 2.0,      # quadratic (QUBO)
    "(0, 1, 2)": -1.5,  # cubic (HUBO), no extra qubits
}

job = iskay.run(
    problem=hubo,
    problem_type="binary",
    instance=INSTANCE_CRN,
    backend_name="ibm_fez",
    options={"shots": 100, "num_iterations": 3},
)

result = job.result()
print(result["solution_info"]["cost"], result["solution"])

Option B: Miray on the Kipu Quantum Hub

Miray runs as a Hub service. You need its service endpoint and an access key pair. The Hub Quickstart walks you through account setup, the Service SDK documents HubServiceClient, and access tokens issues your access_key_id and secret_access_key.

python
# miray_quickstart.py
from qhub.service.client import HubServiceClient  # pip install qhub-service

client = HubServiceClient(
    service_endpoint=SERVICE_ENDPOINT,
    access_key_id=ACCESS_KEY_ID,
    secret_access_key=SECRET_ACCESS_KEY,
)

# Same objective, same engine. Also runs on IonQ, Rigetti, QuEra.
hubo = {
    "()": 0.0,
    "(0,)": -1.0,
    "(1,)": -1.0,
    "(0, 1)": 2.0,
    "(0, 1, 2)": -1.5,
}

execution = client.run(request={
    "problem": hubo,
    "problem_type": "binary",
    "shots": 100,
    "num_iterations": 3,
})
execution.wait_for_final_state()

response = execution.result()
print(response.result["cost"], response.result["mapped_solution"])

Step 3: Read the solution

Both options print two things: the cost, which is the objective value the optimizer reached, and the solution, which assigns 0 or 1 to each variable. Kipu handles the encoding and the post-processing, so the solution is already in your original variables.

To raise the quality, increase shots and num_iterations. To get a faster run, reduce them.


Where next

How was this session?

Ready for a real problem?

Get a free Hub account

The Free plan includes a 5€ trial credit.