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.providers.basicaer.UnitarySimulatorPy

class UnitarySimulatorPy(configuration=None, provider=None, **fields)

GitHub

Python implementation of a unitary simulator.

Initialize a backend class

Parameters

  • configuration (BackendConfiguration) – A backend configuration object for the backend object.
  • provider (qiskit.providers.Provider) – Optionally, the provider object that this Backend comes from.
  • fields – kwargs for the values to use to override the default options.

Raises

AttributeError – if input field not a valid options

__init__

__init__(configuration=None, provider=None, **fields)

Initialize a backend class

Parameters

  • configuration (BackendConfiguration) – A backend configuration object for the backend object.
  • provider (qiskit.providers.Provider) – Optionally, the provider object that this Backend comes from.
  • fields – kwargs for the values to use to override the default options.

Raises

AttributeError – if input field not a valid options


Methods

__init__([configuration, provider])Initialize a backend class
configuration()Return the backend configuration.
name()Return the backend name.
properties()Return the backend properties.
provider()Return the backend Provider.
run(qobj, **backend_options)Run qobj asynchronously.
run_experiment(experiment)Run an experiment (circuit) and return a single experiment result.
set_options(**fields)Set the options fields for the backend
status()Return the backend status.

Attributes

DEFAULT_CONFIGURATION
DEFAULT_OPTIONS
MAX_QUBITS_MEMORY
optionsReturn the options for the backend
version

configuration

configuration()

Return the backend configuration.

Returns

the configuration for the backend.

Return type

BackendConfiguration

name

name()

Return the backend name.

Returns

the name of the backend.

Return type

str

options

Return the options for the backend

The options of a backend are the dynamic parameters defining how the backend is used. These are used to control the run() method.

properties

properties()

Return the backend properties.

Returns

the configuration for the backend. If the backend does not support properties, it returns None.

Return type

BackendProperties

provider

provider()

Return the backend Provider.

Returns

the Provider responsible for the backend.

Return type

Provider

run

run(qobj, **backend_options)

Run qobj asynchronously.

Parameters

  • qobj (Qobj) – payload of the experiment
  • backend_options (dict) – backend options

Returns

derived from BaseJob

Return type

BasicAerJob

Additional Information:

backend_options: Is a dict of options for the backend. It may contain
    * "initial_unitary": matrix_like
    * "chop_threshold": double
 
The "initial_unitary" option specifies a custom initial unitary
matrix for the simulator to be used instead of the identity
matrix. This size of this matrix must be correct for the number
of qubits inall experiments in the qobj.
 
The "chop_threshold" option specifies a truncation value for
setting small values to zero in the output unitary. The default
value is 1e-15.
 
Example::
 
    backend_options = {
        "initial_unitary": np.array([[1, 0, 0, 0],
                                     [0, 0, 0, 1],
                                     [0, 0, 1, 0],
                                     [0, 1, 0, 0]])
        "chop_threshold": 1e-15
    }

run_experiment

run_experiment(experiment)

Run an experiment (circuit) and return a single experiment result.

Parameters

experiment (QobjExperiment) – experiment from qobj experiments list

Returns

A result dictionary which looks something like:

{
"name": name of this experiment (obtained from qobj.experiment header)
"seed": random seed used for simulation
"shots": number of shots used in the simulation
"data":
    {
    "unitary": [[[0.0, 0.0], [1.0, 0.0]],
                [[1.0, 0.0], [0.0, 0.0]]]
    },
"status": status string for the simulation
"success": boolean
"time taken": simulation time of this single experiment
}

Return type

dict

Raises

  • BasicAerError – if the number of qubits in the circuit is greater than 24.
  • Note that the practical qubit limit is much lower than 24.

set_options

set_options(**fields)

Set the options fields for the backend

This method is used to update the options of a backend. If you need to change any of the options prior to running just pass in the kwarg with the new value for the options.

Parameters

fields – The fields to update the options

Raises

AttributeError – If the field passed in is not part of the options

status

status()

Return the backend status.

Returns

the status of the backend.

Return type

BackendStatus

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