loom.executor.eka_circuit_to_stim_converter

Copyright (c) Entropica Labs Pte Ltd 2025.

Use, distribution and reproduction of this program in its source or compiled form is prohibited without the express written consent of Entropica Labs Pte Ltd.

class loom.executor.eka_circuit_to_stim_converter.EkaCircuitToStimConverter[source]

Bases: object

Convert an Eka circuit description in Stim

property classically_controlled_gate_mapper: dict[str, str]

A dictionary mapping Circuit classically controlled gates to their corresponding Stim operations.

convert(interpreted_eka, with_ticks=False, error_models=None)[source]

A method to convert the eka_circuit into stim circuit

Properties of the interpreted_eka used for the conversion:

1.) Circuit 2.) Blocks 3.) Syndrome history 4.) Detectors list 5.) Logical observables list

Parameters:
  • interpreted_eka (InterpretationStep) – The final interpretation step for the complete circuit containing necessary information on the program

  • with_ticks (bool, optional) – If True, append a TICK instruction after each layer

Returns:

stim_circuit – The iteratively generated StimCircuit.

Return type:

StimCircuit

eka_channel_to_stim_qubit_instruction_mapper(circuit, eka_coords_to_stim_qubit_instruction)[source]

Based on the input EKA circuit, define stim qubits as QUBIT_COORDS Each non-classical channel in the input eka circuit is mapped to the respective qubit declaration in stim. Its a map containing elements, for e.g. :

{Channel('q',id,): CircuitInstruction("QUBIT_COORDS", q, [x, y]}

Parameters:
  • circuit (Circuit) – The EKA circuit object

  • eka_coords_to_stim_qubit_instruction (dict[tuple[int,...], CircuitInstruction]) – The mapping between EKA coordinates and stim qubit instructions

Returns:

The mapping between circuit channels and stim qubit instructions

Return type:

dict[Channel, CircuitInstruction]

eka_coords_to_stim_qubit_instruction_mapper(eka_circuit)[source]

Generate stim qubits from all input blocks

Parameters:

circuit (Circuit) – The input EKA circuit object

Returns:

Mapping between Eka coordinates and stim qubit instructions

Return type:

dict[tuple, CircuitInstruction]

generate_stim_circuit_instruction(name, targets, gate_args=None)[source]

Return the StimCircuit.CircuitInstruction corresponding to the input operator

Parameters:
  • name (str) – The input stim circuit operator name

  • targets (list[int]) – The list of indices the gate is acting on

  • gate_args (str) –

    A list of arguments for parameterizing the gate. For e.g.

    • noise_probability for noise instruction

    • location coordinate for qubit declarations

    NOTE: This is a parameter of the CircuitInstruction, which depends on the type of instruction specified

Returns:

circuit_instructions – Stim circuit instructions for an input name and qubit target

Return type:

list[CircuitInstruction]

property measurement_mapper: dict[str, str]

A dictionary mapping Eka measurement operations to their corresponding Stim operations.

property misc_mapper: dict[str, str]

A dictionary mapping Eka miscellaneous operations to their corresponding Stim operations.

property noise_annotation_mapper: dict[ErrorType, str]

A dictionary mapping error types to the corresponding Stim operation name.

print_stim_circuit_for_crumble(final_step)[source]

Print the stim circuit along with polygon instructions to be used for crumble

Parameters:

stim_circ (StimCircuit) – input stim circuit

Return type:

str

property reset_mapper: dict[str, str | tuple[str]]

A dictionary mapping Eka measurement operations to their corresponding Stim operations or list of operations.

property single_qubit_gate_mapper: dict[str, str]

A dictionary mapping Circuit single qubit gates to their corresponding Stim operations.

stim_polygons(interpreted_eka)[source]

Define stim polygons using data qubits coordinates involved with each stabilizer on blocks passed as argument to the function

DEMO SYNTAX: #!pragma POLYGON(1,0,0,0.25) 5 11 16 23

POLYGON(<X>, <Y>, <Z>, <color intensity>) <data qubits involved>

Since polygon definitions are added as comments in the stim circuit body, and there is no way to add comments programmatically in StimCircuit This function is only available to print polygon instructions from the block stabilizers. The user MUST add these comments manually to the StimCircuit string body to display the polygons in crumble

Parameters:

interpreted_eka (InterpretationStep) – The InterpretationStep object containing information on the code stabilizers

Returns:

stim_polygons – Stim polygon instructions as a string

Return type:

str

property to_stim_ops_mapper: dict[str, str | tuple[str]]

This property is a dict mapping Eka operations to their corresponding Stim operations. The keys are the Eka operation names and the values are the Stim operations.

Returns:

A mapping between Circuit instruction names and stim instruction names

Return type:

dict

property two_qubit_gate_mapper: dict[str, str]

A dictionary mapping Circuit two qubit gates to their corresponding Stim operations.

loom.executor.eka_circuit_to_stim_converter.noise_annotated_stim_circuit(stim_circ, before_measure_flip_probability=0, after_clifford_depolarization=0, after_reset_flip_probability=0)[source]

This function takes as input a pure (sans noise) stim circuit, and outputs a the circuit with the desired noise model

Parameters:
  • stim_circ (StimCircuit) – The input noiseless stim circuit

  • before_measure_flip_probability (float, optional) – X_ERROR probability before a measurement. Default set to 0 will add no measurement errors

  • after_clifford_depolarization (float, optional) – applies DEPOLARIZING_ERROR1 and DEPOLARIZING_ERROR2 after each single and two qubit clifford gate in the circuit. Default set to 0 will add no depolarization errors

  • after_reset_flip_probability (float, optional) – Apply an X_ERROR with this probability after a reset gate. Default set to 0 will add no reset errors

Returns:

stim circuit annotated with the input noise model

Return type:

StimCircuit