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
LazyRealizationContext
LazyRealizationContext
class max.experimental.realization_context.LazyRealizationContext(executor=None, *, use_interpreter=None)
Bases: EagerRealizationContext
A realization context that defers execution until explicitly requested.
Unlike EagerRealizationContext, this context does not automatically
execute the computation graph when the context exits. Tensors remain
unrealized until explicitly awaited via await tensor.realize.
This is useful for batching many operations together before execution, improving performance by reducing compilation overhead.
Example:
with F.lazy():
a = Tensor.zeros([5, 5])
b = a + 1
c = b * 2
assert not c.real
await c.realize # Now compile and execute
assert c.realInitializes the context.
-
Parameters:
-
- executor (Executor | None) – Executor used to run the finalized graph.
Noneresolves todefault_executor()at construction time. - use_interpreter (bool | None) – Deprecated. Selects an executor for backward
compatibility when
executoris not given:Trueforces the interpreter for any graph the interpreter accepts (runtime errors propagate),Falseforces compilation, andNoneuses the default executor.
- executor (Executor | None) – Executor used to run the finalized graph.
subgraph_cache
Subgraph dedup table; armed per instance by lazy().
subgraph_out_defs
Output tree structure per keyed subgraph (see
GraphRealizationContext.subgraph_out_defs).