Skip to content

remoteable

remoteable

RemoteableMixin

RemoteableMixin(*args, dispatch: bool = False, meta_buffers: bool = True, rename: Optional[Dict[str, str]] = None, **kwargs)

Bases: MetaMixin

Mixin that adds remote execution support via NDIF.

Extends :class:MetaMixin with remote and backend parameters on :meth:trace and :meth:session, enabling interventions to be serialized and executed on remote infrastructure.

Subclasses must implement :meth:_remoteable_model_key (returns a string identifying the model for the remote server) and :meth:_remoteable_from_model_key (reconstructs the wrapper from that key on the server side).

trace

trace(*inputs: Any, backend: Union[Backend, str, None] = None, remote: Union[bool, str] = False, blocking: bool = True, **kwargs: Dict[str, Any])

Open a tracing context for a single forward pass.

Extends the base :meth:trace with remote execution options.

PARAMETER DESCRIPTION
*inputs

Model inputs (strings, tensors, etc.).

TYPE: Any DEFAULT: ()

backend

Explicit backend instance or a URL string for a :class:RemoteBackend.

TYPE: Union[Backend, str, None] DEFAULT: None

remote

True to execute on NDIF, 'local' for local simulation, or False (default) for local execution.

TYPE: Union[bool, str] DEFAULT: False

blocking

If True (default), block until the remote job completes.

TYPE: bool DEFAULT: True

**kwargs

Forwarded to the underlying trace.

TYPE: Dict[str, Any] DEFAULT: {}

RETURNS DESCRIPTION

A tracing context manager.

session

session(*inputs: Any, backend: Union[Backend, str, None] = None, remote: bool = False, blocking: bool = True, **kwargs: Dict[str, Any])

Open a session context grouping multiple traces.

PARAMETER DESCRIPTION
*inputs

Inputs forwarded to the underlying session.

TYPE: Any DEFAULT: ()

backend

Explicit backend instance or a URL string for a :class:RemoteBackend.

TYPE: Union[Backend, str, None] DEFAULT: None

remote

If True, execute on NDIF.

TYPE: bool DEFAULT: False

blocking

If True (default), block until the remote job completes.

TYPE: bool DEFAULT: True

**kwargs

Forwarded to the underlying session.

TYPE: Dict[str, Any] DEFAULT: {}

to_model_key

to_model_key() -> str

Build a fully-qualified model key including the class import path.

The key has the form "import.path.ClassName:model_specific_key" and is used by NDIF to locate and reconstruct the model on the server.

from_model_key classmethod

from_model_key(model_key: str, **kwargs) -> Self

Reconstruct a model wrapper from a fully-qualified model key.

Parses the import path, imports the correct class, and delegates to :meth:_remoteable_from_model_key.

PARAMETER DESCRIPTION
model_key

Key in the form "import.path:model_key".

TYPE: str

**kwargs

Additional arguments forwarded to the class constructor.

DEFAULT: {}

StreamTracer

StreamTracer(frame: FrameType, *args, **kwargs)

Bases: Tracer

Tracer that serializes intervention code, sends it to a remote server, and injects results back into the caller's frame.

Used by :meth:RemoteTracer.local to enable hybrid local/remote execution within a remote session.

frame instance-attribute

frame = frame

register classmethod

register(send_fn: Callable, recv_fn: Callable)

Register the send/receive callables used for remote communication.

deregister classmethod

deregister()

Clear the registered send/receive callables.

execute

execute(fn: Callable)

RemoteTracer

RemoteTracer(*args, backend: Backend = None, _info: Info = None, **kwargs)

Bases: Tracer

Tracer used inside remote sessions that supports hybrid local/remote execution.

local

local()

RemoteInterleavingTracer

RemoteInterleavingTracer(fn: Callable, model: Envoy, *args, backend: Backend = None, **kwargs)

Bases: InterleavingTracer, RemoteTracer

Interleaving tracer with remote execution capabilities.

Combines :class:InterleavingTracer (thread-based interleaving) with :class:RemoteTracer (remote/hybrid support) for use in model.trace(remote=True).