diagnose(fn: Callable[..., object], example_inputs: Tensor = ())Trace fn(*example_inputs) and report manual-VJP coverage.
Runs fn once inside a _tracing context to capture the
op DAG, then classifies every op against the registry exposed by
vjp_registration_status (C++ engine binding). Does
not compile or execute the captured graph — purely
introspective, runs in milliseconds even for large models.
Parameters
fnCallableAny callable that returns a
Tensor (or a tuple of
them). An nn.Module instance works because
Module.__call__ is the callable.Positional arguments forwarded to
fn. Their concrete
shape / dtype are recorded into the trace, so the diagnosis
reflects exactly what would be compiled for these inputs.Returns
DiagnosisReportThree-bucket classification + recommendation string. Inspect
.uncovered to see which ops will fall back, or print
str(report) for a quick log line.
Examples
>>> import lucid, lucid.nn as nn
>>> from lucid.compile import diagnose
>>> model = nn.Sequential(nn.Linear(8, 16), nn.ReLU(), nn.Linear(16, 4))
>>> print(diagnose(model, lucid.zeros(2, 8)))
Diagnosis: 5 op(s) total ...
100% manual VJP coverage — no fallback expected ...See Also
- lucid.compile.fused_step—the production training-step compile
path that consults the same registry under the hood.