Skip to main content

How to track your workloads

In the Haiqu SDK, you can make use of experiment tracking to keep your circuits and jobs organized. Every circuit you log and/or execute is connected to an experiment. So are the jobs that you run. Let’s see how this works in the following simple example:
1

Initialize an Experiment

Create a new experiment to keep your circuits and jobs organized.
from haiqu.sdk import haiqu

# Login with your API key
haiqu.login()

# Create a new experiment
haiqu.init("Hello Quantum World!")
All your circuits and jobs will now be tracked under this experiment until you initialize a new one.
2

View and Switch Experiments

List your experiments and switch between them as needed.
# View all experiments
haiqu.list_experiments()

# Switch to another experiment
haiqu.init("Hello Again!")
If you don’t create an experiment, a default one is used automatically.
3

Log a Circuit

Add circuits to your experiment for tracking and re-use.
from qiskit import QuantumCircuit

# Create a Bell state circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

# Log the circuit
haiqu_circuit = haiqu.log(qc, name="Bell state", description="A simple Bell state circuit")

# View all circuits in the current experiment
haiqu.list_circuits()
You can now track, analyze, and re-run the logged circuits later.
4

Run a Job

Execute your logged circuit and track the job’s progress.
# Run the circuit on a simulator
job = haiqu.run(
    circuits=haiqu_circuit,
    shots=1000,
    device_id="aer_simulator",
    job_name="Bell state execution",
    job_description="Executing Bell state on Aer simulator"
)

# Monitor progress
job.progress()

# Check status
print(job.retrieve_status())

# View all jobs in the current experiment 
haiqu.list_jobs()
Jobs are automatically linked to the experiment and circuit.
5

Retrieve Past Work

Easily load circuits or jobs from your history.
# Get a circuit by ID
loaded_circuit = haiqu.get_circuit(haiqu_circuit.id)
haiqu.draw(loaded_circuit)

# Get a job by ID and check status
loaded_job = haiqu.get_job(job.id)
loaded_job.retrieve_status()
You can also search jobs by the circuit they executed using haiqu.list_jobs(circuit=<circuit_id>).

Other useful functions

Here are some additional features you can use when working with experiments:

Retrieve experiments in different forms

haiqu.list_experiments(widget=False)               # List of Experiment objects
haiqu.list_experiments(widget=False, pandas=True)  # Pandas DataFrame

List circuits from another experiment

haiqu.list_circuits(experiment_id=<experiment_id>)

Access job logs

print(job.logs)