Skip to main content
IBM Quantum Platform

VirtualRegister

class samplomatic.virtual_registers.VirtualRegister(virtual_gates: ndarray)

GitHub

Bases: object

A data register containing a 2D array of virtual gates.

Each virtual gate itself has a shape equal to GATE_SHAPE, so the number of dimensions of the array owned by a virtual register is actually 2 plus one for each member of gate shape. The first two axes of the array are respectively reserved to represent the number of subsystems and the number of samples. For example, a virtual register representing 2-qubit unitaries might have an array of shape (5, 6, 4, 4) to store a 5x6 array of 4x4 complex unitary matrices.

Parameters

virtual_gates – The virtual gates in this register.

Raises

VirtualGateError – If virtual_gates’ shape is not understood.

Attributes Summary

Column 1
Column 2
CONVERTABLE_TYPESValid arguments for convert_to().
DTYPEThe data type of gate array elements.
GATE_SHAPEThe array shape of any single virtual gate.
SUBSYSTEM_SIZEThe number of qubits each virtual gate acts on.
TYPEThe group name in 1-1 correspondence with this virtual gate type.
num_samplesThe number of samples in this register.
num_subsystemsThe number of subsystems in this register.
shapeThe shape of this register, excluding the trailing shape due to gate shape.
sizeThe total number of virtual gates in this register.
virtual_gatesThe virtual gates of the virtual gates in this register.

Methods Summary

Column 1
Column 2
convert_to(register_type)Convert this register type to some other type, if possible.
copy()Generate a copy of this virtual register.
empty(num_subsystems, num_samples)Instantiate a new register.
identity(num_subsystems, num_samples)Instantiate a new register of identity virtual gates.
select(register_type)Select a VirtualRegister subclass based on a VirtualType enum.

Attributes Documentation

CONVERTABLE_TYPES

Type: frozenset[VirtualType]

Default value: frozenset({})

Valid arguments for convert_to().

DTYPE

Type: dtype

Default value: NotImplemented

The data type of gate array elements.

GATE_SHAPE

Type: tuple[int, ...]

Default value: NotImplemented

The array shape of any single virtual gate.

SUBSYSTEM_SIZE

Type: int

Default value: NotImplemented

The number of qubits each virtual gate acts on.

TYPE

Type: VirtualType

Default value: NotImplemented

The group name in 1-1 correspondence with this virtual gate type.

num_samples

The number of samples in this register.

num_subsystems

The number of subsystems in this register.

shape

The shape of this register, excluding the trailing shape due to gate shape.

size

The total number of virtual gates in this register.

virtual_gates

The virtual gates of the virtual gates in this register.

Methods Documentation

convert_to

convert_to(register_type: VirtualType) → VirtualRegister

GitHub

Convert this register type to some other type, if possible.

Parameters

register_type – The type of register to convert to.

Returns

A new register of the specified output type, or this instance if its type is register_type.

Raises

VirtualGateError – If this type cannot be converted to the specified type.

copy

copy() → VirtualRegister

GitHub

Generate a copy of this virtual register.

empty

classmethod empty(num_subsystems: int, num_samples: int) → T

GitHub

Instantiate a new register.

The array element values are not initialized to any value, so it is expected that the user of this constructor overwrites them all.

identity

abstractmethod classmethod identity(num_subsystems: int, num_samples: int) → T

GitHub

Instantiate a new register of identity virtual gates.

select

static select(register_type: VirtualType) → type[VirtualRegister]

GitHub

Select a VirtualRegister subclass based on a VirtualType enum.

Note

Not all VirtualRegisters need to define a TYPE, though they will need to if they want to participate in many types of Node actions. Conversely, not every VirtualType must correspond to a VirtualRegister, most notably intermediate abstractions like VirtualType can correspond to at most one VirtualRegister type.

Parameters

register_type – The identifier of the type to select.

Returns

The unique subclass associated with the register_type, if any.

Was this page helpful?
Report a bug, typo, or request content on GitHub.