IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python class

JitExecutor

JitExecutor​

class max.experimental.executor.JitExecutor(*, interpreter, sync_on_interpreter_fallback=True)

source

Bases: object

Executes via the interpreter while compiling in the background.

The first call for a given graph (keyed by structure) submits the graph to a background compile process (ProcessCompilePool) and caches the resulting future for the life of this executor. The future resolves to an initialized model: session.init runs as soon as the compile lands, off the calling thread, so a call that finds a done future executes immediately. While the compile is pending, calls execute via the interpreter. When the interpreter refuses a graph, the call waits for that graph’s compile.

Failed compilations are assumed to not be transient and are cached.

Initializes the executor.

Parameters:

  • interpreter (Executor) – Executor serving graphs whose compile is pending.
  • sync_on_interpreter_fallback (bool) – Whether a graph the interpreter refuses waits for its compile. When False such a graph raises UnsupportedGraphError instead.

cache​

cache: dict[tuple[str, tuple[tuple[str, str], ...]], Future[Model]]

source

compile()​

compile(graph)

source

Submits the graph to the compiler on first sight.

Returns:

A future resolving to the initialized model.

Parameters:

graph (Graph)

Return type:

Future[Model]

execute()​

execute(graph, inputs)

source

Executes graph, compiling in the background on first call.

Raises:

Exception – The interpreter’s own error, when it fails and sync_on_interpreter_fallback is False.

Parameters:

Return type:

Sequence[Buffer | None]

lock​

lock: lock

source