Skip to content
fn

diagnose

→DiagnosisReport
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

fnCallable
Any callable that returns a Tensor (or a tuple of them). An nn.Module instance works because Module.__call__ is the callable.
*example_inputsTensor= ()
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

DiagnosisReport

Three-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

Used by 1