Skip to content

Backends

base

Backend interface and registry.

A backend wraps one implementation of one method. Third-party packages can register more backends (e.g. GPL-licensed solvers kept out of the MIT core) through the lightsmith.backends entry-point group, each entry pointing at a :class:Backend subclass.

Backend

Bases: ABC

name class-attribute

name: str

method class-attribute

method: str

license class-attribute

license: str

citation class-attribute

citation: str = ''

gpu class-attribute

gpu: bool = False

differentiable class-attribute

differentiable: bool = False

problem_kinds class-attribute

problem_kinds: tuple[str, ...] = ('scattering',)

available classmethod

available() -> tuple[bool, str]

Whether the backend's dependencies are installed (and why not).

supports abstractmethod classmethod

supports(sim: Simulation) -> tuple[bool, str]

Whether this backend can solve sim (and why not).

estimate classmethod

estimate(sim: Simulation, device: Device) -> dict[str, Any]

Cheap pre-flight estimate of problem size and memory. Never solves.

solve abstractmethod classmethod

solve(sim: Simulation, device: Device) -> Result

info classmethod

info() -> dict[str, Any]

unsupported_outputs

unsupported_outputs(sim: Simulation, *, near_field: bool = False, far_field: bool = False, substrate: bool = False, orientation_average: bool = False) -> str

Helper for supports: name the requested features a backend lacks ('' if none).

register

register(cls: type[Backend]) -> type[Backend]

all_backends

all_backends() -> list[type[Backend]]

get_backend

get_backend(name_or_method: str, kind: str | None = None) -> type[Backend]

Look up by backend name, or by method name (first available backend for kind wins).