---
title: QpyDataModel (latest version)
description: API reference for ibm_quantum_schemas.common.QpyDataModel in the latest version of qiskit-ibm-runtime
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit-ibm-runtime/ibm-quantum-schemas-common-qpy-data-model
---

# QpyDataModel

*pydantic model* `QpyDataModel`

[GitHub](https://github.com/Qiskit/ibm-quantum-schemas/tree/0.10.20260723/ibm_quantum_schemas/common/qpy.py#L78-L149)

Bases: `BaseModel`, `Generic`\[`T`]

QPY-encoded Qiskit objects.

### b64\_data

*field*

Type: `str`

Base-64 encoded data of the QPY serialization of some Qiskit objects.

**Validated by**

- `cross_validate_qpy_info`

### num\_programs

*field*

Type: `int`

The number of distinct elements in the Python encoding.

**Constraints**

- **ge** = 1

**Validated by**

- `cross_validate_qpy_info`

### qpy\_version

*field*

Type: `int`

The QPY encoding version.

**Constraints**

- **ge** = 10

**Validated by**

- `cross_validate_qpy_info`

### cross\_validate\_qpy\_info

*validator* `cross_validate_qpy_info`

[GitHub](https://github.com/Qiskit/ibm-quantum-schemas/tree/0.10.20260723/ibm_quantum_schemas/common/qpy.py#L92-L106)

Check that the encoded qpy information matches expectations.

### from\_python

*classmethod* `from_python(data, qpy_version=17)`

[GitHub](https://github.com/Qiskit/ibm-quantum-schemas/tree/0.10.20260723/ibm_quantum_schemas/common/qpy.py#L127-L149)

Create a model instance from Python data of the correct type.

The returned instance owns a reference to the provided data. This instance may be returned by [`to_python()`](#ibm_quantum_schemas.common.QpyDataModel.to_python "ibm_quantum_schemas.common.QpyDataModel.to_python") depending on the value of `use_cached`. Users of this class are responsible for managing cached instances of the data and possible side-effects of their mutations.

**Parameters**

- **data** (*list\[T]*) – The data to base64 encode in the new model instance.
- **qpy\_version** (*int*) – The QPY version to encode with.

**Returns**

A new model instance.

**Return type**

*Self*

### to\_python

`to_python(use_cached=False)`

[GitHub](https://github.com/Qiskit/ibm-quantum-schemas/tree/0.10.20260723/ibm_quantum_schemas/common/qpy.py#L108-L125)

Return a Python representation of the encoded data in the model.

When `use_cached` is false, or when no cached version exists, [`b64_data`](#ibm_quantum_schemas.common.QpyDataModel.b64_data "ibm_quantum_schemas.common.QpyDataModel.b64_data") is decoded and loaded into a new Python instance. Users of this class are responsible for managing cached instances of the Python data and possible side-effects of their mutations.

**Parameters**

**use\_cached** (*bool*) – Whether to return the cached instance (if it exists).

**Returns**

Python data.

**Return type**

list\[*T*]
