IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Python class

CompilationTimer

CompilationTimer

class max.pipelines.lib.CompilationTimer(name)

source

Bases: object

Timer for logging graph build, compile, and init phases.

Use as a context manager. Starts timing on entry. Call mark_build_complete() after graph building; per-phase timings are logged on exit. Compile and init durations come from engine instrumentation inside InferenceSession.compile() and InferenceSession.init_all(), so they are accurate even when the timer wraps a higher-level call like session.load_all.

Parameters:

name (str) – The name to use in log messages (e.g., “model”, “vision model”).

Example:

>>> with CompilationTimer("model") as timer:
...     graph = self._build_graph(self.weights, self.adapter)
...     timer.mark_build_complete()
...     model = session.load(graph, weights_registry=self.state_dict)

mark_build_complete()

mark_build_complete()

source

Marks the end of the build phase and logs build time.

Return type:

None