cosmiq.library#

The algorithm library (see its guide): textbook methods on cosmiq’s programs.

from cosmiq.library import graphs, iqp, mis, reservoir

reg, g = graphs.kings(3, 4, filling=mask, device="cosmiq-ref-1")
res = cq.Emulator().run(mis.program(reg)(), shots=1000, seed=1)
rep = mis.report(mis.postprocess(res, g), g)
F = reservoir.Reservoir(reg, "cosmiq-ref-1", window=4, segment=0.5).features(U)
K = iqp.kernel(X1, X2, feature_map=iqp.zz_map(reg, reps=2))
  • graphs: Graph, the kings, square and triangular lattices and given positions, refused unless their unit-disk graph is clean (LIB_MARGIN);

  • mis: the sweep, the post-processing, exact answers up to 24 vertices, a report;

  • reservoir: windowed detuning segments, their exact or sampled features, a ridge readout, polynomial baselines and NARMA2;

  • iqp: Qiskit’s IQP and ZZ maps on the register’s CZ graph, their distribution on the digital path’s simulator, and the fidelity kernel. It needs the qiskit extra, and is loaded on first use.

No quantum benefit is claimed for any of them.

graphs

cosmiq.library.graphs: graphs on atoms, and the lattices whose unit-disk graph the device's interaction makes.

iqp

cosmiq.library.iqp: IQP circuits and the ZZ feature map, built with Qiskit's own iqp and zz_feature_map and restricted to the register's CZ graph, so they transpile with no SWAPs.

mis

cosmiq.library.mis: maximum independent sets on the unit-disk graph of a register, after Pichler et al. 2018 and Ebadi et al. 2022.

reservoir

cosmiq.library.reservoir: a windowed reservoir with a ridge readout, after Fujii & Nakajima 2017 and Bravo et al. 2022, and the NARMA2 task (Atiya & Parlos 2000).

Graph

An undirected simple graph on vertices 0..n-1 (vertex i is atom i).

Submodules

Classes

class cosmiq.library.Graph(n: int, edges: Iterable[tuple[int, int]] = ())#

Bases: object

An undirected simple graph on vertices 0..n-1 (vertex i is atom i).

property n: int#
property edges: tuple[tuple[int, int], ...]#

Every edge once, as (i, j) with i < j, sorted.

property adjacency: NDArray[bool]#

The [n, n] read-only adjacency matrix.

degrees() → NDArray[int64]#

Each vertex’s number of neighbours.

neighbours(i: int) → tuple[int, ...]#
independent(bits: object) → NDArray[bool]#

Per shot: no two chosen vertices share an edge. bits as mis.postprocess takes.

maximal(bits: object) → NDArray[bool]#

Per shot: independent, and no vertex can be added.

__len__() → int#