cosmiq#

Train neutral-atom quantum programs like neural networks.

cosmiq is an open-source Python library for building and training programs for neutral-atom quantum computers.

It is for researchers and engineers working on quantum machine learning and hybrid quantum-classical algorithms. You describe how lasers drive a group of atoms, choose which settings should be learned, and train them with PyTorch, the same way you would train a neural network.

cosmiq simulates the atoms on a laptop or a GPU, computes the gradients that training needs, and checks every program against what the device can actually do, so what you train stays within the hardware’s limits. It works inside PennyLane and Qiskit, and exports programs to Pulser and Amazon Braket.

pip install cosmiq · Apache-2.0 · Python 3.11–3.13 · Status: alpha (v0.1)

Key features#

  • Neutral-atom programs in PyTorch. Programs are ordinary PyTorch modules, checked against the device as you build them, with clear errors when something is out of range.

  • Gradients for training. Exact gradients in simulation, and the sampled estimates that real hardware would need.

  • Simulators from laptop to GPU. From a few atoms on a laptop to larger systems on a GPU, with or without noise.

  • Realistic devices. A bundled reference device with calibrated noise and atom loss.

  • Works with the tools you use. PennyLane and Qiskit, and exports to Pulser and Amazon Braket.

  • Long runs, safely. Checkpoints, stop and resume, and runs on remote GPU boxes.

  • Honest about its limits. Every claim is backed by a test, and anything untested is refused rather than guessed. See Claims and limits.

A first program#

import torch
import cosmiq as cq
from cosmiq.emulator import density
from cosmiq.units import MHz, us

t = [0.0, 0.2 * us, 0.8 * us, 1.0 * us]  # on the device's 4 ns clock
program = cq.program(
    cq.Register.chain(3, spacing=6.1),  # µm
    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")  # checked against the device; ConstraintError if not

emulator = cq.Emulator(observable=density())  # the CPU, complex128
optimizer = torch.optim.Adam(program.parameters(), lr=0.1)
for _ in range(5):
    optimizer.zero_grad()
    loss = -emulator(program())[0].sum()  # maximise the Rydberg population
    loss.backward()  # exact gradients, through the device's rounding
    optimizer.step()

Your first program runs this, and the same gradient from shots, at every build of this site.

Made by Identity Quantum Computing.