---
title: CompressedQpyDataModel (latest version)
description: API reference for ibm_quantum_schemas.common.CompressedQpyDataModel 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-compressed-qpy-data-model
---

# CompressedQpyDataModel

*pydantic model* `CompressedQpyDataModel`

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

Bases: [`QpyDataModel`](/docs/api/qiskit-ibm-runtime/ibm-quantum-schemas-common-qpy-data-model "ibm_quantum_schemas.common.qpy.QpyDataModel"), `Generic`\[`T`]

QPY-encoded Qiskit objects with compression.

### 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#L155-L169)

Check that the encoded qpy information matches expectations.

### from\_python

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

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

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.CompressedQpyDataModel.to_python "ibm_quantum_schemas.common.CompressedQpyDataModel.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.
- **metadata\_serializer** (*type\[JSONEncoder] | None*) – An optional `json.JSONEncoder` class that will be passed to [`qiskit.qpy.dump()`](/docs/api/qiskit/qpy#qiskit.qpy.dump) during QPY serialization. In particular, this encoder overrides the default behaviour of converting Python objects into JSON data.

**Returns**

A new model instance.

**Return type**

*Self*

### to\_python

`to_python(use_cached=False, metadata_deserializer=None)`

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

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.CompressedQpyDataModel.b64_data "ibm_quantum_schemas.common.CompressedQpyDataModel.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).
- **metadata\_deserializer** (*type\[JSONDecoder] | None*) – An optional `json.JSONDecoder` class that will be forwarded to ``qiskit.qpy.load`()`` when deserializing QPY data. In particular, this controls how JSON-serialized circuit metadata are instantiated into Python objects at load time.

**Returns**

Python data.

**Return type**

list\[*T*]
