Serialise a compiled forward graph to disk (AOT export).
Writes two files at path: <path>.mpsgraphpackage (Apple's
native MPSGraphExecutable archive, macOS 14+) and <path>.meta
(Lucid's I/O plan + dtype / shape / ABI metadata). A
CompiledModule may hold multiple cached executables (one
per input signature); this entry point currently serialises the
most-recently-compiled signature only — sufficient for AOT
deployment where the production input shape is fixed.
The on-disk artifact is identical to the per-process cache used
when LUCID_COMPILE_DISK_CACHE=1 is set — so calls
save_compiled produces by hand are loadable by either
load_compiled or the runtime cache machinery.
Parameters
lucid.compile. Must have
been invoked at least once so an executable exists to save.pathstrf"{path}.mpsgraphpackage" and f"{path}.meta".Returns
boolTrue on success. Raises RuntimeError if cm
has no compiled entries (call the module once with the
target input first).
Examples
>>> import lucid, lucid.nn as nn
>>> import lucid.compile as lc
>>> m = nn.Linear(8, 4).to("metal")
>>> cm = lc.compile(m)
>>> _ = cm(lucid.randn(2, 8).to("metal")) # populate cache
>>> lc.save_compiled(cm, "/tmp/my_linear") # writes .mpsgraphpackage + .meta
True