Skip to content

Quickstart

Get from zero to basin surgery in 5 minutes. No checkpoint needed.

Install

bash
pip install qriton-hlm

Create a Synthetic Model

python
import torch
from qriton_hlm import BasinSurgeon

d_model = 128
torch.manual_seed(42)
W = torch.randn(d_model, d_model) * 0.01
W = (W + W.T) / 2

surgeon = BasinSurgeon.from_W(W)

Survey

python
survey = surgeon.survey(layer=0)
print(f"{survey['num_basins']} basins found")

for i in range(min(5, survey['num_basins'])):
    print(f"  B{i}  E={survey['energies'][i]:+.4f}  pop={survey['populations'][i]}")

Inject

python
result = surgeon.inject(layer=0, seed=42, strength=0.1)
print(f"New basin created: {result['exists_after']}")

Verify

python
v = surgeon.verify(layer=0, seed=42)
print(f"Is basin: {v['is_basin']}  cos={v['cos']:.4f}")

Restore

python
surgeon.restore(layer=0)

Next