cosmiq.library.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.
Needs the extra: pip install "cosmiq[qiskit]".
zz_map,iqp_map,random_map: aFeatureMap, the circuit with its register and device;probabilities: the output distribution, from the digital path’s simulator;kernel: the fidelity kernel \(|\langle \varphi(x) | \varphi(x') \rangle|^2\), exact, or sampled throughcosmiq.qiskit.SamplerV2.
Qiskit’s random_iqp draws couplings between every pair. On a register, random_map draws the
same integers (0-7) on the CZ pairs only and builds with Qiskit’s iqp.
A circuit on |
|
The register's CZ graph on |
|
Qiskit's |
|
\(K[i, j] = |\langle \varphi(x1_i) | \varphi(x2_j) \rangle|^2\), [len(x1), len(x2)] float64 (x2 = x1 by default). |
|
The output distribution of |
|
A random IQP circuit on the register's CZ graph: integers 0-7 (numpy's default_rng(seed)) on the diagonal and the CZ pairs, built with Qiskit's |
|
Qiskit's |
Classes
- class cosmiq.library.iqp.FeatureMap(circuit: QuantumCircuit, register: Register, device: str)#
Bases:
objectA circuit on
register‘s atoms (qubit q is atom q), fordevice‘s digital profile. Its parameters, if any, are the data:num_featuresof them, incircuit.parameters‘ order.- circuit: QuantumCircuit#
- property transpiled: QuantumCircuit#
The circuit on
cosmiq.qiskit.target(device, register): the trivial layout, and no routing at all (routing_method="none"raises if a SWAP were needed).
Functions
- cosmiq.library.iqp.cz_pairs(register: Register, device: str = 'cosmiq-ref-1') list[tuple[int, int]]#
The register’s CZ graph on
device‘s digital profile: each pair (i, j), i < j, within itscz_range_um.
- cosmiq.library.iqp.iqp_map(register: Register, interactions: object, *, device: str = 'cosmiq-ref-1') FeatureMap#
Qiskit’s
iqp(interactions): an n x n symmetric integer matrix, the T powers on its diagonal and the CS powers above it. Off the diagonal, only the register’s CZ pairs may be non-zero (LIB_CZ_GRAPH).
- cosmiq.library.iqp.kernel(x1: object, x2: object = None, *, feature_map: FeatureMap, shots: int | None = None, seed: int | None = None) Tensor#
\(K[i, j] = |\langle \varphi(x1_i) | \varphi(x2_j) \rangle|^2\), [len(x1), len(x2)] float64 (x2 = x1 by default).
Exact from the simulator’s states, or with
shots=the fraction of all-zero outcomes of \(\varphi(x2_j)^\dagger \varphi(x1_i)\) throughcosmiq.qiskit.SamplerV2(noise off, seeded byseed).
- cosmiq.library.iqp.probabilities(feature_map: FeatureMap, values: object = None) Tensor#
The output distribution of
feature_mapwith its parameters bound tovalues(none for a map without), \([2^n]\) float64 in Qiskit’s order (qubit 0 the lowest bit), from the digital path’s own simulator, noise off.
- cosmiq.library.iqp.random_map(register: Register, *, seed: int, device: str = 'cosmiq-ref-1') FeatureMap#
A random IQP circuit on the register’s CZ graph: integers 0-7 (numpy’s default_rng(seed)) on the diagonal and the CZ pairs, built with Qiskit’s
iqp.
- cosmiq.library.iqp.zz_map(register: Register, reps: int = 2, *, device: str = 'cosmiq-ref-1') FeatureMap#
Qiskit’s
zz_feature_mapwith one feature per atom,repsrepetitions, and its ZZ terms on the register’s CZ pairs only.