loom.executor.executor

Copyright 2024 Entropica Labs Pte Ltd

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class loom.executor.executor.Executor(**data)[source]

Bases: BaseModel

Factory class for executing quantum circuits using different target languages.

Parameters:

target_language (TargetLanguage) – The target language/platform for circuit execution

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

property converter: Converter

Return the converter for the target language.

export_eka(input_data)[source]

Factory function that selects the right converter and runs it.

Parameters:

input_data (InterpretationStep) – The EKA interpretation step to convert

Returns:

The converted output in the target language format

Return type:

Any

export_eka_circuit(input_data)[source]

Export the EKA circuit to the target language format.

Parameters:

input_data (Circuit) – The EKA circuit to convert

Returns:

The converted output in the target language format

Return type:

Any

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'target_language': FieldInfo(annotation=TargetLanguage, required=True, description='Target language for circuit conversion and execution')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

parse_outcome(run_output)[source]

Function to parse the measurement outcomes from the target language run output.

Parameters:

run_output (Any) – The output from running the converted circuit

Returns:

Parsed measurement outcomes as a dictionary mapping channels labels to outcomes or lists of outcomes (for multiple shots)

Return type:

dict[str, int | list[int]]

target_language: TargetLanguage
class loom.executor.executor.TargetLanguage(*values)[source]

Bases: Enum

Enumeration of the available converters.

CUDAQ(**data) = <class 'loom.executor.eka_to_cudaq_converter.EkaToCudaqConverter'>
MIMIQ(**data) = <class 'loom.executor.eka_to_mimiq_converter.EkaToMimiqConverter'>
OPEN_QASM3(**data) = <class 'loom.executor.eka_to_qasm_converter.EkaToQasmConverter'>
PENNYLANE = functools.partial(<class 'loom.executor.eka_to_pennylane_converter.EkaToPennylaneConverter'>, is_catalyst=False)
PENNYLANE_CATALYST = functools.partial(<class 'loom.executor.eka_to_pennylane_converter.EkaToPennylaneConverter'>, is_catalyst=True)
STIM(**data) = <class 'loom.executor.eka_to_stim_converter.EkaToStimConverter'>