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
TYPE:
|
description
|
Shown in the model's repr, like any eproperty's.
TYPE:
|
unavailable
|
A reason string, or a function of the envoy returning a
reason or
TYPE:
|
select
|
One element of the served value: with
TYPE:
|
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".
layout
property
¶
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
¶
The axis names of layout: ("batch", "seq", "hidden_size").
reason
¶
Why this value is not available on obj, or None when it is.
__str__
¶
The repr line: (name) -> Layout [axes]: description for a value with a layout, else nnsight's line.
path
¶
The key for obj: the path itself, or what the key function returns for it.
inside_forward
¶
Whether the value is an operation inside a forward (a key function, or a source segment on its path).
attribute
staticmethod
¶
The served attribute a path ends in: output, input, inputs, or another an engine serves (logits).
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.
layout_name
¶
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.