compile
11 memberslucid.compilelucid.compile — graph-capture compile path for Apple Silicon.
Lowers a Lucid model's forward pass (and optionally its backward +
optimizer-update graph) into a single MPSGraphExecutable
that is cached per input signature. Subsequent calls with the same
signature reuse the cached executable, skipping Python dispatch
entirely for every op inside the captured region.
Notes
compile— the top-level entry. Wraps either annn.Moduleor a plain callable; returns aCompiledModule. Also usable as a decorator (@lucid.compileor@lucid.compile(dynamic=False)).CompiledModule— module-shaped wrapper exposingcache_info()/timing()/clear_cache()plusmodel-delegated APIs (parameters/state_dict/to/train/eval).compile_optimizer— wraps the update step of an optimizer into a single cached executable (8 optimizers supported; seelucid.compile._optim.compiler). Forward + backward stay eager.fused_step— single executable covering forward + loss + backward (via MPSGraph autodiff) + optimizer update via the ghost-grad placeholder mechanism.compiled_step— convenience wrapper combiningcompile+make_stepfor one-line training loops._tracing— low-level context manager that installs a thread-localTracer; used internally by every entry above. Public-but-underscored so external callers know they're touching an unstable surface.
The MPSGraph builder + executable cache + per-op emitters live in
lucid/_C/compile/. See lucid/compile/USER_GUIDE.md
for the production-facing user guide (op coverage, perf numbers,
fallback policy).
Classes
Functions
diagnose→ DiagnosisReportTrace fn(*example_inputs) and report manual-VJP coverage.
compiled_step→ TensorRun one compiled training step: forward + backward + grad assignment.
fused_step→ Callable[..., Tensor]Return a callable that runs one fused training step.
compile_optimizer→ _CompiledStepBaseWrap opt so opt.step() runs as a single MPSGraph executable.
make_step→ callableReturn a callable that runs one compiled training step.
save_compiled→ boolSerialise a compiled forward graph to disk (AOT export).
load_compiled→ objectLoad a previously-saved compiled executable into a thin wrapper.
compile→ CompiledModuleWrap target so calls are routed through cached MPSGraph executables.