Skip to content

Quickstart

1 of 7

Quantum Feature Extraction Quickstart Guide

Get a free Hub account

Free plan includes a 5€ trial credit.

Self-paced: ~5 min

For developers with Python. No quantum background needed; you need a free Kipu Quantum Hub account.

By the end of this session, you can

  • Setup Rimay on the Kipu Hub
  • Run Rimay on a small dataset using datapools
  • Download the quantum features

Prerequisites

  • Python 3.11 or newer
  • A free Kipu Quantum Hub account

Rimay Quantum Feature Extraction takes tabular data as input. It returns new quantum features. This quickstart is a minimal example of how to set up the free Rimay simulator and use its results. To find out whether the new features help your model, have a look at the full lab.


Step 1: Setup

You need a Kipu Quantum Hub account and these three credentials:

  • Personal Access Token (PAT) for the platform API: data pools, files, your application, pool access. Hub Home > Personal Access Token, or Settings > Personal Access Tokens.
  • Access Key ID and Secret Access Key of an application, for the service gateway: they start a Rimay run. Applications > your application > Credentials. If you have none, create a new one.
  • A subscription of that application to Rimay - Quantum Feature Extraction - Simulator, which lets the application call the service. In the Marketplace, open the Rimay simulator, press Subscribe and pick your application.

Keep these credentials safe, like passwords. You can rotate and refresh them at any time.

The Credentials tab of an application on the Kipu Quantum Hub: the Access Key ID, the Secret Access Key hidden behind dots with a show and a copy button, the gateway address and the token endpoint, with a sample curl call below.
Applications > YOUR_APPLICATION > Credentials.

The next box runs on the Kipu Hub with your key. . It stays in this tab, and a reload clears it.


Step 2: Install dependencies

Python 3.11 or newer, with uv:

shell
uv init rimay-quickstart
cd rimay-quickstart
uv add "qhub-service>=2.0" "qhub-api>=3.3" numpy pandas scikit-learn python-dotenv

Put the three values in a .env file next to your script. For example:

shell
KQH_PERSONAL_ACCESS_TOKEN=...
KQH_ACCESS_KEY_ID=...
KQH_SECRET_ACCESS_KEY=...

You can check the key pair before running your code. If the code below returns 200, that means the gateway accepts the credentials:

shell
set -a; source .env; set +a
curl -s -o /dev/null -w "%{http_code}\n" -u "$KQH_ACCESS_KEY_ID:$KQH_SECRET_ACCESS_KEY" \
  -d grant_type=client_credentials https://gateway.hub.kipu-quantum.com/token

Step 3: Format the dataset

Rimay reads one file, data.json, with four blocks: X_train, y_train, X_test and y_test. Each block is a pandas to_dict(). The label column is named label, and the row keys of each feature block match its label block.

In [ ]:

python
# quickstart.py, part 1: the payload
import json
import numpy as np
import pandas as pd

rng = np.random.default_rng(0)
X = pd.DataFrame(rng.normal(size=(100, 4)),
                 columns=["temperature", "pressure", "vibration", "speed"]).round(3)
y = ((X["temperature"] + X["vibration"]) > 0.5).astype(int)

X_train, X_test = X.iloc[:80], X.iloc[80:]
y_train, y_test = y.iloc[:80], y.iloc[80:]

payload = {
    "X_train": X_train.to_dict(),
    "y_train": y_train.to_frame("label").to_dict(),
    "X_test": X_test.to_dict(),
    "y_test": y_test.to_frame("label").to_dict(),
}
with open("data.json", "w") as fh:
    json.dump(payload, fh)

The free tier takes up to 15 features and 3,000 samples. For upgrades, contact Kipu.


Step 4: Create data pools

Rimay reads from and writes to data pools. The script below creates one for input and one for output, using your Personal Access Token (PAT):

In [ ]:

python
# quickstart.py, part 2: the data pools
import io
import os
from dotenv import load_dotenv
from qhub.api.platform import HubPlatformClient

load_dotenv()
platform = HubPlatformClient(api_key=os.getenv("KQH_PERSONAL_ACCESS_TOKEN"))

input_dp = platform.data_pools.create_data_pool(name="Rimay Quickstart Input")
output_dp = platform.data_pools.create_data_pool(name="Rimay Quickstart Output")
with open("data.json", "rb") as fh:
    platform.data_pools.add_data_pool_file(id=input_dp.id, file=("data.json", io.BytesIO(fh.read())))
print("input", input_dp.id, "output", output_dp.id)

Step 5: Run Rimay

Rimay authenticates with your key pair. By additionally sharing the data pools, the service can read and write input_data_pool and output_data_pool.

In [ ]:

python
# quickstart.py, part 3: the run
from qhub.service.client import HubServiceClient
from qhub.service.datapool import DataPoolGrant, DataPoolPermission

key_id = os.getenv("KQH_ACCESS_KEY_ID")
app_id = next((a.id for a in platform.applications.get_applications()
               if any(k.access_key_id == key_id
                      for k in platform.applications.get_application_access_keys(a.id))), None)
if app_id is None:
    raise SystemExit("No application of this PAT owns the key pair. Use a PAT and keys from the same Hub account.")

service = HubServiceClient(
    service_endpoint=(
        "https://gateway.hub.kipu-quantum.com/kipu-quantum/"
        "rimay---quantum-feature-extraction---simulator/1.0.0"
    ),
    access_key_id=key_id,
    secret_access_key=os.getenv("KQH_SECRET_ACCESS_KEY"),
    platform_client=platform,
)

execution = service.run(
    request={
        "_mode": "fit_transform",   # fit on train, transform train and test
        "_fit_reference": "None",   # no saved model: fit a new one
        "num_shots": 2000,
        "num_runs": 1,
    },
    grants=[
        DataPoolGrant(name="input_data_pool", datapool_id=input_dp.id,
                      application_id=app_id, permission=DataPoolPermission.VIEW),
        DataPoolGrant(name="output_data_pool", datapool_id=output_dp.id,
                      application_id=app_id, permission=DataPoolPermission.MODIFY),
    ],
)
execution.wait_for_final_state(timeout=900, wait=10)
print("status:", execution.status)

# SUCCEEDED covers the whole run. An error inside it shows up in the result.
error = execution.result().model_dump().get("ErrorResult")
if error:
    raise SystemExit(error["message"])

This example runs in under a minute. Larger tables take longer.


Step 6: Fetch the results

Rimay writes six files to the output pool: Xc_train, Xq_train_0, y_train, Xc_test, Xq_test_0 and y_test. Xc holds the classical features, Xq the quantum features. The .csv files hold the same quantum features, but as tables.

In [ ]:

python
# quickstart.py, part 4: the results
for f in platform.data_pools.get_data_pool_files(id=output_dp.id):
    if f.name.endswith(".npy"):
        for attempt in range(3):   # a download can arrive cut short: check its length, retry
            with open(f.name, "wb") as fp:
                for chunk in platform.data_pools.get_data_pool_file(id=output_dp.id, file_id=f.id):
                    fp.write(chunk)
            if not f.content_length or os.path.getsize(f.name) == f.content_length:
                break
        else:
            raise IOError(f"{f.name} arrived incomplete. Run this step again.")

Xc_train = np.load("Xc_train.npy")
Xq_train = np.load("Xq_train_0.npy")
n_c, n_q = Xc_train.shape[1], Xq_train.shape[1]
print(f"classical {n_c}, quantum {n_q}")
assert n_q == 2 * n_c - 1

By the way, feature and qubit interactions are based on the native connectivity map of the hardware.


Step 7: Classify with the new features

The quantum features are ordinary columns, row-aligned with your data. You can use them to train any model:

In [ ]:

python
# quickstart.py, part 5: classify
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score

y_train, y_test = np.load("y_train.npy"), np.load("y_test.npy")
Xc_test, Xq_test = np.load("Xc_test.npy"), np.load("Xq_test_0.npy")

for name, train, test in (
    ("classical", Xc_train, Xc_test),
    ("classical + quantum", np.hstack([Xc_train, Xq_train]), np.hstack([Xc_test, Xq_test])),
):
    model = LogisticRegression(max_iter=1000).fit(train, y_train)
    print(f"{name}: test accuracy {accuracy_score(y_test, model.predict(test)):.2f}")

The full lab goes into more detail about how to use the results.


Step 8 (optional): Delete the data pools

In [ ]:

python
# quickstart.py, part 6: clean up
for dp in (input_dp, output_dp):
    for f in platform.data_pools.get_data_pool_files(id=dp.id):
        platform.data_pools.delete_data_pool_file(id=dp.id, file_id=f.id)
    platform.data_pools.delete_data_pool(id=dp.id)
print("data pools deleted")

Last tested on the Kipu Quantum Hub · 3 December 2026

© 2026 Kipu Quantum GmbH. All rights reserved.

How was this session?

Do the features help your model?

Get a free Hub account

Free plan includes a 5€ trial credit.