Host

class pmrf.models.adapters.bridge.Host(*, name: str | None = None, metadata: Any = None, domain: str = 's', z0: Any = 50.0)

Bases: AbstractSingleDomain

An abstract base class for models where computation occurs on the Host (CPU/Python) rather than the Device (XLA/GPU).

Inherit from this class (defining your parameters as usual) to create a ParamRF model that calls external software.

These models break the JAX trace and cannot be JIT-compiled internally. Execution is threaded automatically when vmapped.

NB: Any vmapping over model properties will automatically create a thread pool to execute the individual batches in parallel. If this feature is to be used, compute() must be written in a thread-safe manner, as it may be called from multiple threads that share the same memory.

abstractmethod compute(freq: Frequency) ndarray | Array

The user-defined host-side computation, to be overriden.

This method receives concrete values (not tracers) and should return a numpy array of shape (n_freq, n_ports, n_ports).

matrix(freq: Frequency) Array

The JIT-compatible entry point. Automatically handles threading if called inside a vmap.

abstract property number_of_ports

Number of ports.

Return type:

int