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:
circ (
Circuit
) – given circuitname (
str
) – name for the qir module createdqir_format (
QIRFormat
) – format of the generated qir, default value is binarywfh – wasm file handler used when creating the circuit. Only needed when there are wasm calls in the circuit.
int_type (
int
) – size of each integer, allowed value 32 and 64cut_pytket_register (
bool
) – breaks up the internal scratch bit registers into smaller registers, default value falseprofile (
QIRProfile
) –generates QIR corresponding to the selected profile:
Use
QIRProfile.BASE
for the base profile. See: https://github.com/qir-alliance/qir-spec/blob/main/specification/under_development/profiles/Base_Profile.mdUse
QIRProfile.ADAPTIVE
for the adaptive profile. See: https://github.com/qir-alliance/qir-spec/tree/main/specification/under_development/profiles/Adaptive_Profile.mdUse
QIRProfile.ADAPTIVE_CREGSIZE
for the adaptive profile with additional truncation operations to assure that integers matching the classical registers have no unexpected set bits. See: https://github.com/qir-alliance/qir-spec/tree/main/specification/under_development/profiles/Adaptive_Profile.mdUse
QIRProfile.PYTKET
for QIR with additional functions for classical registers.Use
QIRProfile.AZUREBASE
for the base profile with metadata for Azure devices andarray_record
for output recording.Use
QIRProfile.AZUREADAPTIVE
for the adaptive profile with metadata for Azure devices and bitwise recording of results viaarray_record
.
- Return type:
- 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:
- Raises:
ValueError – with a suggestion on how to resolve the problems
- Return type:
- 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:
- class pytket.qir.conversion.baseprofileqirgenerator.BaseProfileQirGenerator(circuit, module, wasm_int_type, qir_int_type)[source]¶
Generate QIR from a pytket circuit.
- class pytket.qir.conversion.profileqirgenerator.AdaptiveProfileQirGenerator(circuit, module, wasm_int_type, qir_int_type, trunc)[source]¶
Generate QIR from a pytket circuit.
- 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.
- class pytket.qir.conversion.azurebaseprofileqirgenerator.AzureBaseProfileQirGenerator(circuit, module, wasm_int_type, qir_int_type)[source]¶
Generate QIR from a pytket circuit.
- class pytket.qir.conversion.azureprofileqirgenerator.AzureAdaptiveProfileQirGenerator(circuit, module, wasm_int_type, qir_int_type, trunc)[source]¶
Generate QIR from a pytket circuit.
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.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]¶