API documentation

Backends for processing pytket circuits with Quantinuum devices

Backends for processing pytket circuits with Quantinuum devices

public api for qir conversion from pytket

pytket.qir.conversion.api.pytket_to_qir(circ, name='Generated from input pytket circuit', qir_format=QIRFormat.BINARY, int_type=64, cut_pytket_register=False, profile=QIRProfile.PYTKET)[source]

converts given pytket circuit to qir

Parameters:
Return type:

str | bytes | None

class pytket.qir.conversion.api.QIRFormat(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Return types qir, options are BINARY for a binary output and STRING for a string output

class pytket.qir.conversion.api.QIRProfile(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Profile for the QIR generation

exception pytket.qir.conversion.api.ClassicalRegisterWidthError(width, max_width=64, hint=None)[source]

Error trying to convert a circuit with a classical register exceeding the maximum width

pytket.qir.conversion.api.check_circuit(circuit, int_type=64)[source]

Checks the validity of the circuit.

Running this check before conversion is recommended for big circuits that take a long time to be converted.

Parameters:
  • circuit (Circuit) – given circuit

  • int_type (int) – integer bit width (32 or 64)

Raises:

ValueError – with a suggestion on how to resolve the problems

Return type:

None

class pytket.qir.conversion.qirgenerator.AbstractQirGenerator(circuit, module, wasm_int_type, qir_int_type)[source]

Abstract Class for the QIR generation from a pytket circuit. Implementing the functionality that is not specific to any profile

circuit_to_module(circuit, record_output=False)[source]

Populate a PyQir module from a pytket circuit.

Return type:

tketqirModule

command_to_module(op, args)[source]

Populate a PyQir module from a pytket command.

Return type:

tketqirModule

abstract record_output()[source]

function to record the output

Return type:

None

subcircuit_to_module(circuit)[source]

Populate a PyQir module from a pytket subcircuit.

Return type:

tketqirModule

conv_BarrierOp(qubits, op)[source]
Return type:

None

conv_CopyBitsOp(args)[source]
Return type:

None

conv_RangePredicateOp(op, args)[source]
Return type:

None

conv_SetBitsOp(bits, op)[source]
Return type:

None

conv_WASMOp(op, args)[source]
Return type:

None

conv_ZZPhase(qubits, op)[source]
Return type:

None

conv_clexprop(op, args)[source]
Return type:

None

abstract conv_conditional(command, op)[source]
Return type:

None

abstract conv_measure(bits, qubits)[source]
Return type:

None

conv_other(bits, qubits, op, args)[source]
Return type:

None

conv_phasedx(qubits, op)[source]
Return type:

None

conv_tk2(qubits, op)[source]
Return type:

None

conv_zzmax(qubits)[source]
Return type:

None

get_azure_sar()[source]
Return type:

dict[str, str]

abstract get_ssa_vars(reg_name)[source]
Return type:

Value

get_wasm_sar()[source]
Return type:

dict[str, str]

abstract set_ssa_vars(reg_name, ssa_i64, trunc)[source]
Return type:

None

class pytket.qir.conversion.baseprofileqirgenerator.BaseProfileQirGenerator(circuit, module, wasm_int_type, qir_int_type)[source]

Generate QIR from a pytket circuit.

record_output()[source]

function to record the output

Return type:

None

conv_conditional(command, op)[source]
Return type:

None

conv_measure(bits, qubits)[source]
Return type:

None

get_ssa_list(reg_name)[source]
Return type:

list

get_ssa_vars(reg_name)[source]
Return type:

Value

set_ssa_vars(reg_name, ssa_i64, trunc)[source]
Return type:

None

class pytket.qir.conversion.profileqirgenerator.AdaptiveProfileQirGenerator(circuit, module, wasm_int_type, qir_int_type, trunc)[source]

Generate QIR from a pytket circuit.

record_output()[source]

function to record the output

Return type:

None

conv_conditional(command, op)[source]
Return type:

None

conv_measure(bits, qubits)[source]
Return type:

None

get_ssa_list(reg_name)[source]
Return type:

list

get_ssa_vars(reg_name)[source]
Return type:

Value

set_ssa_vars(reg_name, ssa_i64, trunc)[source]
Return type:

None

class pytket.qir.conversion.pytketqirgenerator.PytketQirGenerator(circuit, module, wasm_int_type, qir_int_type)[source]

Generates QIR from a pytket circuit in line with the pytket profile. This profile uses the functions get_creg_bit, set_creg_bit, set_creg_to_int, create_creg, get_int_from_creg and mz_to_creg_bit for the handling of the classical registers. The other aspects of the QIR file are identical to the adaptive profile.

record_output()[source]

function to record the output

Return type:

None

conv_conditional(command, op)[source]
Return type:

None

conv_measure(bits, qubits)[source]
Return type:

None

get_ssa_vars(reg_name)[source]
Return type:

Value

set_ssa_vars(reg_name, ssa_i64, trunc)[source]
Return type:

None

class pytket.qir.conversion.azurebaseprofileqirgenerator.AzureBaseProfileQirGenerator(circuit, module, wasm_int_type, qir_int_type)[source]

Generate QIR from a pytket circuit.

record_output()[source]

function to record the output

Return type:

None

conv_measure(bits, qubits)[source]
Return type:

None

class pytket.qir.conversion.azureprofileqirgenerator.AzureAdaptiveProfileQirGenerator(circuit, module, wasm_int_type, qir_int_type, trunc)[source]

Generate QIR from a pytket circuit.

record_output()[source]

function to record the output

Return type:

None

conv_measure(bits, qubits)[source]
Return type:

None

This module defines an extension for the PyQir SimpleModule for the needs of generating QIR from Pytket circuits.

class pytket.qir.conversion.module.tketqirModule(name, num_qubits, num_results, wasm_handler=None)[source]

PyQir module extension to account for custom defined input gate set and calls to WASM files.

class pytket.qir.conversion.gatesets.QirGate(func_nat, func_name, func_spec)[source]
class pytket.qir.conversion.gatesets.CustomQirGate(func_nat, func_name, func_spec, function_signature, return_type)[source]
class pytket.qir.conversion.gatesets.CustomGateSet(name, template, base_gateset, gateset, tk_to_gateset)[source]
class pytket.qir.conversion.gatesets.FuncName(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
class pytket.qir.conversion.gatesets.FuncNat(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
class pytket.qir.conversion.gatesets.FuncSpec(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]