Skip to main content

Haiqu.log(self, parent_ctx: CircuitModel | QuantumCircuit | Any = None, child_ctx: Any = None, name: str = None, description: str = None) -> str | CircuitModel:

Record data to the Haiqu cloud based on the context (e.g., circuit, or any other relevant information). This method functions similarly to a generic logger, in the same vein as the log method of the Weights & Biases Python SDK for machine learning.
  • Parameters:
    • parent_ctx — The input object to be logged.
    • child_ctx — An optional child object, linked to the context of the parent.
    • name — An optional name for the logged object.
    • description — An optional description if logging a circuit.
  • Returns: Status message, circuit metadata object.
  • Return type: str | CircuitModel

Examples

If used without parameters, haiqu.log() displays the nice widget with help. Try it out:
haiqu.log()
This function always acts in the context of the current experiment. If the circuit metadata object (CircuitModel) is passed as the first argument, it will log data to that circuit.

Log metrics

haiqu.log(12.34, name="Some value")
haiqu.log("Hello quantum world!", name="Some textual value")
haiqu.log([1, 2, 3], name="Experiment parameters")

# W&B style:
haiqu.log({"examples": ["one", "two", "three"]})
haiqu.log({"some_value": 12.34, "some_text": "Quantum!", "parameters": [1, 2, 3]})

Log a circuit

from qiskit.circuit.random import random_circuit

qc = random_circuit(num_qubits=4, depth=1, max_operands=4, measure=True)
meta = haiqu.log(qc)

# or with name/description:
meta = haiqu.log(qc, name="Hello", description="World!")

# log artifact/metric to the circuit:
haiqu.log(meta, 42)

Log the Matplotlib plt object

import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6], label="Label")

haiqu.log(plt, name="Awesome plot")
# or W&B style:
# haiqu.log({"chart": plt})

Log the Pandas DataFrame

import pandas as pd
data = {
    "columns": [0, 1, 2],
    "data": [50, 40, 45]
}
df = pd.DataFrame(data)

haiqu.log(df, name="My DataFrame")

Log the Drawer plot

from haiqu.sdk.wiz.drawer import Drawer

drawer = Drawer()
drawer.plot([1, 2, 3], [4, 5, 6])

haiqu.log(drawer, name="Cool drawer plot")

Log the Matplotlib figure

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([1, 2, 3], [4, 5, 6], label="Test Plot")
...

haiqu.log(fig, name="Awesome figure")
You can see logged data on Dashboard: https://dashboard.haiqu.ai