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 function

compile_and_init_graphs

compile_and_init_graphs()​

max.pipelines.lib.graph_specs.compile_and_init_graphs(session, specs)

source

Compiles and initializes each role’s graph.

Roles that share a group trace into one Module, compile once, and initialize once with the weights of all of them; each role’s callable then holds the same compiled model. Each compiles through compile_reusing_mefs(), so an ungrouped role reuses the session’s precompiled or exported MEFs. A group compiles every time, as any module of several graphs does. Inside compile_roles_separately(), groups are ignored.

Each callable is called with one argument per input type, positionally, or with the named input tree as its one argument, and returns the graph’s outputs in the tree its forward returned. It keeps no weight registry, so the host weights can be released after initialization. A ModuleV3 role’s callable instead takes and returns what the module’s forward does, adds the signal buffers a multi-device graph takes, and keeps its weight registry.

Parameters:

Returns:

Each role’s compiled, initialized graph.

Raises:

ValueError – If two roles in one group share a graph name, or bind different values to one weight name.

Return type:

dict[str, CompiledCallable[…, Any]]