Qiskit modules for C3

C3 Backend module

class c3.qiskit.c3_backend.C3QasmSimulator(configuration=None, provider=None, **fields)[source]

Bases: qiskit.providers.backend.BackendV1

A C3-based Qasm Simulator for Qiskit

Parameters

Backend (qiskit.providers.BackendV1) – The C3QasmSimulator is derived from BackendV1

DEFAULT_OPTIONS = {'initial_statevector': None, 'memory': False, 'shots': 1024}
MAX_QUBITS_MEMORY = 15
run(qobj: qiskit.qobj.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

C3Job

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),
}
run_experiment(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(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

C3 Provider module

class c3.qiskit.c3_provider.C3Provider[source]

Bases: qiskit.providers.provider.ProviderV1

Provider for C3 Qiskit backends

Parameters

ProviderV1 (ProviderV1) – Derived from ProviderV1 from qiskit.providers.provider

backends(name=None, filters=None, **kwargs)[source]

Return a list of backends matching the name

Parameters
  • name (str, optional) – name of the backend, by default None

  • filters (callable, optional) – Filtering conditions, as callable, by default None

Returns

A list of backend instances matching the condition

Return type

list[BackendV1]

C3 Job module

class c3.qiskit.c3_job.C3Job(backend, job_id, result)[source]

Bases: qiskit.providers.job.JobV1

C3Job class

Parameters

Job (JobV1) – Inherits JobV1 from qiskit.providers

result() → qiskit.result.result.Result[source]

Return the result of the job

Returns

Result of the job simulation

Return type

qiskit.Result

status() → qiskit.providers.jobstatus.JobStatus[source]

Return job status

Returns

Status of the job

Return type

qiskit.providers.JobStatus

submit() → None[source]

Submit a job to the simulator

C3 Exceptions module

Exception for errors raised by Basic Aer.

exception c3.qiskit.c3_exceptions.C3QiskitError(*message)[source]

Bases: qiskit.exceptions.QiskitError

Base class for errors raised by C3 Qiskit Simulator.

C3 Backend Utilities module

Convenience Module for creating different c3_backend

c3.qiskit.c3_backend_utils.get_init_ground_state(n_qubits: int, n_levels: int) → tensorflow.python.framework.ops.Tensor[source]

Return a perfect ground state

Parameters
  • n_qubits (int) – Number of qubits in the system

  • n_levels (int) – Number of levels for each qubit

Returns

Tensor array of ground state shape(m^n, 1), dtype=complex128 m = no of qubit levels n = no of qubits

Return type

tf.Tensor

c3.qiskit.c3_backend_utils.get_sequence(instructions: List) → List[str][source]

Return a sequence of gates from instructions

Parameters

instructions (List[dict]) –

Instructions from the qasm experiment, for example:

instructions: [
        {"name": "u1", "qubits": [0], "params": [0.4]},
        {"name": "u2", "qubits": [0], "params": [0.4,0.2]},
        {"name": "u3", "qubits": [0], "params": [0.4,0.2,-0.3]},
        {"name": "snapshot", "label": "snapstate1", "snapshot_type": "statevector"},
        {"name": "cx", "qubits": [0,1]},
        {"name": "barrier", "qubits": [0]},
        {"name": "measure", "qubits": [0], "register": [1], "memory": [0]},
        {"name": "u2", "qubits": [0], "params": [0.4,0.2], "conditional": 2}
    ]

Returns

List of gates, for example:

sequence = ["X90p:Id", "Id:X90p", "CR90"]

Return type

List[str]

Module contents