Host

class pmrf.models.adapters.bridge.Host(*, z0: complex = 50 + 0j, name: str | None = None, metadata: Any = None)

Bases: Model

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).

primary_matrix(freq: Frequency) Array

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

property number_of_ports

Number of ports.

Return type:

int

property primary_property

The primary property (e.g. "s", "a") as a string.

The primary property is the first overridden among PRIMARY_PROPERTIES, unless build is overridden, in which case the primary property of the built model is returned.

Return type:

str

Raises:

NotImplementedError – If no primary property is overridden.