merlin.algorithms.module module

class merlin.algorithms.module.MerlinModule

Bases: Module

Base Merlin module with shared execution-policy utilities.

Parameters:

None

Notes

Merlin remote execution policy:

  • _force_simulation defaults to False. When True, the layer must run locally.

  • force_local exposes that flag through a property interface.

  • supports_offload() reports whether remote offload is possible via export_config().

  • should_offload() returns whether the current module should be offloaded under the active policy.

  • as_simulation() provides a context manager that temporarily forces local simulation.

as_simulation()

Temporarily force local simulation within the context.

property force_local: bool

When True, this layer must run locally (Merlin will not offload it).

static setup_device_and_dtype(device, dtype)

Normalize device/dtype to final forms.

Return type:

tuple[Optional[device], dtype, dtype]

should_offload()

Return True if this layer should be offloaded under current policy.

Return type:

bool

supports_offload()

Return True if this layer is technically offloadable.

Return type:

bool