qoqo_qasm

QASM interface and backend for qoqo.

Translates qoqo operations and circuits to QASM operations via the interface, and Create a Qasm file with QasmBackend.

qasm_call_operation(operation, ...)

Translate a qoqo operation to QASM text

qasm_call_circuit(circuit, ...)

Translate the qoqo circuit into QASM ouput

QasmBackend([qubit_register_name, qasm_version])

Backend to qoqo that produces QASM output which can be imported.

Functions

qasm_call_circuit(circuit, ...)

Translate the qoqo circuit into QASM ouput

qasm_call_operation(operation, ...)

Translate a qoqo operation to QASM text

qasm_file_to_circuit(file)

Translates a QASM File to a Circuit.

qasm_str_to_circuit(input)

Translates a QASM string into a qoqo Circuit instance.

Classes

QasmBackend([qubit_register_name, qasm_version])

Backend to qoqo that produces QASM output which can be imported.

class qoqo_qasm.QasmBackend(qubit_register_name=None, qasm_version=None)

Backend to qoqo that produces QASM output which can be imported.

This backend takes a qoqo circuit to be run on a certain device and returns a QASM file containing the translated circuit. The circuit itself is translated using the qoqo_qasm interface. In this backend, the initialization sets up the relevant parameters and the run function calls the QASM interface and writes the QASM file, which is saved to be used by the user on whatever platform they see fit. QASM input is widely supported on various quantum computing platforms.

__new__(**kwargs)
circuit_to_qasm_file(circuit, folder_name, filename, overwrite)

Translates a Circuit to a QASM file.

Parameters:
  • circuit -- The Circuit that is translated

  • folder_name -- The name of the folder that is prepended to all filenames.

  • filename -- The name of the file the QASM text is saved to.

  • overwrite -- Whether to overwrite file if it already exists.

Returns:

The qasm file was correctly written

Return type:

Ok(())

Raises:
  • TypeError -- Circuit conversion error

  • ValueError -- Operation not in QASM backend

circuit_to_qasm_str(circuit)

Translates a Circuit to a valid QASM string.

Parameters:

circuit -- The Circuit items that is translated

Returns:

The valid QASM string

Return type:

str

Raises:
  • TypeError -- Circuit conversion error

  • ValueError -- Operation not in QASM backend

qasm_file_to_circuit(file)

Translates a QASM File to a Circuit.

Parameters:

file (str) -- The path to the QASM file.

Returns:

The Circuit that was read from the QASM file.

Return type:

Circuit

Raises:
  • PyFileNotFoundError -- The file could not be opened.

  • PyValueError -- An error occurred while converting the file into a Circuit.

qasm_str_to_circuit()

Translates a QASM string into a qoqo Circuit instance.

Parameters:

input (str) -- The QASM string to translate.

Returns:

The Circuit that was read from the QASM file.

Return type:

Circuit

Raises:

PyValueError -- An error occurred while converting the file into a Circuit.

qoqo_qasm.qasm_call_circuit(circuit, qubit_register_name, qasm_version)

Translate the qoqo circuit into QASM ouput

The qoqo_qasm interface iterates through the qoqo circuit and translates each qoqo operation to QASM output (strings).

Parameters:
  • circuit (Circuit) -- The qoqo circuit that is translated

  • qubit_register_name (str) -- The name of the quantum register

Returns:

The translated circuit

Return type:

List[str]

Raises:
  • TypeError -- Circuit conversion error

  • ValueError -- Operation not in QASM backend

qoqo_qasm.qasm_call_operation(operation, qubit_register_name, qasm_version)

Translate a qoqo operation to QASM text

Parameters:
  • operation -- The qoqo operation that is translated

  • qubit_register_name (str) -- The name of the quantum register

Returns:

The translated operation

Return type:

str

Raises:
  • TypeError -- Operation conversion error

  • ValueError -- Operation not in QASM backend

qoqo_qasm.qasm_file_to_circuit(file)

Translates a QASM File to a Circuit.

Parameters:

file (str) -- The path to the QASM file.

Returns:

The Circuit that was read from the QASM file.

Return type:

Circuit

Raises:
  • PyFileNotFoundError -- The file could not be opened.

  • PyValueError -- An error occurred while converting the file into a Circuit.

qoqo_qasm.qasm_str_to_circuit(input)

Translates a QASM string into a qoqo Circuit instance.

Parameters:

input (str) -- The QASM string to translate.

Returns:

The Circuit that was read from the QASM file.

Return type:

Circuit

Raises:

PyValueError -- An error occurred while converting the file into a Circuit.