API reference¶
Every name below is imported straight from the package
(from kpnn2 import ...). Module paths inside kpnn2 are private
and may change between releases.
Callables¶
Names you call or construct.
| Name | Description |
|---|---|
parse_layered |
Parse a source/target edgelist into a LayeredSpec (DAG only; optional widths=, ranks=). |
parse_adjacency |
Parse a source/target edgelist into an AdjacencySpec (packed layout; cycles allowed). |
MaskedLinear |
Linear layer that keeps only the connections in a fixed mask. |
PackedLinear |
Linear layer with one weight per live edge, not a dense matrix. |
PackedMultiheadAttention |
Attention that scores only live edgelist pairs, not a full matrix. |
gather_hop_inputs |
Build the input for one hop from the layer activations you saved. |
scatter_hop_outputs |
Split a hop's concatenated source axis back onto source layers. |
align_inputs |
Feature names → column index so the wiring matches. |
map_node_attributions |
Attach spec node names to an attribution tensor you already computed. |
aggregate_node_attributions |
Reduce mapped node scores with a registered method (default rauter_mangano_2026 is not yet implemented). |
list_aggregation_methods |
Table of registered attribution aggregation methods and their status. |
Specs¶
Returned by the parsers. Frozen dataclasses; densify with
to_mask() when you need a rectangle.
| Name | Description |
|---|---|
LayeredSpec |
A DAG as named layers and packed hops; not a ready-made model. |
Hop |
Incoming packed wiring of one layer; pass its indices to PackedLinear. |
Skip |
Record of an edge that jumps layers; already a packed pair of its hop. |
AdjacencySpec |
Every node in one state vector, with packed edges; the general packed layout. |
Errors and version¶
| Name | Description |
|---|---|
Kpnn2Error |
Error raised by the public API when a call is invalid. |
__version__ |
Package version string. |