c3.qiskit.c3_backend_utils

Convenience Module for creating different c3_backend

Module Contents

c3.qiskit.c3_backend_utils.make_gate_str(instruction: dict, gate_name: str) str[source]

Make C3 style gate name string

Parameters
  • instruction (Dict[str, Any]) –

    A dict in OpenQasm instruction format

    {"name": "rx", "qubits": [0], "params": [1.57]}
    

  • gate_name (str) – C3 style gate names

Returns

C3 style gate name + qubit string

{"name": "rx", "qubits": [0], "params": [1.57]} -> rx90p[0]

Return type

str

c3.qiskit.c3_backend_utils.get_init_ground_state(n_qubits: int, n_levels: int) tensorflow.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.flip_labels(counts: Dict[str, int]) Dict[str, int][source]

Flip C3 qubit labels to match Qiskit qubit indexing

Parameters

counts (Dict[str, int]) – OpenQasm 2.0 result counts with original C3 style qubit indices

Returns

OpenQasm 2.0 result counts with Qiskit style labels

Return type

Dict[str, int]

Note

Basis vector ordering in Qiskit

Qiskit uses a slightly different ordering of the qubits compared to what is seen in Physics textbooks. In qiskit, the qubits are represented from the most significant bit (MSB) on the left to the least significant bit (LSB) on the right (big-endian). This is similar to bitstring representation on classical computers, and enables easy conversion from bitstrings to integers after measurements are performed.

More details: https://qiskit.org/documentation/tutorials/circuits/3_summary_of_quantum_operations.html#Basis-vector-ordering-in-Qiskit