---
title: ConversionNode (latest version)
description: API reference for samplomatic.samplex.nodes.ConversionNode in the latest version of samplomatic
source: https://quantum.cloud.ibm.com/docs/en/api/samplomatic/auto/samplex-nodes-conversion-node
---

# ConversionNode

*class* `samplomatic.samplex.nodes.ConversionNode(existing_name: str, existing_type: VirtualType, new_name: str, new_type: VirtualType, num_subsystems: int, remove_existing: bool)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/conversion_node.py#L21-L114)

Bases: [`EvaluationNode`](/docs/api/samplomatic/auto/samplex-nodes-evaluation-node "samplomatic.samplex.nodes.evaluation_node.EvaluationNode")

Converts a node from one type to another.

**Parameters**

- **existing\_name** – The name of the register to convert.
- **existing\_type** – The type of the register to convert.
- **new\_name** – The name of the the converted register, possibly equal to `existing_name`.
- **new\_type** – The type to convert to.
- **num\_subsystems** – The number of subsystems in the register to convert.
- **remove\_existing** – Whether to remove the existing register following conversion.

**Raises**

[**SamplexConstructionError**](/docs/api/samplomatic/auto/exceptions-samplex-construction-error "samplomatic.exceptions.SamplexConstructionError") – If the names are the same, and `remove_existing` is true.

**Attributes Summary**

|                                                                                                                                                                |                                              |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| [`outgoing_register_type`](#samplomatic.samplex.nodes.ConversionNode.outgoing_register_type "samplomatic.samplex.nodes.ConversionNode.outgoing_register_type") | The virtual gate type of outgoing registers. |

**Methods Summary**

|                                                                                                                                                                               |                                                                                  |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [`evaluate`](#samplomatic.samplex.nodes.ConversionNode.evaluate "samplomatic.samplex.nodes.ConversionNode.evaluate")(registers, \*\_)                                         | Evaluate this node.                                                              |
| [`get_style`](#samplomatic.samplex.nodes.ConversionNode.get_style "samplomatic.samplex.nodes.ConversionNode.get_style")()                                                     | Return the style of this node when plotted.                                      |
| [`instantiates`](#samplomatic.samplex.nodes.ConversionNode.instantiates "samplomatic.samplex.nodes.ConversionNode.instantiates")()                                            | Return a manifest of new virtual registers that this node instantiates.          |
| [`reads_from`](#samplomatic.samplex.nodes.ConversionNode.reads_from "samplomatic.samplex.nodes.ConversionNode.reads_from")()                                                  | Return a manifest of which virtual register values this node needs to read from. |
| [`removes`](#samplomatic.samplex.nodes.ConversionNode.removes "samplomatic.samplex.nodes.ConversionNode.removes")()                                                           | Return a manifest of virtual registers that this node removes.                   |
| [`validate_and_update`](#samplomatic.samplex.nodes.ConversionNode.validate_and_update "samplomatic.samplex.nodes.ConversionNode.validate_and_update")(register\_descriptions) | Validate provided register descriptions are compatible, update with changes.     |

**Attributes Documentation**

### outgoing\_register\_type

**Methods Documentation**

### evaluate

`evaluate(registers, *_)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/conversion_node.py#L91-L94)

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**](/docs/api/samplomatic/auto/exceptions-samplex-runtime-error "samplomatic.exceptions.SamplexRuntimeError") – If the number of parameter values received does not equal the number required by this node.

### get\_style

`get_style()`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/conversion_node.py#L107-L114)

Return the style of this node when plotted.

### instantiates

`instantiates() → dict[str, tuple[int, VirtualType]]`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/conversion_node.py#L67-L68)

Return a manifest of new virtual registers that this node instantiates.

> **Note**
>
> - To change the type or size of a register, both instantiate and remove it.
> - Do not specify [`reads_from()`](#samplomatic.samplex.nodes.ConversionNode.reads_from "samplomatic.samplex.nodes.ConversionNode.reads_from") or `writes_to()` for an instantiated register, these powers are implicit.

### reads\_from

`reads_from()`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/conversion_node.py#L62-L65)

Return a manifest of which virtual register values this node needs to read from.

### removes

`removes() → set[str]`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/conversion_node.py#L70-L71)

Return a manifest of virtual registers that this node removes.

It is assumed that registers are removed as a last step; it is not ill-defined to read and write from a removed register.

### validate\_and\_update

`validate_and_update(register_descriptions)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/conversion_node.py#L73-L89)

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.
