A copyable, self-contained record of every activation cached during one forward pass, plus the node ids in topological order and each node's op_type/label metadata.
More...
#include <activation_snapshot.hpp>
A copyable, self-contained record of every activation cached during one forward pass, plus the node ids in topological order and each node's op_type/label metadata.
- Note
- Holds no reference to the ComputationGraph or ExplainerContext it was captured from – deliberately. ExplainerContext::forward_pass() replaces its graph and activation cache wholesale on every call, and ComputationGraph is move-only (std::vector<std::unique_ptr<Node>>), so a snapshot that referred back to either would be invalidated by the very next forward pass. Copying the activation Tensors and the small amount of per-node metadata instead is what makes two snapshots from two different forward passes simultaneously alive and correct – the capability activation patching needs (campaign campaign_exai_dl_library_mechanistic_interpretability, Phase 4).
-
NodeIds are comparable across two snapshots taken from the same ExplainerContext: its module chain is fixed for its lifetime, so every forward pass builds a structurally identical graph (same node count, same op-type sequence, same ids), differing only in the cached values.
-
Constructed by ExplainerContext::activation_snapshot(), not assembled by hand.
◆ ActivationSnapshot()
| pulsatrix::ActivationSnapshot::ActivationSnapshot |
( |
std::unordered_map< NodeId, Tensor > |
activations, |
|
|
std::vector< NodeId > |
node_ids, |
|
|
std::unordered_map< NodeId, NodeMetadata > |
metadata |
|
) |
| |
|
inline |
Constructs a snapshot from already-captured data.
- Parameters
-
| activations | Deep copy of the cached activation value per node id. |
| node_ids | Node ids in topological order at capture time. |
| metadata | Per-node op_type/label, captured at the same moment. |
- Note
- No cross-validation between the three arguments: this constructor is reached only from ExplainerContext::activation_snapshot(), which builds all three from one consistent graph in a single pass. An empty snapshot (all three empty) is a well-formed value, not an error – it is what a context that has not yet run a forward pass produces.
◆ activation()
| const Tensor & pulsatrix::ActivationSnapshot::activation |
( |
NodeId |
id | ) |
const |
|
inline |
The activation value captured at a node.
- Parameters
-
- Note
- Mirrors ExplainerContext::activation()'s not-found behavior (PULSATRIX_ASSERT): internal-only invariant per cpp_tdd/context_tdd_adversarial_boundary_testing.md's classification table – every id a caller can legitimately hold came from node_ids().
◆ label()
| std::optional< std::string > pulsatrix::ActivationSnapshot::label |
( |
NodeId |
id | ) |
const |
|
inline |
The optional label captured at a node.
- Parameters
-
- Returns
- The node's label, or std::nullopt if it had none.
◆ node_ids()
| const std::vector< NodeId > & pulsatrix::ActivationSnapshot::node_ids |
( |
| ) |
const |
|
inline |
Every captured node id, in topological order as of capture time.
- Note
- The enumeration capability ExplainerContext's single-node activation() lookup lacks – Phase 2's linear probing iterates this to reach every cached layer.
◆ op_type()
| OpType pulsatrix::ActivationSnapshot::op_type |
( |
NodeId |
id | ) |
const |
|
inline |
The op-type tag captured at a node.
- Parameters
-
The documentation for this class was generated from the following file: