qutip_qip.qir

Functions

QirFormat(value)

Specifies the format used to serialize QIR.

circuit_to_qir()

Converts a qubit circuit to its representation in QIR.

class qutip_qip.qir.QirFormat(value)[source]

Bases: Enum

Specifies the format used to serialize QIR.

BITCODE = 1

Specifies that QIR should be encoded as LLVM bitcode (typically, files ending in .bc).

MODULE = 3

Specifies that QIR should be encoded as a PyQIR module object.

TEXT = 2

Specifies that QIR should be encoded as plain text (typicaly, files ending in .ll).

classmethod ensure(val: Union[Literal['bitcode', 'text', 'module'], QirFormat]) QirFormat[source]

Given a value, returns a value ensured to be of type QirFormat, attempting to convert if needed.

qutip_qip.qir.circuit_to_qir(circuit: QubitCircuit, format: Union[Literal[QirFormat.BITCODE], Literal['bitcode']], module_name: str) bytes[source]
qutip_qip.qir.circuit_to_qir(circuit: QubitCircuit, format: Union[Literal[QirFormat.TEXT], Literal['text']], module_name: str) str
qutip_qip.qir.circuit_to_qir(circuit: QubitCircuit, format: Union[Literal[QirFormat.MODULE], Literal['module']], module_name: str) QirModule

Converts a qubit circuit to its representation in QIR.

Given a circuit acting on qubits, generates a representation of that circuit using Quantum Intermediate Representation (QIR).

Parameters
circuit

The circuit to be translated to QIR.

format

The QIR serialization to be used. If “text”, returns a plain-text representation using LLVM IR. If “bitcode”, returns a dense binary representation ideal for use with other compilation tools. If “module”, returns a PyQIR module object that can be manipulated further before generating QIR.

module_name

The name of the module to be emitted.

Returns
A QIR representation of circuit, encoded using the format specified by
format.