Check your install#

Run these in the environment you installed cosmiq into. The outputs shown come from this site’s build, on Linux with every extra installed.

The versions#

import numpy
import torch

import cosmiq as cq

print("cosmiq", cq.__version__)
print("torch", torch.__version__, "numpy", numpy.__version__)
cosmiq 0.1.0
torch 2.14.1+cpu numpy 2.5.4

A small run#

A program checked against the reference device and simulated once. If this prints how excited each of the three atoms ends up, the core works.

from cosmiq.emulator import density
from cosmiq.units import MHz, us

t = [0.0, 0.2 * us, 0.8 * us, 1.0 * us]
program = cq.program(
    cq.Register.chain(3, spacing=6.1),
    lambda p: cq.GlobalDrive(
        amplitude=cq.pwl(t, [0.0, p["omega"], p["omega"], 0.0]),
        detuning=cq.pwl(t, [p["start"], p["start"], p["stop"], p["stop"]]),
    ),
    {"omega": 1.5 * MHz, "start": -2.0 * MHz, "stop": 2.0 * MHz},
).to_target("cosmiq-ref-1")

with torch.no_grad():
    print(cq.Emulator(observable=density())(program()))
tensor([[0.7044, 0.2420, 0.7044]], dtype=torch.float64)

The extras#

Which optional parts this environment can import:

import importlib.util

for extra, module in [
    ("pennylane", "pennylane"),
    ("qiskit", "qiskit"),
    ("qec", "stim"),
    ("verify", "cryptography"),
]:
    found = importlib.util.find_spec(module) is not None
    print(f"{extra:10s} {'installed' if found else 'not installed'}")
pennylane  installed
qiskit     installed
qec        installed
verify     installed

With the pennylane extra, the device loads by name:

import pennylane as qml

device = qml.device("cosmiq.emulator", wires=2)
print(type(device).__name__)
EmulatorDevice

The pennylane, qiskit and qec extras aren’t available on Intel Macs (Installation), so there the last cell fails with ModuleNotFoundError.

Next#

Your first program.