qarp.devices

Devices: architectures, noise models and the compile-for-device pipeline. Public depth: flat. Submodules are private.

class qarp.devices.Architecture(*args, **kwargs)

Bases: object

property edges

Edge list; assigning rebuilds the adjacency indices.

has_directed_edge(self, a: int, b: int) bool
is_connected(self, a: int, b: int) bool
property n_qubits

(self) -> int

property name

(self) -> str

neighbours(self, q: int) list[int]
shortest_path(self, a: int, b: int) list[int]
class qarp.devices.Device(*args, **kwargs)

Bases: object

property architecture

(self) -> qarpx.Architecture | None

check_fits(self, needed: int) None
property directedness

(self) -> bool

property gate_set

(self) -> qarpx.GateSet | None

property n_qubits

(self) -> int

property noise_model

(self) -> qarpx.NoiseModel | None

class qarp.devices.NoiseModel(_inner: NoiseModel | None = None)[source]

Bases: object

Per-gate noise model attached to a qarp.devices.Device.

Ergonomic builders (depolarizing(), pauli(), bit_flip(), amplitude_damping()) cover the common cases. Compose with the + operator (right operand wins on collision).

The underlying C++ object is reachable via inner for callers that need to pass it straight into qx.QarpSimulator.

Parameters:

_inner – existing qx.NoiseModel to wrap (internal use). End users construct via the named class methods.

classmethod amplitude_damping(p: float, gate_set: str | GateSet | Iterable[GateType] | None = '1q') NoiseModel[source]

Amplitude damping (T1-like relaxation) of strength p.

classmethod bit_flip(p: float, gate_set: str | GateSet | Iterable[GateType] | None = '1q') NoiseModel[source]

PauliChannel(p, 0, 0) — flip the qubit with probability p.

classmethod depolarizing(p: float, gate_set: str | GateSet | Iterable[GateType] | None = '2q') NoiseModel[source]

Depolarizing channel of strength p.

1q gates receive PauliChannel(p/3, p/3, p/3); 2q gates receive the uniform 2q depolarizing (each of the 15 non-identity Paulis with weight p/15).

property enabled: bool
has_any_channel() bool[source]
has_channel(gate: GateType) bool[source]
property inner: NoiseModel

Underlying C++ qx.NoiseModel for direct simulator use.

classmethod pauli(p_x: float = 0.0, p_y: float = 0.0, p_z: float = 0.0, gate_set: str | GateSet | Iterable[GateType] | None = '1q') NoiseModel[source]

1q Pauli channel with explicit X/Y/Z weights.

qarp.devices.compile_for_device(*args, router=None)[source]

Run check_fits → rebase → route → rebase against a Device.

Two call forms:

compile_for_device(block, device) -> CompiledCircuit compile_for_device(commands, n_qubits, device) -> CompiledCircuit

The block form is a thin wrapper around the commands form: it calls block.flatten() and reads block.n_qubits for the user.

Parameters:

router – Optional qx.RouterKind selecting the routing implementation (default Sabre; qx.RouterKind.Lite is the simpler greedy sweep).

qarp.devices.get_all_to_all_architecture(n_qubits: int) Architecture[source]

All-to-all connectivity (undirected).

qarp.devices.get_nearest_neighbour_architecture(xdim: int, ydim: int) Architecture[source]

Nearest-neighbour grid connectivity (undirected).

Parameters:
  • xdim – Number of qubits per row.

  • ydim – Number of qubits per column.

Returns:

A qx.Architecture for the requested grid.