CombineRegistersNode
class samplomatic.samplex.nodes.CombineRegistersNode(output_type: VirtualType, output_register_name: str, num_output_subsystems: int, operands: dict[str, tuple[Sequence[int], Sequence[int], VirtualType]])
Bases: EvaluationNode
Composes one or more registers into a new register.
The registers are composed in the order of operands.
The new register can be larger than any of the registers being composed. In this case, any slice of the new register that remains untouched is initialized to identity. Therefore, this node can be used for virtual gate multiplication of registers of the same type, for tensoring subsystems, for slicing registers, for implicit identity insertion, and for subsystem reordering.
Parameters
- output_type – What type of register type to collect into.
- output_register_name – The name of the output register.
- num_output_subsystems – The number of subsystems of the output register.
- operands – A map from register names to tuples
(source_idxs, destination_idxs, input_type)wheresource_idxsslices the input register,destination_idxsis of the same length and slices the output register, dictating the location into which to multiply, andinput_typeis the type of the input register. The order of this map is in standard matrix multiplication order.
Raises
- SamplexConstructionError – If some pair of input and output indices don’t match size.
- SamplexConstructionError – If an output index is not in
[0, .., num_output_subsystems-1]. - SamplexConstructionError – If there is not at least one register.
Attributes Summary
Column 1 | Column 2 |
|---|---|
outgoing_register_type | The virtual gate type of outgoing registers. |
Methods Summary
Column 1 | Column 2 |
|---|---|
evaluate(registers, *_) | Evaluate this node. |
get_style() | Return the style of this node when plotted. |
instantiates() | Return a manifest of new virtual registers that this node instantiates. |
reads_from() | Return a manifest of which virtual register values this node needs to read from. |
validate_and_update(register_descriptions) | Validate provided register descriptions are compatible, update with changes. |
Attributes Documentation
outgoing_register_type
Methods Documentation
evaluate
evaluate(registers, *_)
Evaluate this node.
Parameters
- registers – At least those registers needed by this node to read from or write to.
- parameter_values – Parameter values to use during evaluation.
Raises
SamplexRuntimeError – If the number of parameter values received does not equal the number required by this node.
get_style
instantiates
instantiates()
Return a manifest of new virtual registers that this node instantiates.
- To change the type or size of a register, both instantiate and remove it.
- Do not specify
reads_from()orwrites_to()for an instantiated register, these powers are implicit.
reads_from
validate_and_update
validate_and_update(register_descriptions)
Validate provided register descriptions are compatible, update with changes.
This method can be used by a samplex to determine when a node execution order has well-defined dependencies before sampling begins.
Parameters
register_descriptions – A map from existing register names to their size and type.