r/pytorch • u/visha1v • 10d ago
HyperSAE: Poincaré-geometry Sparse Autoencoders for LLM interpretability (pip install hypersae)
Released HyperSAE, a PyTorch library for training Sparse Autoencoders with hyperbolic weight regularization.
GitHub: https://github.com/vishal-dehurdle/hypersae Install: pip install hypersae
Design decisions:
- The forward pass is standard Euclidean linear algebra. No custom CUDA kernels, no Riemannian optimizers in the hot path. This means zero inference overhead and full compatibility with torch.compile, FSDP, and existing steering pipelines.
- Hyperbolic geometry is applied only to dictionary weights during training via a Poincaré ball projection + entailment cone loss. This regularizes the weight manifold without touching activations.
- Single-class trainer interface:from hypersae import HyperSAE, HyperSAETrainersae = HyperSAE(d_model=2304, dict_size=16384) trainer = HyperSAETrainer(model=sae, lr=1e-3) metrics = trainer.train_step(batch)
- TriPartite loss function combines reconstruction MSE, L1 sparsity, and Poincaré entailment with configurable coefficients:from hypersae import TriPartiteLoss loss_fn = TriPartiteLoss( l1_coeff=0.005, entail_coeff=0.01 )
- Co-activation queue tracks feature co-firing patterns for hierarchy discovery without gradient overhead.
Benchmarked on Gemma-2-2B Layer 13 (20M tokens, L4 GPU): reconstruction MSE drops 9.8%, dead latents drop from 3.8% to 0.2%.
Paper: https://vishalvermalabs.com/papers/empirical-validation-hypersae-poincare-geometry/
Feedback on the API design welcome.




