geolip-conduit-experiments / notebook_cell_1_hello_world.py
AbstractPhil's picture
Update notebook_cell_1_hello_world.py
c2812d3 verified
"""
FLEighConduit — Quick Smoke Test
Run this cell to verify the conduit is working.
To install the geolip-core repo simply install the geolip-svae repo, which will install it automatically.
Run this as code cell 0.
!pip install "git+https://github.com/AbstractEyes/geolip-svae.git"
"""
import torch
from geolip_core.linalg import FLEighConduit, verify_parity
# Random symmetric 4×4 matrices
B, n = 32, 4
A = torch.randn(B, n, n, device='cuda')
A = (A + A.transpose(-1, -2)) / 2
# Standard conduit
solver = FLEighConduit().cuda()
packet = solver(A)
print("=" * 60)
print("FLEighConduit — Smoke Test")
print("=" * 60)
print(f" Input: ({B}, {n}, {n})")
print(f" eigenvalues: {packet.eigenvalues.shape}")
print(f" eigenvectors: {packet.eigenvectors.shape}")
print(f" char_coeffs: {packet.char_coeffs.shape}")
print(f" friction: {packet.friction.shape}")
print(f" settle: {packet.settle.shape}")
print(f" extraction_order: {packet.extraction_order.shape}")
print(f" refinement_resid: {packet.refinement_residual.shape}")
print()
# Sample values
print("Sample patch 0:")
print(f" eigenvalues: {packet.eigenvalues[0].tolist()}")
print(f" friction: {[f'{v:.2f}' for v in packet.friction[0].tolist()]}")
print(f" settle: {packet.settle[0].tolist()}")
print(f" refine resid: {packet.refinement_residual[0].item():.2e}")
print()
# Friction statistics across batch
print("Friction stats (all patches):")
print(f" mean: {[f'{v:.2f}' for v in packet.friction.mean(0).tolist()]}")
print(f" std: {[f'{v:.2f}' for v in packet.friction.std(0).tolist()]}")
print(f" min: {[f'{v:.2f}' for v in packet.friction.min(0).values.tolist()]}")
print(f" max: {[f'{v:.2f}' for v in packet.friction.max(0).values.tolist()]}")
print()
# Parity check
print(f"Parity with FLEigh: {verify_parity(A)}")
print("=" * 60)