A 2D register of qubits which includes their coordinates.
It is needed for e.g. analog computing.
The coordinates are ignored in backends that don't need them. The easiest
way to construct a register is via its classmethods like Register.triangular_lattice
.
PARAMETER |
DESCRIPTION |
support |
A graph or number of qubits. Nodes can include a "pos" attribute
such that e.g.: graph.nodes = {0: {"pos": (2,3)}, 1: {"pos": (0,0)}, ...} which
will be used in backends that need qubit coordinates.
See the classmethods for simple construction of some predefined lattices if you
don't want to build a graph manually.
If you pass an integer the resulting register is the same as
Register.all_to_all(n_qubits) .
TYPE:
Graph | int
|
spacing |
Value set as the distance between the two closest qubits.
TYPE:
float | None
DEFAULT:
1.0
|
Examples:
Source code in qadence/register.py
| def __init__(
self,
support: nx.Graph | int,
spacing: float | None = 1.0,
device_specs: RydbergDevice = DEFAULT_DEVICE,
):
"""
A 2D register of qubits which includes their coordinates.
It is needed for e.g. analog computing.
The coordinates are ignored in backends that don't need them. The easiest
way to construct a register is via its classmethods like `Register.triangular_lattice`.
Arguments:
support: A graph or number of qubits. Nodes can include a `"pos"` attribute
such that e.g.: `graph.nodes = {0: {"pos": (2,3)}, 1: {"pos": (0,0)}, ...}` which
will be used in backends that need qubit coordinates.
See the classmethods for simple construction of some predefined lattices if you
don't want to build a graph manually.
If you pass an integer the resulting register is the same as
`Register.all_to_all(n_qubits)`.
spacing: Value set as the distance between the two closest qubits.
Examples:
```python exec="on" source="material-block" result="json"
from qadence import Register
reg = Register.honeycomb_lattice(2,3)
reg.draw()
```
"""
if device_specs is not None and not isinstance(device_specs, RydbergDevice):
raise ValueError("Device specs are not valid. Please pass a `RydbergDevice` instance.")
self.device_specs = device_specs
self.graph = support if isinstance(support, nx.Graph) else alltoall_graph(support)
if spacing is not None and self.min_distance != 0.0:
_scale_node_positions(self.graph, self.min_distance, spacing)
|