Superposition stores more features than dimensions as directions that are nearly, not exactly, orthogonal. Measure how many such directions fit and what the interference costs.
random_unit_vectors(rng, n, d)
n rows drawn with one rng.normal(size=(n, d)) call and normalised to unit length.max_abs_cosine(V)
V.greedy_pack(rng, d, eps, max_tries)
rng.normal(size=d), normalised) and keep a candidate only if its absolute cosine with every kept vector is at most eps. Stop after max_tries draws and return the (n, d) array of kept vectors.interference(V, x)
V is (n, d) feature directions, x an (n,) activation vector. The layer stores h = V.T @ x and reads back x_hat = V @ h. Return x_hat - x, the per-feature interference.relu_readout_error(V, x)
np.maximum(V @ (V.T @ x), 0), minus x; its squared norm as a float.np.linalg.norm(..., axis=1, keepdims=True).d + 1 vectors the interference on an inactive feature is negative and the ReLU removes it.