c3.qiskit.c3_backend
¶
Module Contents¶
- class c3.qiskit.c3_backend.C3QasmSimulator(configuration, provider=None, **fields)[source]¶
Bases:
qiskit.providers.BackendV1
,abc.ABC
An Abtract Base Class for C3 Qasm Simulators for Qiskit. This class CAN NOT be instantiated directly. Classes derived from this must compulsorily implement
def __init__(self, configuration=None, provider=None, **fields): def _default_options(cls) -> None: def run_experiment(self, experiment: QasmQobjExperiment) -> Dict[str, Any]:
- Parameters
Backend (qiskit.providers.BackendV1) – The C3QasmSimulator is derived from BackendV1
ABC (abc.ABC) – Helper class for defining Abstract classes using ABCMeta
- set_device_config(self, config_file: str) None [source]¶
Set the path to the config for the device
- Parameters
config_file (str) – path to hjson file storing the configuration for all device parameters for simulation
- get_labels(self) List[str] [source]¶
Return state labels for the system
- Returns
A list of state labels in hex format
labels = ['0x1', ...]
- Return type
List[str]
- disable_flip_labels(self) None [source]¶
Disable flipping of labels State Labels are flipped before returning results to match Qiskit style qubit indexing convention This function allows disabling of the flip
- run(self, qobj: C3QasmSimulator.run.qobj, **backend_options) c3.qiskit.c3_job.C3Job [source]¶
Parse and run a Qobj
- Parameters
qobj (Qobj) – The Qobj payload for the experiment
backend_options (dict) – backend options
- Returns
An instance of the C3Job (derived from JobV1) with the result
- Return type
- Raises
QiskitError – Support for Pulse Jobs is not implemented
Notes
- 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 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 all experiments in the qobj.
Example:
backend_options = { "initial_statevector": np.array([1, 0, 0, 1j]) / np.sqrt(2), }
- set_options(self, **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
- configuration(self)¶
Return the backend configuration.
- Returns
the configuration for the backend.
- Return type
BackendConfiguration
- properties(self)¶
Return the backend properties.
- Returns
the configuration for the backend. If the backend does not support properties, it returns
None
.- Return type
BackendProperties
- provider(self)¶
Return the backend Provider.
- Returns
the Provider responsible for the backend.
- Return type
Provider
- status(self)¶
Return the backend status.
- Returns
the status of the backend.
- Return type
BackendStatus
- name(self)¶
Return the backend name.
- Returns
the name of the backend.
- Return type
str
- __str__(self)¶
Return str(self).
- __repr__(self)¶
Official string representation of a Backend.
Note that, by Qiskit convention, it is consciously not a fully valid Python expression. Subclasses should provide ‘a string of the form <…some useful description…>’. [0]
[0] https://docs.python.org/3/reference/datamodel.html#object.__repr__
- class c3.qiskit.c3_backend.C3QasmPerfectSimulator(configuration=None, provider=None, **fields)[source]¶
Bases:
C3QasmSimulator
A C3-based perfect gates simulator for Qiskit
- Parameters
C3QasmSimulator (c3.qiskit.c3_backend.C3QasmSimulator) – Inherits the C3QasmSimulator and implements a perfect gate simulator
- run_experiment(self, experiment: qiskit.qobj.qasm_qobj.QasmQobjExperiment) Dict[str, Any] [source]¶
Run an experiment (circuit) and return a single experiment result
- Parameters
experiment (QasmQobjExperiment) – 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": { "counts": {'0x9': 5, ...}, "memory": ['0x9', '0xF', '0x1D', ..., '0x9'] }, "status": status string for the simulation "success": boolean "time_taken": simulation time of this single experiment }
- Return type
Dict[str, Any]
- Raises
C3QiskitError – If an error occured
- set_device_config(self, config_file: str) None ¶
Set the path to the config for the device
- Parameters
config_file (str) – path to hjson file storing the configuration for all device parameters for simulation
- get_labels(self) List[str] ¶
Return state labels for the system
- Returns
A list of state labels in hex format
labels = ['0x1', ...]
- Return type
List[str]
- disable_flip_labels(self) None ¶
Disable flipping of labels State Labels are flipped before returning results to match Qiskit style qubit indexing convention This function allows disabling of the flip
- run(self, qobj: C3QasmSimulator.run.qobj, **backend_options) c3.qiskit.c3_job.C3Job ¶
Parse and run a Qobj
- Parameters
qobj (Qobj) – The Qobj payload for the experiment
backend_options (dict) – backend options
- Returns
An instance of the C3Job (derived from JobV1) with the result
- Return type
- Raises
QiskitError – Support for Pulse Jobs is not implemented
Notes
- 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 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 all experiments in the qobj.
Example:
backend_options = { "initial_statevector": np.array([1, 0, 0, 1j]) / np.sqrt(2), }
- set_options(self, **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
- configuration(self)¶
Return the backend configuration.
- Returns
the configuration for the backend.
- Return type
BackendConfiguration
- properties(self)¶
Return the backend properties.
- Returns
the configuration for the backend. If the backend does not support properties, it returns
None
.- Return type
BackendProperties
- provider(self)¶
Return the backend Provider.
- Returns
the Provider responsible for the backend.
- Return type
Provider
- status(self)¶
Return the backend status.
- Returns
the status of the backend.
- Return type
BackendStatus
- name(self)¶
Return the backend name.
- Returns
the name of the backend.
- Return type
str
- __str__(self)¶
Return str(self).
- __repr__(self)¶
Official string representation of a Backend.
Note that, by Qiskit convention, it is consciously not a fully valid Python expression. Subclasses should provide ‘a string of the form <…some useful description…>’. [0]
[0] https://docs.python.org/3/reference/datamodel.html#object.__repr__
- class c3.qiskit.c3_backend.C3QasmPhysicsSimulator(configuration=None, provider=None, **fields)[source]¶
Bases:
C3QasmSimulator
A C3-based perfect gates simulator for Qiskit
- Parameters
C3QasmSimulator (c3.qiskit.c3_backend.C3QasmSimulator) – Inherits the C3QasmSimulator and implements a physics based simulator
- run_experiment(self, experiment: qiskit.qobj.qasm_qobj.QasmQobjExperiment) Dict[str, Any] [source]¶
Run an experiment (circuit) and return a single experiment result
- Parameters
experiment (QasmQobjExperiment) – 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": { "counts": {'0x9: 5, ...}, "memory": ['0x9', '0xF', '0x1D', ..., '0x9'] }, "status": status string for the simulation "success": boolean "time_taken": simulation time of this single experiment }
- Return type
Dict[str, Any]
- Raises
C3QiskitError – If an error occured
- set_device_config(self, config_file: str) None ¶
Set the path to the config for the device
- Parameters
config_file (str) – path to hjson file storing the configuration for all device parameters for simulation
- get_labels(self) List[str] ¶
Return state labels for the system
- Returns
A list of state labels in hex format
labels = ['0x1', ...]
- Return type
List[str]
- disable_flip_labels(self) None ¶
Disable flipping of labels State Labels are flipped before returning results to match Qiskit style qubit indexing convention This function allows disabling of the flip
- run(self, qobj: C3QasmSimulator.run.qobj, **backend_options) c3.qiskit.c3_job.C3Job ¶
Parse and run a Qobj
- Parameters
qobj (Qobj) – The Qobj payload for the experiment
backend_options (dict) – backend options
- Returns
An instance of the C3Job (derived from JobV1) with the result
- Return type
- Raises
QiskitError – Support for Pulse Jobs is not implemented
Notes
- 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 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 all experiments in the qobj.
Example:
backend_options = { "initial_statevector": np.array([1, 0, 0, 1j]) / np.sqrt(2), }
- set_options(self, **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
- configuration(self)¶
Return the backend configuration.
- Returns
the configuration for the backend.
- Return type
BackendConfiguration
- properties(self)¶
Return the backend properties.
- Returns
the configuration for the backend. If the backend does not support properties, it returns
None
.- Return type
BackendProperties
- provider(self)¶
Return the backend Provider.
- Returns
the Provider responsible for the backend.
- Return type
Provider
- status(self)¶
Return the backend status.
- Returns
the status of the backend.
- Return type
BackendStatus
- name(self)¶
Return the backend name.
- Returns
the name of the backend.
- Return type
str
- __str__(self)¶
Return str(self).
- __repr__(self)¶
Official string representation of a Backend.
Note that, by Qiskit convention, it is consciously not a fully valid Python expression. Subclasses should provide ‘a string of the form <…some useful description…>’. [0]
[0] https://docs.python.org/3/reference/datamodel.html#object.__repr__