Skip to main content

Compressed neural network layers — Eisenstein lattice splines and low-rank factorization

Project description

tensor-spline

Compressed neural network layers — Eisenstein lattice splines and low-rank factorization.

What's Novel

SplineLinear: Weights parameterized by control points on an Eisenstein (hexagonal) lattice, interpolated to create the full weight matrix. Built-in compression, regularization, and constraint-native structure.

Key result: drift-detect task hits 100% accuracy at 20× compression with SplineLinear.

Install

pip install tensor-spline

Requires PyTorch ≥ 2.0.

Quick Start

import torch.nn as nn
from tensor_spline import SplineLinear, inject_spline, LowRankLinear, recommend_variant

# Option 1: Direct construction
layer = SplineLinear(512, 512, n_control_points=16)
# 262,144 params → 16 params (16,384:1 compression)

# Option 2: Inject into any model
model = nn.Sequential(nn.Linear(256, 128), nn.ReLU(), nn.Linear(128, 10))
inject_spline(model, n_control_points=16)

# Option 3: Low-rank for sharp classification tasks
layer = LowRankLinear(256, 128, rank=16)
# 32,768 params → 6,144 params (5.3× compression, 80% accuracy retention)

# Auto-select the right compression for your task
variant = recommend_variant("detect drift in sensor data")  # → "spline"
variant = recommend_variant("classify documents by topic")   # → "lowrank"

Compression Strategies

Method Best For Compression Accuracy
SplineLinear Smooth/continuous tasks 20-40× 95-100% retention
LowRankLinear Classification, sharp boundaries 5-16× 80% retention
HierarchicalSpline Multi-scale continuous 10-20× Experimental

Honest Findings

SplineLinear achieves 100% accuracy at 20× compression on drift-detect (smooth task). But only 31% on topic-classify (sharp boundaries) — IDW interpolation is too smooth for classification. Use LowRankLinear for classification tasks instead.

Use the right tool for the right task.

3 Basis Functions (SplineLinear)

  • eisenstein — Inverse distance weighting (default, best for smooth)
  • gaussian — Gaussian RBF
  • bspline — Cubic B-spline kernel

Related

  • plato-training — Micro model training (primary consumer of SplineLinear)
  • eisenstein-embed — 5-layer semantic matching cascade (uses SplineLinear for 20× embedding quantization)
  • eisenstein — Eisenstein integer arithmetic (mathematical foundation)
  • plato-types — Tile lifecycle and provenance
  • ASSEMBLY-GUIDE — Full ecosystem assembly guide

Mesh Protocol

tensor-spline supports the SuperInstance mesh protocol. When co-installed with plato-core, compression capabilities auto-register with the shared registry.

pip install tensor-spline[mesh]

This enables:

  • spline-linear and low-rank compressors discoverable via the mesh registry
  • inject, measure, and recommend utilities available to other mesh services
  • Entry-point based plugin loading (superinstance.plugins)

Works standalone without plato-core — graceful degradation via try/except.

License

MIT

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

tensor_spline-1.0.0.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

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

tensor_spline-1.0.0-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tensor_spline-1.0.0.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for tensor_spline-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0d7d2973b935abb03d189c861742319bb624f72f314c412c9804b894d5828e78
MD5 11a84a91589fdf194bd89da0ffdf4812
BLAKE2b-256 5f2d39791541dac279913d7322cdf62b64596e80e6e40f3695587f49195a93b9

See more details on using hashes here.

File details

Details for the file tensor_spline-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tensor_spline-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for tensor_spline-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a8d2bcbdf87491355ee5a91c7998179caf08ce42778333d94f5503062d781d6
MD5 158c5258edaab1ee176cb430fc534b1c
BLAKE2b-256 f9977e721f88e613953d512016168cb9b8f467c7aa058692bec9beda1f458cc6

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