Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.
Important

IBM Quantum Platform is moving and this version will be sunset on July 1. To get started on the new platform, read the migration guide.

qiskit.circuit.qpy_serialization.load

load(file_obj)

GitHub

Load a QPY binary file

This function is used to load a serialized QPY circuit file and create QuantumCircuit objects from its contents. For example:

from qiskit.circuit import qpy_serialization
 
with open('bell.qpy', 'rb') as fd:
    circuits = qpy_serialization.load(fd)

or with a gzip compressed file:

import gzip
from qiskit.circuit import qpy_serialization
 
with gzip.open('bell.qpy.gz', 'rb') as fd:
    circuits = qpy_serialization.load(fd)

which will read the contents of the qpy and return a list of QuantumCircuit objects from the file.

Parameters

file_obj (File) – A file like object that contains the QPY binary data for a circuit

Returns

List of QuantumCircuit

The list of QuantumCircuit objects contained in the QPY data. A list is always returned, even if there is only 1 circuit in the QPY data.

Return type

list

Raises

QiskitError – if file_obj is not a valid QPY file

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