standard¶
standard
¶
Standard, the envoy every component derives from, the axis names every layout is spelled with, the two helpers for tuple outputs, and the walk support makes over a block list.
Standard
¶
Bases: Envoy
An envoy carrying standard values: what Layer, Attention and Mlp share.
A value that is an operation inside a forward is served only on a call
whose forward was instrumented before the call began. Instrumenting on
first read is enough when the read comes before the module runs, which
is the usual case; it is too late when the worker is already parked
inside the module, as it is when a block's mlp_output (an operation
in the block's forward) is read after the block's attention_output.
A family whose value sits in such a forward sets sourced = True on
that envoy, and the forward is instrumented when the envoy is built and
again when real weights replace meta ones, which reinstalls the plain
forward.
first_tensor
¶
The tensor of a module output: the first element when it is a tuple.
rewrap
¶
value in the shape the module returned: back in its tuple, if any.
module_int
¶
The first of names the module holds as an integer, or None.
in_width
¶
The input width of the first of names the module has as a projection (nn.Linear, or transformers' Conv1D), or None.
absent
¶
Why a value at the child module name is unavailable: the envoy has no such child or alias. None when it has.
unsized
¶
The error a size raises when the module spells it no way the base reads.
axis_size
¶
The size of layout axis axis on a value envoy serves.
An axis that is a fact about the model is named as the size that holds
it (HIDDEN is "hidden_size", HEADS "num_heads"), so its size
is that attribute: on envoy when its class declares it (an
attention's num_heads, a mixture's num_experts), else on the
first envoy above it that does, up to the model's root (hidden_size,
vocab_size)::
axis_size(model.layers[3], HIDDEN) # model.hidden_size
axis_size(model.layers[3].self_attn, HEADS) # this block's heads
Only an envoy's class counts (a property, the root's
StandardizedProperty), never an attribute of the wrapped module, which
can share a name and hold another number.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
no envoy from |
values
¶
values(cls: type) -> dict[str, EProperty]
A class's standard values by name, base classes first.
standard_children
¶
standard_children(block: Envoy) -> dict[str, Standard]
The block's children that carry standard values, by standard name (the alias where one is bound).
block_hosts
¶
Standard-value hosts across every block: module name -> value names, in first-seen order.
The union over the blocks, so a hybrid lists both self_attn and
linear_attn and a block lacking one reports it as missing; a
module no block has (OPT's mlp) is not listed.
block_support
¶
One block's values by dotted name, over hosts: None when available, else the reason.
blocks_support
¶
The block values of a block list, the way support reports them.
With layer, that block's values by dotted name ("layer_output",
"self_attn.attention_probabilities"). Without, each value -> None
when available on every block, else {layer: reason} for the blocks
where it is not. Shared by the text model's blocks and a vision tower's.