Skip to main content

Pale Ale Core (Rust): deterministic Spin(3) rotor distance kernels

Reason this release was yanked:

Update and rename

Project description

pale-ale-core

Geometric auditing engine for LLM embeddings using E8 lattices and geometric algebra. This crate provides deterministic, structure-aware distance metrics that complement cosine similarity.

Overview

pale-ale-core computes a structural distance between embedding vectors by:

  • Decomposing vectors into 8D blocks
  • Snapping blocks to the 240 roots of the E8 lattice
  • Comparing rotors/bivectors to measure flow and consistency

The result is a stable, deterministic signal designed for auditing and analysis.

Unlike cosine similarity (angle-only), this metric detects block-wise structural drift and flow/topology breaks that can be invisible in high-dimensional angle metrics.

Features

  • Deterministic E8-based structural distance
  • Zero-copy Numpy integration for contiguous arrays
  • Zero-alloc hot path for k=1..3 and stack-only dyn path
  • NaN/Inf rejection for inputs and parameters
  • Optional inspect feature for detailed diagnostics

Installation

Python

Use the wrapper package:

pip install pale-ale

pale-ale is the higher-level wrapper/CLI; pale-ale-core provides the Rust engine and Python bindings.

Core-only (no CLI):

pip install pale-ale-core

Rust

[dependencies]
pale-ale-core = "1.0.0"

Usage (Python)

Directly using the core bindings. Note that spin3_struct_distance is the primary metric for structural auditing.

import numpy as np
import pale_ale_core

# Must be float64, length % 8 == 0
# Use ascontiguousarray to ensure zero-copy passing to Rust
u = np.ascontiguousarray(np.random.rand(1536), dtype=np.float64)
v = np.ascontiguousarray(u + 0.1, dtype=np.float64)

# 1. Structural-only distance (0.0 .. 1.0) -> Recommended for auditing
d_struct = pale_ale_core.spin3_struct_distance(u, v)

# 2. Mixed distance (Semantic + Structural)
# alpha is a linear mixing weight: (1-alpha)*semantic + alpha*structural
d_mix = pale_ale_core.spin3_distance(u, v, alpha=0.15)

# 3. Detailed Breakdown
components = pale_ale_core.spin3_components(u, v)

print(f"Structural Dist: {d_struct:.6f}")
print(f"Intra-Block:     {components['intra']:.6f}")
print(f"Topology (HCT):  {components['hct']:.6f}")

Python API Reference

Function Description
spin3_struct_distance(u, v) Pure structural distance. 0 = identity, 1 = maximally different under this metric.
spin3_distance(u, v, alpha) Mixed distance. Blends a cosine-like semantic distance (normalized dot) with structural distance.
spin3_components(u, v) Returns a dictionary of detailed metrics (intra, inter, hct, anchors).

Usage (Rust)

use pale_ale_core::{spin3_components, spin3_struct_distance};

fn main() {
    let u: Vec<f64> = vec![0.1; 8];
    let v: Vec<f64> = vec![0.2; 8];

    let d = spin3_struct_distance(&u, &v).unwrap();
    let components = spin3_components(&u, &v).unwrap();

    println!("d_struct = {:.6}", d);
    println!("d_intra  = {:.6}", components.d_intra);
}

Constraints

  • Vector length must be a multiple of 8
  • Inputs must be float64 / f64
  • Inputs must be finite (NaN/Inf are rejected)
  • alpha must be finite

MSRV

  • Rust 1.65+

Note on Numpy Contiguity

When using the Python bindings, contiguous Numpy arrays are borrowed zero-copy. Non-contiguous arrays (e.g., slices like arr[::2]) will fall back to an owned copy internally to ensure safety.

Roadmap & Licensing Note

The project is preparing a Technical Whitepaper detailing the geometric properties of E8 lattices for AI auditing.

The current release is licensed under MPL-2.0 to preserve research integrity during the initial phase. The project is considering a future dual license (MIT / Apache-2.0) after the whitepaper publication to encourage wider adoption. No decision has been made yet.

License

Licensed under the Mozilla Public License 2.0. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pale_ale_core-1.0.0.tar.gz (20.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pale_ale_core-1.0.0-cp310-abi3-win_amd64.whl (114.9 kB view details)

Uploaded CPython 3.10+Windows x86-64

pale_ale_core-1.0.0-cp310-abi3-manylinux_2_24_x86_64.whl (229.8 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.24+ x86-64

pale_ale_core-1.0.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (413.0 kB view details)

Uploaded CPython 3.10+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file pale_ale_core-1.0.0.tar.gz.

File metadata

  • Download URL: pale_ale_core-1.0.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pale_ale_core-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3dd1641921d3b49fe2b8fae4005edf1262266c139e84a39388889bc4d26593ae
MD5 085652895184afbcb76da5bdfa755caa
BLAKE2b-256 b20487d7eff441f254f575b447f5433f9e0ae3673fd0e9db40464cdb657d4074

See more details on using hashes here.

File details

Details for the file pale_ale_core-1.0.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pale_ale_core-1.0.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 42816f50f8599ff20486c0eb33317df82e93af900250a5610303b86618d06e7c
MD5 01074e5f9fe3cbbac20e533524d22f01
BLAKE2b-256 875d104132f72324e103ce2f24fe2e3fdaccdccf9771cc394d8bb908907d33fc

See more details on using hashes here.

File details

Details for the file pale_ale_core-1.0.0-cp310-abi3-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for pale_ale_core-1.0.0-cp310-abi3-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 16d40ae441811b2cb051635ac2395a2ca28e2703bc3a3a909325902684d51cc8
MD5 79d42c0adc95eda50fef359dfd04e422
BLAKE2b-256 ed29d6031bfce8d9a0cef59651d4759ef1a327c5e18da3de75597a772ad8b62a

See more details on using hashes here.

File details

Details for the file pale_ale_core-1.0.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for pale_ale_core-1.0.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 e84a81426dedefe188d1aca5760ddf84effd7812cedc3c0cb03bbc4be1488cd9
MD5 221f20557f8203ad6992315d50362307
BLAKE2b-256 202e27fc54be05850e8e335e744e3d4686c2435e61f8073e8789632e1990e636

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page