eml-cost-torch
In-development PyTorch diagnostics: per-layer Pfaffian profile of a
torch.nn.Module, EML-graph curvature helpers, differential-Galois bounds,
and Schwarz 2F1 detection.
Status
In development. The package reports diagnostics and empirical summaries; it does not claim formal verification of a model.
Install
Base install is lightweight and does not install PyTorch:
pip install eml-cost-torch
Install the PyTorch-backed APIs with:
pip install 'eml-cost-torch[torch]'
Quick start
import torch.nn as nn
from eml_cost_torch import profile
model = nn.Sequential(
nn.Linear(128, 64),
nn.ReLU(),
nn.Linear(64, 32),
nn.GELU(),
nn.Linear(32, 10),
)
p = profile(model)
print(p.total_layers) # 5
print(p.total_pfaffian_depth) # 0 — all r=0 (ReLU=0, GELU=non-EML, Linear=0)
print(p.transcendental_layer_count) # 0
print(p.non_eml_layer_count) # 1 — GELU uses erf
print(p.estimated_pfaffian_width) # 0 — no softmax/attention
for layer in p.layers:
print(f" {layer.name:8s} {layer.activation:30s} r={layer.pfaffian_r}")
What it does
Walks the module graph statically (does NOT execute the model), classifies each layer against an internal registry of activation/operator types, and returns a structured profile.
Registry covers ~50 standard torch.nn modules:
- Linear / Conv / Norm:
r=0(polynomial) - ReLU family / Hard sigmoid / Hard swish:
r=0 - Sigmoid, Tanh, Softplus, ELU, SiLU/Swish:
r=1 - Mish:
r=3 - GELU: flagged
is_pfaffian_not_eml=True(uses erf, outside EML class) - Softmax / MultiheadAttention: contributes to
estimated_pfaffian_width
Why this matters for architecture search
Across the internal test set, NN training cost appeared to correlate with Pfaffian width. This profile gives a static diagnostic input you can use as a search heuristic before training.
Library API
from eml_cost_torch import profile, ModelProfile, LayerProfile
p: ModelProfile = profile(model)
# Aggregate fields
p.layers # list[LayerProfile]
p.total_layers # int
p.total_pfaffian_depth # sum of r over all layers
p.total_eml_depth # sum of depth
p.transcendental_layer_count # count of layers with r >= 1
p.non_eml_layer_count # count of layers using non-EML primitives (e.g., GELU)
p.estimated_pfaffian_width # parallel-chain count (softmax + attention)
p.total_params # parameter count
# Per-layer fields
layer.name # named_modules path
layer.cls_name # Python class name
layer.activation # friendly description
layer.pfaffian_r # chain order
layer.eml_depth # routing depth
layer.is_pfaffian_not_eml # True for GELU and similar
layer.n_params # parameters at this layer
Curvature diagnostic (eml-graph)
Closed-form Gaussian + mean curvature of the eml surface
z = exp(x) - ln(y + 1). Use it as a diagnostic on training inputs
or intermediate activations to see where in input space the eml
geometry is steeply curved — typically a fingerprint of regions
where finite-precision evaluation drift is largest.
import torch
from eml_cost_torch import gaussian_K, mean_H, curvature_summary
x = torch.randn(1000) * 0.5
y = torch.randn(1000) * 0.5 + 1.0 # keep y > -1 to stay off the branch cut
s = curvature_summary(x, y)
s.K_min, s.K_max # range of Gaussian curvature
s.K_log10_dynamic_range # orders of magnitude spanned
s.K_median, s.K_mean # central tendency
s.H_min, s.H_max, s.H_median # mean curvature stats
s.n_finite, s.n_nonfinite # samples that landed on y = -1 etc.
gaussian_K and mean_H are autograd-friendly torch ops; they
preserve the input tensor's dtype and device. Both K and H are
real-valued; inputs with y == -1 produce non-finite outputs (the
ln branch point) and are filtered out by curvature_summary.
Closed forms and the supporting derivation live in
monogate-research/exploration/C247_omega_differential_geometry/.
This is intentionally a diagnostic only, not a learning-rate
scheduler — the C-247b prototype showed that Adam absorbs the same
signal through its second-moment estimate, so explicit curvature
scaling does not improve training.
License
Apache-2.0. See LICENSE.
Metadata
Release files for eml-cost-torch 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| eml_cost_torch-0.5.2.tar.gz | 30.1 kB | Without provenance | Details for eml_cost_torch-0.5.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| eml_cost_torch-0.5.2-py3-none-any.whl | Python 3 | none | any | Details for eml_cost_torch-0.5.2-py3-none-any.whl |
Total release size: 50.6 kB
Release files / eml_cost_torch-0.5.2.tar.gz
| Download URL | eml_cost_torch-0.5.2.tar.gz |
|---|---|
| Size | 30.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c6fe8c2b66038afee7740e448a83792ab14232e05fe289c29027f3250d3f813
|
|
BLAKE2b-256 checksum How to use checksums |
a112d07c10702f92dbf9412354164e58ee96114093d0bb7fb22f31b5cc172fc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / eml_cost_torch-0.5.2-py3-none-any.whl
| Download URL | eml_cost_torch-0.5.2-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d4f6a817512912aa5b9dde204da316600fe42f8abb261a17d36d7cb4f7f9d6b
|
|
BLAKE2b-256 checksum How to use checksums |
edeaa6d1c8943983893e66fb0a086fc6c99b29fecd0e0993cac1a879446f7c52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for eml-cost-torch 0.5.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.