Mathematically rigorous ML model diagnostics: stationarity verdict, effective dimension, barrier certificate
Project description
spectraldiag
Mathematically rigorous ML model diagnostics.
Answers not "what happened" (that's W&B) but "why it happened and what to do" — with mathematical proof, not empirical guessing.
pip install spectraldiag
Three core functions
stationarity_verdict(ntk_eigs, target_coeffs)
Is your model's feature learning done, or still evolving?
from spectraldiag import stationarity_verdict
result = stationarity_verdict(ntk_eigs, target_coeffs)
print(result.reason)
# STATIONARY. Source exponent r_hat=0.491 (±0.031) is consistent with r=0.5
# (self-organised criticality). Model is pinned to the Sobolev minimax barrier
# β₀=0.556. Additional data will improve loss at rate D^{-0.556} — no more
# than 44% further gain possible without compositional restructuring.
What it computes: fits the source exponent r from the empirical NTK spectrum. r ≈ 0.5 means your model has self-organised to the critical attractor — it's stationary, permanently bounded by β₀ = 2s/(2s+d*).
effective_dimension(laplacian_eigs, approx_errors, model_sizes)
Does your data have compositional structure your model could exploit?
from spectraldiag import effective_dimension
result = effective_dimension(laplacian_eigs, approx_errors, model_sizes)
print(result.verdict)
# COMPOSITIONAL STRUCTURE DETECTED. Data intrinsic dimension d*=8.2 but
# effective task dimension d_loc=2.1. Compositional approximation exponent
# α=1.19 vs Sobolev baseline α=0.30 — 3.9× compression gain available.
What it computes: estimates d* from the graph-Laplacian spectrum of your data, d_loc from the model-side approximation exponent. If d_loc < d*, genuine compositional structure exists — and the phase transition theorem says emergence is real.
barrier_certificate(d_star, d_loc, s, current_loss, current_N, current_D)
Where is your model relative to the theoretical ceiling?
from spectraldiag import barrier_certificate
result = barrier_certificate(
d_star=8.0, d_loc=2.0, s=1.25,
current_loss=0.42, current_N=1e8, current_D=1e11
)
print(result.verdict)
# BARRIER CERTIFICATE. Theoretical ceiling β₀=0.238. With compositional
# structure (d_loc=2.0), barrier rises to β'=0.556 — 2.3× faster data
# scaling. Training budget D=1e11 has NOT passed the crossover D_cross≈...
One-line integration
from spectraldiag.callbacks import make_hf_callback
trainer = Trainer(
...,
callbacks=[make_hf_callback(eval_data=(X_val, y_val))]
)
Works with HuggingFace Trainer and PyTorch Lightning out of the box.
Graph-Laplacian protocol (for real data)
from spectraldiag.graph_lap import graph_laplacian_eigs, estimate_d_star, double_dimension_consistency
eig_vals, eig_vecs = graph_laplacian_eigs(X_data, knn=10)
d_star = estimate_d_star(eig_vals)
consistency = double_dimension_consistency(d_star_data=d_star, d_loc_model=d_loc_from_model)
print(consistency["verdict"])
Mathematical foundation
This library implements the three-paper programme:
- TR — Boundaries of Stationary Feature Learning: the Sobolev minimax barrier
β₀, self-organised criticalityr=½, approximation exponentα=2s/d* - AB — Foundations of a Theory of Composable Abstractions: defect as projection, effective dimension
d_loc, subspace gap as the order parameter - BM — Spectral Scaling Benchmark: the decisive-test protocol, source exponent measurement, graph-Laplacian intrinsic dimension estimation
The decisive invariant: d_loc < d* ⟺ emergence is real ⟺ the phase transition theorem applies.
Build from source
pip install -e ".[all]"
Requires only a C++17 compiler. The C++ core is a standard CPython extension built automatically by setuptools — no CMake, no pybind11, no extra build dependencies.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spectraldiag-0.1.0.tar.gz.
File metadata
- Download URL: spectraldiag-0.1.0.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98b76659baae4fe2ad667c8f896c3327db99585e052ce2ad9d96d69e3d1552a5
|
|
| MD5 |
cac98c62b687ee66ad3c1a630f3ee97d
|
|
| BLAKE2b-256 |
15dc51fd552262c6310fae9dc901dffd6ff3305212fda8fa1fe4418f09e7c05d
|
File details
Details for the file spectraldiag-0.1.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 38.3 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd4cdada0c10e5413a6909178f8d9c276aaa0e51d7c26cc665e6f38a287833a6
|
|
| MD5 |
3592328d91b8b4e040688389d70a4fb6
|
|
| BLAKE2b-256 |
f3ae170cff3c9ef9171a3ce51c6c77afe4c26c9a19be67c153206ff3b346bbd5
|
File details
Details for the file spectraldiag-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 209.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6a13959ba2dd20c16ff8a517935dd4188e32d05c4e9c9b954519a5ba1df87f6
|
|
| MD5 |
a0065f08893be178196d586c60b81a3c
|
|
| BLAKE2b-256 |
154ce840a2a166e012451402be6eef0651f74a3cfb14cd4ffc41c8876b2bfed8
|
File details
Details for the file spectraldiag-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 32.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d435c75bc9c9f8563b9a02e9fc29fceee11797d95364bee12277be14528dec6
|
|
| MD5 |
cfefbc1dcff5d36c7ac979681206647e
|
|
| BLAKE2b-256 |
408cea4e3cd08c2e45961ff257c956366204793e7bb1600069f3feb32461b7a5
|
File details
Details for the file spectraldiag-0.1.0-cp312-cp312-macosx_10_9_x86_64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 33.0 kB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a423d9c0243ea2d06bba108a5ff762d26c1e3e3e2ff669183ee2ea01882a475
|
|
| MD5 |
70fdca7038a6d07e56012aca49a4677c
|
|
| BLAKE2b-256 |
696ba86fe0e9df7a135b8eb9c32b08e7b56552fdec7c3f67138e05d0ba23cb07
|
File details
Details for the file spectraldiag-0.1.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 38.3 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ae0b32e4f03e58f7ee7faba2d4bc6e94ea638547cac5f04b368268f386a11fd
|
|
| MD5 |
98170e6cd472fac3980f9448e4bd8c9d
|
|
| BLAKE2b-256 |
39c5869af2fea3eed29eb6149e0e70298ccc1b95966f9ed63c8edb24f9965d9c
|
File details
Details for the file spectraldiag-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 208.7 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c415a80a6e629684de29ce954d35c2f8da3c10e94f217ecd681a0eaa49e60f20
|
|
| MD5 |
28eed950c8db2914cea2d22f78fc780f
|
|
| BLAKE2b-256 |
06e9aed1dca38181629a974827ad4615db6b9070c3168ea1846ea3096750d50f
|
File details
Details for the file spectraldiag-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 32.9 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eb41af05b585d5fe494fab68ca7df96a4525a0133e23eba0ca3efef443709da
|
|
| MD5 |
5f9294e0f043685b6daab20ee36970b8
|
|
| BLAKE2b-256 |
64bd84b627e89c426447f3da36a8b9c5c0a3fd62f0cf3de6548a2fa9f9b1d6c6
|
File details
Details for the file spectraldiag-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 33.0 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
268204fdf395972d3f4a97f352cbdda169b3fd45134aeb23caef5646cd9e401e
|
|
| MD5 |
c37bc63edb22f5f088b01e94c7a8a7eb
|
|
| BLAKE2b-256 |
24bf1d8540261650d1cb41a24200f080d174125d6a68d77fe9a717db174e2b5a
|
File details
Details for the file spectraldiag-0.1.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 38.3 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c7944301b05b3982f9630387d769a15b5d065dbdd0f0311fab824439d4417f4
|
|
| MD5 |
70ef63de682e978f1a5b4219818f67e5
|
|
| BLAKE2b-256 |
aeea5e3db785b93c8a688b3f7ef1c7a3d151beff3d8cf3f2f66a3bf42aa132e7
|
File details
Details for the file spectraldiag-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 208.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be9ef2228f9e4959d97288494944eac0f442de049381033589e0df4b70a4fcbb
|
|
| MD5 |
e7e5139bdda1f0a418c7f02907d7d3b4
|
|
| BLAKE2b-256 |
363a23f2f9e33d157690d37259b41e508e9fec1165cd00d8c0c1f045c97ccdc3
|
File details
Details for the file spectraldiag-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 32.9 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a4110c2903ae80a9ae877e89006e9f7c84c52a5aa4ea79560eb58559cdd4ece
|
|
| MD5 |
77226783307902abd19097568d9d4f1b
|
|
| BLAKE2b-256 |
2efd85f3e9b348e37c0d77766b5ca1c6651a813e3cd5125bd1e3c5297d4c2a3f
|
File details
Details for the file spectraldiag-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 33.0 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af3b7d16afc97d4bb94b7daeee91968e59ede6ad9b60008045b6382e2e732b1e
|
|
| MD5 |
c605dc846260dd480575d26928f2b670
|
|
| BLAKE2b-256 |
1355cadfd104a6682013beb7eaceaed22fe42c6c72ce91996b3bb74359ea3d7b
|
File details
Details for the file spectraldiag-0.1.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 38.3 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef783f47b8909e47ebe993ab80769d3a1f9175f38b12d04940b7cfc61c3880a5
|
|
| MD5 |
78cca424b4806f4695e4d39594da50bf
|
|
| BLAKE2b-256 |
6de54d50458f958058efe4fbe89ec6c87b760150db31dee0ee848a2a3a56c0a9
|
File details
Details for the file spectraldiag-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 208.0 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e69315819c3f4be9825849119ff22eb48318a4e9a9edd2bbecfdc2b0c37aa766
|
|
| MD5 |
05c74c3d48afd63922744c7ce77be067
|
|
| BLAKE2b-256 |
8a4757aea12212914cbaf083630e027376f5edfb2c04e1882b61510806722eb2
|
File details
Details for the file spectraldiag-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 32.9 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f777b183269be0d906be48e1e4a4252cf6712326d780f8327268e877ea42b3a
|
|
| MD5 |
4776833c2145c51b2062c64aaf73b79c
|
|
| BLAKE2b-256 |
4a333791de2e66a2a567df0a6e51ed3a4f44f21b8a8ea877f35729201809ae5b
|
File details
Details for the file spectraldiag-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl.
File metadata
- Download URL: spectraldiag-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 33.0 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa59ef9482edc7fa8a824332a284e8d9edcfac2de5aac2a1869cb246f738c733
|
|
| MD5 |
f6d6c7f3a192e1db51f40938d2216b65
|
|
| BLAKE2b-256 |
694918dd501fb1a92835fae6e01958106880a0531f053aabfd6a3a687055c3b9
|