Skip to main content
IBM Quantum Platform
This page is from a dev version of Qiskit Runtime client. This is a new interface that does not exist in the stable version.

CompressedQpyDataModel

pydantic model CompressedQpyDataModel

GitHub

Bases: QpyDataModel, Generic[T]

QPY-encoded Qiskit objects with compression.

b64_data

field

Type: str [Required]

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

Validated by

  • cross_validate_qpy_info

num_programs

field

Type: int [Required]

The number of distinct elements in the Python encoding.

Constraints

  • ge = 1

Validated by

  • cross_validate_qpy_info

qpy_version

field

Type: int [Required]

The QPY encoding version.

Constraints

  • ge = 10

Validated by

  • cross_validate_qpy_info

cross_validate_qpy_info

validator cross_validate_qpy_info

GitHub

Check that the encoded qpy information matches expectations.

from_python

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

GitHub

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() 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() 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

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

When use_cached is false, or when no cached version exists, 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]

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