Skip to content

eproperty

eproperty

The descriptors a family's values are made of.

An EProperty is nnsight's eproperty with two additions: availability (Unavailable, unavailable=) and a path for a key, so one descriptor serves a value wherever it lives: on the host module, on another module named relative to it, or at an operation inside a forward. DerivedEProperty computes one from several served values.

Unavailable

Bases: RuntimeError

A standard value this checkpoint does not have, and why.

Raised on access, before anything runs, so a wrong assumption fails at the line that makes it. Standard.support reports the same reasons without raising.

EProperty

EProperty(key: str | Callable[[Envoy], str] | None = None, description: str | None = None, unavailable: str | Callable[[Envoy], str | None] | None = None, select: int | str | Callable[[Envoy], int | str | None] | None = None)

Bases: eproperty

An eproperty whose key is a path from the host, and which can say when it is unavailable.

PARAMETER DESCRIPTION
key

Where the value lives, relative to the host envoy: dotted segments ending in output, input or inputs, or in another value the module at that point serves (an engine's logits). "output" is the host's own output. A leading "/" anchors the path at the model's root instead (envoy.root), walked down from there as a relative path is, aliases included: "/inputs" is the model's inputs, "/projector.output" the projector's output, from any host. A leading "../" (repeatable) steps to the parent module by native name, another name to a child module (aliases included) or, under a source segment, to an operation: "source" drills into the current module's or operation's forward, instrumenting it for this run, so "source.attention_interface_1.inputs" is the shared attention call's arguments. Above the host the location is the path's string, so "../source.hidden_states_view_0.output" is an operation of the parent block's own forward, which the family instruments at build (Standard.sourced); a call inside that forward cannot be drilled from a child. A function of the host returning such a path, for a forward that branches: it runs at read time, inside the trace, so it can read the forward's own branch variable (RecurrentMixer.KERNEL) or the config (a family's by_alibi). None means the attribute's name, for a bare marker (unavailable).

TYPE: str | Callable[[Envoy], str] | None DEFAULT: None

description

Shown in the model's repr, like any eproperty's.

TYPE: str | None DEFAULT: None

unavailable

A reason string, or a function of the envoy returning a reason or None. A reason makes every read and write raise Unavailable before the model runs, and shows up in Standard.support. It is checked on the instance, so a checkpoint's config can decide (attn_implementation, an alibi variant), and a per-layer difference in a hybrid model too.

TYPE: str | Callable[[Envoy], str | None] | None DEFAULT: None

select

One element of the served value: with inputs an int is a positional argument and a str a keyword; with output an int indexes the returned tuple. A write repacks the element into the current value, so assigning one argument of a call replaces just that argument. input is the call's first argument, inputs with the first element selected. A function of the host returning one of those (or None, the whole value) selects per access, for a value whose position differs between the calls a forward branches to (SelectiveScan's prompt and decode kernels, StateSpace's two kernels).

TYPE: int | str | Callable[[Envoy], int | str | None] | None DEFAULT: None

The location is served by nnsight the way any eproperty's is, whatever the path: a module's output, a sibling norm's, or an operation's arguments, with preprocess, postprocess and transform all available. An operation inside a called function only exists once someone has drilled into that call in the current run (the interleaver resolves the callee from the live value and clears what it built at the start of every run), so a path through source is walked before every read or write. An operation that is not there raises SourceNotAvailable naming what is, rather than the AttributeError a descriptor would otherwise swallow into "no attribute".

locate instance-attribute

locate = key if callable(key) else None

unavailable instance-attribute

unavailable = unavailable

select instance-attribute

select = select

layout property

layout: Any

The value's shape as a jaxtyping type (Residual, Pattern, ...), or None.

Read off the return annotation of the function that defines the value. isinstance(tensor, value.layout) checks rank and dtype; dims names the axes, the same on every family.

dims property

dims: tuple[str, ...] | None

The axis names of layout: ("batch", "seq", "hidden_size").

__set_name__

__set_name__(owner: type, name: str) -> None

reason

reason(obj: Envoy) -> str | None

Why this value is not available on obj, or None when it is.

__str__

__str__() -> str

The repr line: (name) -> Layout [axes]: description for a value with a layout, else nnsight's line.

path

path(obj: Envoy) -> str

The key for obj: the path itself, or what the key function returns for it.

inside_forward

inside_forward() -> bool

Whether the value is an operation inside a forward (a key function, or a source segment on its path).

attribute staticmethod

attribute(key: str) -> str

The served attribute a path ends in: output, input, inputs, or another an engine serves (logits).

__get__

__get__(obj: Envoy | None, owner: Any = None) -> Any

__set__

__set__(obj: Envoy, value: Any) -> None

DerivedEProperty

DerivedEProperty(compute: Callable[[Envoy], Any], description: str | None = None, unavailable: Any = None)

Bases: EProperty

An EProperty computed from other served values rather than read at one location.

compute(envoy) runs at read time inside the trace and may read any number of values; the result is read-only (assign through whatever method the host offers). Listed in the repr like any value.

compute instance-attribute

compute = compute

__get__

__get__(obj: Envoy | None, owner: Any = None) -> Any

__set__

__set__(obj: Envoy, value: Any) -> None

layout_name

layout_name(layout: Any) -> str

The name a layout alias is exported under (Residual, Pattern), else the type's own name.

unavailable

unavailable(reason: str) -> EProperty

A value a family does not have: assign it in the class body in place of the inherited one.

attention_probabilities = unavailable("no softmax: the attention is linear") keeps the name in the tree and in the repr, with the reason, and makes any access raise Unavailable with it.