Gate Chain and Gate Connection

class arline_quantum.gate_chain.gate_chain.AstInterpreter(gate_chain, hardware_from_qasm)

Bases: object

Interprets an OpenQASM by expanding subroutines and unrolling loops

class arline_quantum.gate_chain.gate_chain.GateChain(quantum_hardware)

Bases: object

Gate Chain Class

Parameters:

quantum_hardware – Quantum hardware configuration

Variables:
  • chain (list) – gate chain, list of GateConnection
  • chain_labels (list) – printed labels
  • matrix (np.array) – unitary matrix
add_gate(gate, connections, force_connection=False)

Place gate to circuit

Parameters:
  • gate (Gate) – gate object
  • connections (tuple) – qubits to place the gate
  • force_connection (bool) – don’t check qubit connection
Raises:

NoQubitConnectionError – when there is no connection between qubits

add_gate_left(gate, connections, force_connection=False)

Place gate to left end of the circuit

Parameters:
  • gate (Gate) – gate object
  • connections (tuple) – qubits to place the gate
  • force_connection (bool) – don’t check qubit connection
Raises:

NoQubitConnectionError – when there is no connection between qubits

add_subchain(subchain)
calculate_cost()
calculate_noise()
copy()
delete_gate(gate_number)
delete_subchain(subchain)
find_subchain(subchain)
static from_qasm(input_file, quantum_hardware=None)
static from_qasm_list_of_lines(lines, quantum_hardware=None)
static from_qasm_string(qasm_data, quantum_hardware=None, file_name=None)
get_depth()
get_depth_qubit()
get_gate_count()
get_gates_by_qubit(n)
get_num_gates()
get_num_gates_by_gate_type(gate, gate_num=None)
get_num_gates_by_qubit(n)
insert_gate(gate, connections, position, force_connection=False)

Place gate at a given position

Parameters:
  • gate (Gate) – gate object
  • connections (tuple) – qubits to place the gate
  • position (int the front of the circuit, and len(circuit) is equivalent to add_gate()) – index of the element before which to insert, in case of 0 gate will be places at
  • force_connection (bool) – don’t check qubit connection
Raises:

NoQubitConnectionError – when there is no connection between qubits

load_chain(file)
matrix

Calculate unitary matrix corresponding to the gate chain. Supports lazy matrix calculation, the call of self.matrix will result in recalculation of cashed unitary U = self._matrix. In order to update the cashed unitary after new gates were added to the gate chain we first evaluate the unitary of the appended gates U_new_gates. Then the resulting cashed unitary is the product U_new_gates * U or U * U_new_gates depending on wheather the new gates were appended to the beggining or end of the gate chain.

print()
save_chain(file)
save_to_qasm(output_dir, qreg_name='q')
static string_to_angle(string)

Convert string into angle

to_qasm(qreg_name='q')
exception arline_quantum.gate_chain.gate_chain.NoQubitConnectionError(connections, gate)

Bases: Exception

Exception raised when placing gate to qubits that is not connected

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class arline_quantum.gate_chain.gate_connection.GateConnection(quantum_hardware, gate, connections)

Bases: object

conjugate()
connections
gate
quantum_hardware
to_qasm(qreg_name)