CompilationReport#

class braintrace.CompilationReport(graph)#

A read-only view over a compiled ETraceGraph.

Parameters:

graph (ETraceGraph) – The compiled eligibility-trace graph to summarise.

Notes

All properties are derived on access from graph; the report stores no independent state. to_str(1) renders the full structural summary (hidden groups, dynamic states, eligibility-trace weights, excluded weights); to_str(2) additionally appends WARNING/ERROR compiler diagnostics.

Examples

>>> import brainstate, jax.numpy as jnp, braintrace
>>> gru = braintrace.nn.GRUCell(3, 4)
>>> _ = brainstate.nn.init_all_states(gru)
>>> graph = braintrace.compile_etrace_graph(gru, jnp.ones((3,)))
>>> report = braintrace.CompilationReport(graph)
>>> report.counts['hidden_groups'] >= 1
True
property counts: Dict[str, int]#

Summary counts of groups, weights, and diagnostic severities.

property diagnostics: Tuple[CompilationRecord, ...]#

The structured compiler diagnostics, in emission order.

property dynamic_states: List[Tuple[str, ...]]#

ShortTermState paths that are not part of any hidden group.

property etrace_weights: List[Tuple[Tuple[str, ...], List[int]]]#

List of (weight_path, [group_index, ...]) for ETP-routed weights.

property excluded_weights: List[Tuple[Tuple[str, ...], str | None]]#

ParamState paths not routed through any ETP op, with a reason if known.

property graph: ETraceGraph#

The wrapped ETraceGraph.

property hidden_groups: List[Tuple[int, List[Tuple[str, ...]]]]#

List of (group_index, hidden_paths) for each hidden group.

show(level=1, *, file=None)[source]#

Print to_str() to file (stdout by default).

Parameters:
  • level (int) – Verbosity passed to to_str(): 1 (default) renders the full structural summary; 2 also appends WARNING/ERROR compiler diagnostics.

  • file (file-like, optional) – Destination forwarded to print(). Defaults to None (standard output).

Return type:

None

to_str(level=1)[source]#

Render the report as text.

Parameters:

level (int) – 1 (default) renders the full structural summary; 2 also appends WARNING/ERROR compiler diagnostics.

Returns:

The rendered report.

Return type:

str