pulsatrix 1.1.0
Loading...
Searching...
No Matches
point_cloud.hpp File Reference

The input to topological data analysis: a layer's activations as a set of points, one row per input or per position, gathered across batches. More...

#include <cstdint>
#include <vector>
#include "pulsatrix/activation_snapshot.hpp"
#include "pulsatrix/node.hpp"
#include "pulsatrix/tensor.hpp"
Include dependency graph for point_cloud.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pulsatrix::PointCloudOptions
 PointCloud's settings. More...
 
struct  pulsatrix::PointOrigin
 Where one point of a PointCloud came from. More...
 
class  pulsatrix::PointCloud
 A set of points in R^dimension, built from activation batches. More...
 

Namespaces

namespace  pulsatrix
 

Enumerations

enum class  pulsatrix::PointPooling {
  pulsatrix::Flatten , pulsatrix::PerPosition , pulsatrix::Mean , pulsatrix::Max ,
  pulsatrix::Last
}
 How PointCloud turns one sample's activations into points. More...
 

Functions

PointCloud pulsatrix::MakePointCloud (const std::vector< ActivationSnapshot > &snapshots, NodeId node, PointCloudOptions options={})
 A cloud from one node of several forward passes, such as one snapshot per batch.
 

Detailed Description

The input to topological data analysis: a layer's activations as a set of points, one row per input or per position, gathered across batches.

Persistent homology measures the shape of a finite set of points. A layer's activations come as batches of tensors, (batch, ...), from ActivationSnapshot or a model's hooks. PointCloud turns those batches into one (n, dimension) set of points, and records where each point came from, so a loop or a cluster found later can be traced back to the inputs and positions that form it.

How a sample becomes points is the one choice to make (PointPooling):

  • Flatten (the default): one point per sample, every dimension after the batch flattened. Right for an MLP layer or a classifier's logits.
  • PerPosition: one point per token or pixel, with the feature axis as its coordinates. Right for the geometry of token representations.
  • Mean, Max or Last: one point per sample, pooled over its positions. Last is a causal language model's summary of the whole input.