390 lines
15 KiB
Plaintext
390 lines
15 KiB
Plaintext
---
|
||
title: BasicSimulator (v1.2)
|
||
description: API reference for qiskit.providers.basic_provider.BasicSimulator in qiskit v1.2
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.providers.basic_provider.BasicSimulator
|
||
---
|
||
|
||
# BasicSimulator
|
||
|
||
<Class id="qiskit.providers.basic_provider.BasicSimulator" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/basic_provider/basic_simulator.py#L66-L811" signature="qiskit.providers.basic_provider.BasicSimulator(provider=None, target=None, **fields)" modifiers="class">
|
||
Bases: [`BackendV2`](qiskit.providers.BackendV2 "qiskit.providers.backend.BackendV2")
|
||
|
||
Python implementation of a basic (non-efficient) quantum simulator.
|
||
|
||
**Parameters**
|
||
|
||
* **provider** ([*Provider*](qiskit.providers.Provider "qiskit.providers.Provider") *| None*) – An optional backwards reference to the [`Provider`](qiskit.providers.Provider "qiskit.providers.Provider") object that the backend is from.
|
||
* **target** ([*Target*](qiskit.transpiler.Target "qiskit.transpiler.Target") *| None*) – An optional target to configure the simulator.
|
||
* **fields** – kwargs for the values to use to override the default options.
|
||
|
||
**Raises**
|
||
|
||
[**AttributeError**](https://docs.python.org/3/library/exceptions.html#AttributeError "(in Python v3.13)") – If a field is specified that’s outside the backend’s options.
|
||
|
||
## Attributes
|
||
|
||
### MAX\_QUBITS\_MEMORY
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.MAX_QUBITS_MEMORY" attributeValue="24" />
|
||
|
||
### coupling\_map
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.coupling_map">
|
||
Return the [`CouplingMap`](qiskit.transpiler.CouplingMap "qiskit.transpiler.CouplingMap") object
|
||
</Attribute>
|
||
|
||
### dt
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.dt">
|
||
Return the system time resolution of input signals
|
||
|
||
This is required to be implemented if the backend supports Pulse scheduling.
|
||
|
||
**Returns**
|
||
|
||
The input signal timestep in seconds. If the backend doesn’t define `dt`, `None` will be returned.
|
||
</Attribute>
|
||
|
||
### dtm
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.dtm">
|
||
Return the system time resolution of output signals
|
||
|
||
**Returns**
|
||
|
||
The output signal timestep in seconds.
|
||
|
||
**Raises**
|
||
|
||
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") – if the backend doesn’t support querying the output signal timestep
|
||
</Attribute>
|
||
|
||
### instruction\_durations
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.instruction_durations">
|
||
Return the [`InstructionDurations`](qiskit.transpiler.InstructionDurations "qiskit.transpiler.InstructionDurations") object.
|
||
</Attribute>
|
||
|
||
### instruction\_schedule\_map
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.instruction_schedule_map">
|
||
Return the [`InstructionScheduleMap`](qiskit.pulse.InstructionScheduleMap "qiskit.pulse.InstructionScheduleMap") for the instructions defined in this backend’s target.
|
||
</Attribute>
|
||
|
||
### instructions
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.instructions">
|
||
A list of Instruction tuples on the backend of the form `(instruction, (qubits)`
|
||
</Attribute>
|
||
|
||
### max\_circuits
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.max_circuits" />
|
||
|
||
### meas\_map
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.meas_map">
|
||
Return the grouping of measurements which are multiplexed
|
||
|
||
This is required to be implemented if the backend supports Pulse scheduling.
|
||
|
||
**Returns**
|
||
|
||
The grouping of measurements which are multiplexed
|
||
|
||
**Raises**
|
||
|
||
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") – if the backend doesn’t support querying the measurement mapping
|
||
</Attribute>
|
||
|
||
### num\_qubits
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.num_qubits">
|
||
Return the number of qubits the backend has.
|
||
</Attribute>
|
||
|
||
### operation\_names
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.operation_names">
|
||
A list of instruction names that the backend supports.
|
||
</Attribute>
|
||
|
||
### operations
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.operations">
|
||
A list of [`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction") instances that the backend supports.
|
||
</Attribute>
|
||
|
||
### options
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.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()`](#qiskit.providers.basic_provider.BasicSimulator.run "qiskit.providers.basic_provider.BasicSimulator.run") method.
|
||
</Attribute>
|
||
|
||
### provider
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.provider">
|
||
Return the backend Provider.
|
||
|
||
**Returns**
|
||
|
||
the Provider responsible for the backend.
|
||
|
||
**Return type**
|
||
|
||
[Provider](qiskit.providers.Provider "qiskit.providers.Provider")
|
||
</Attribute>
|
||
|
||
### target
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.target" />
|
||
|
||
### version
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.version" attributeValue="2" />
|
||
|
||
### name
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.name">
|
||
Name of the backend.
|
||
</Attribute>
|
||
|
||
### description
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.description">
|
||
Optional human-readable description.
|
||
</Attribute>
|
||
|
||
### online\_date
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.online_date">
|
||
Date that the backend came online.
|
||
</Attribute>
|
||
|
||
### backend\_version
|
||
|
||
<Attribute id="qiskit.providers.basic_provider.BasicSimulator.backend_version">
|
||
Version of the backend being provided. This is not the same as [`BackendV2.version`](qiskit.providers.BackendV2#version "qiskit.providers.BackendV2.version"), which is the version of the [`Backend`](qiskit.providers.Backend "qiskit.providers.Backend") abstract interface.
|
||
</Attribute>
|
||
|
||
## Methods
|
||
|
||
### acquire\_channel
|
||
|
||
<Function id="qiskit.providers.basic_provider.BasicSimulator.acquire_channel" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/backend.py#L557-L570" signature="acquire_channel(qubit)">
|
||
Return the acquisition channel for the given qubit.
|
||
|
||
This is required to be implemented if the backend supports Pulse scheduling.
|
||
|
||
**Returns**
|
||
|
||
The Qubit measurement acquisition line.
|
||
|
||
**Return type**
|
||
|
||
[AcquireChannel](qiskit.pulse.channels.AcquireChannel "qiskit.pulse.channels.AcquireChannel")
|
||
|
||
**Raises**
|
||
|
||
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") – if the backend doesn’t support querying the measurement mapping
|
||
</Function>
|
||
|
||
### configuration
|
||
|
||
<Function id="qiskit.providers.basic_provider.BasicSimulator.configuration" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/basic_provider/basic_simulator.py#L215-L265" signature="configuration()">
|
||
Return the simulator backend configuration.
|
||
|
||
**Returns**
|
||
|
||
The configuration for the backend.
|
||
|
||
**Return type**
|
||
|
||
[*BackendConfiguration*](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.backendconfiguration.BackendConfiguration")
|
||
</Function>
|
||
|
||
### control\_channel
|
||
|
||
<Function id="qiskit.providers.basic_provider.BasicSimulator.control_channel" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/backend.py#L572-L592" signature="control_channel(qubits)">
|
||
Return the secondary drive channel for the given qubit
|
||
|
||
This is typically utilized for controlling multiqubit interactions. This channel is derived from other channels.
|
||
|
||
This is required to be implemented if the backend supports Pulse scheduling.
|
||
|
||
**Parameters**
|
||
|
||
**qubits** ([*Iterable*](https://docs.python.org/3/library/typing.html#typing.Iterable "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) – Tuple or list of qubits of the form `(control_qubit, target_qubit)`.
|
||
|
||
**Returns**
|
||
|
||
The multi qubit control line.
|
||
|
||
**Return type**
|
||
|
||
List\[[ControlChannel](qiskit.pulse.channels.ControlChannel "qiskit.pulse.channels.ControlChannel")]
|
||
|
||
**Raises**
|
||
|
||
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") – if the backend doesn’t support querying the measurement mapping
|
||
</Function>
|
||
|
||
### drive\_channel
|
||
|
||
<Function id="qiskit.providers.basic_provider.BasicSimulator.drive_channel" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/backend.py#L527-L540" signature="drive_channel(qubit)">
|
||
Return the drive channel for the given qubit.
|
||
|
||
This is required to be implemented if the backend supports Pulse scheduling.
|
||
|
||
**Returns**
|
||
|
||
The Qubit drive channel
|
||
|
||
**Return type**
|
||
|
||
[DriveChannel](qiskit.pulse.channels.DriveChannel "qiskit.pulse.channels.DriveChannel")
|
||
|
||
**Raises**
|
||
|
||
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") – if the backend doesn’t support querying the measurement mapping
|
||
</Function>
|
||
|
||
### measure\_channel
|
||
|
||
<Function id="qiskit.providers.basic_provider.BasicSimulator.measure_channel" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/backend.py#L542-L555" signature="measure_channel(qubit)">
|
||
Return the measure stimulus channel for the given qubit.
|
||
|
||
This is required to be implemented if the backend supports Pulse scheduling.
|
||
|
||
**Returns**
|
||
|
||
The Qubit measurement stimulus line
|
||
|
||
**Return type**
|
||
|
||
[MeasureChannel](qiskit.pulse.channels.MeasureChannel "qiskit.pulse.channels.MeasureChannel")
|
||
|
||
**Raises**
|
||
|
||
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") – if the backend doesn’t support querying the measurement mapping
|
||
</Function>
|
||
|
||
### qubit\_properties
|
||
|
||
<Function id="qiskit.providers.basic_provider.BasicSimulator.qubit_properties" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/backend.py#L493-L525" signature="qubit_properties(qubit)">
|
||
Return QubitProperties for a given qubit.
|
||
|
||
If there are no defined or the backend doesn’t support querying these details this method does not need to be implemented.
|
||
|
||
**Parameters**
|
||
|
||
**qubit** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *|*[*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]*) – The qubit to get the [`QubitProperties`](qiskit.providers.QubitProperties "qiskit.providers.QubitProperties") object for. This can be a single integer for 1 qubit or a list of qubits and a list of [`QubitProperties`](qiskit.providers.QubitProperties "qiskit.providers.QubitProperties") objects will be returned in the same order
|
||
|
||
**Returns**
|
||
|
||
The [`QubitProperties`](qiskit.providers.QubitProperties "qiskit.providers.QubitProperties") object for the specified qubit. If a list of qubits is provided a list will be returned. If properties are missing for a qubit this can be `None`.
|
||
|
||
**Raises**
|
||
|
||
[**NotImplementedError**](https://docs.python.org/3/library/exceptions.html#NotImplementedError "(in Python v3.13)") – if the backend doesn’t support querying the qubit properties
|
||
|
||
**Return type**
|
||
|
||
[*QubitProperties*](qiskit.providers.QubitProperties "qiskit.providers.backend.QubitProperties") | [*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")\[[*QubitProperties*](qiskit.providers.QubitProperties "qiskit.providers.backend.QubitProperties")]
|
||
</Function>
|
||
|
||
### run
|
||
|
||
<Function id="qiskit.providers.basic_provider.BasicSimulator.run" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/basic_provider/basic_simulator.py#L508-L551" signature="run(run_input, **backend_options)">
|
||
Run on the backend.
|
||
|
||
**Parameters**
|
||
|
||
* **run\_input** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") *|*[*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")*\[*[*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")*]*) – payload of the experiment
|
||
* **backend\_options** – backend options
|
||
|
||
**Returns**
|
||
|
||
derived from BaseJob
|
||
|
||
**Return type**
|
||
|
||
[BasicProviderJob](qiskit.providers.basic_provider.BasicProviderJob "qiskit.providers.basic_provider.BasicProviderJob")
|
||
|
||
**Additional Information:**
|
||
|
||
**backend\_options: Is a dict of options for the backend. It may contain**
|
||
|
||
* “initial\_statevector”: vector\_like
|
||
|
||
The “initial\_statevector” option specifies a custom initial initial statevector for the simulator to be used instead of the all zero state. This size of this vector must be correct for the number of qubits in `run_input` parameter.
|
||
|
||
Example:
|
||
|
||
```python
|
||
backend_options = {
|
||
"initial_statevector": np.array([1, 0, 0, 1j]) / math.sqrt(2),
|
||
}
|
||
```
|
||
</Function>
|
||
|
||
### run\_experiment
|
||
|
||
<Function id="qiskit.providers.basic_provider.BasicSimulator.run_experiment" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/basic_provider/basic_simulator.py#L586-L790" signature="run_experiment(experiment)">
|
||
Run an experiment (circuit) and return a single experiment result.
|
||
|
||
**Parameters**
|
||
|
||
**experiment** ([*QasmQobjExperiment*](qiskit.qobj.QasmQobjExperiment "qiskit.qobj.qasm_qobj.QasmQobjExperiment")) – experiment from qobj experiments list
|
||
|
||
**Returns**
|
||
|
||
A result dictionary which looks something like:
|
||
|
||
```python
|
||
{
|
||
"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":
|
||
{
|
||
"counts": {'0x9: 5, ...},
|
||
"memory": ['0x9', '0xF', '0x1D', ..., '0x9']
|
||
},
|
||
"status": status string for the simulation
|
||
"success": boolean
|
||
"time_taken": simulation time of this single experiment
|
||
}
|
||
```
|
||
|
||
**Raises**
|
||
|
||
[**BasicProviderError**](qiskit.providers.basic_provider.BasicProviderError "qiskit.providers.basic_provider.BasicProviderError") – if an error occurred.
|
||
|
||
**Return type**
|
||
|
||
[dict](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)")\[[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)"), …]
|
||
</Function>
|
||
|
||
### set\_options
|
||
|
||
<Function id="qiskit.providers.basic_provider.BasicSimulator.set_options" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/providers/backend.py#L594-L611" signature="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**](https://docs.python.org/3/library/exceptions.html#AttributeError "(in Python v3.13)") – If the field passed in is not part of the options
|
||
</Function>
|
||
</Class>
|
||
|