Torch-native Spectral Flow Transform for data-to-operator spectral programming
Project description
SFT-Torch
SFT-Torch is a Torch-native, data-agnostic compiler from structured data to Hermitian / real-symmetric spectral operator programs.
DataView -> Lift -> OperatorSpec -> SpectralProgram -> W / kappa / tail / codec
The core does not know about domains such as audio, images, astronomy, or text. It knows data topology and operator lifts:
sequence(x).fourier_bands(...)grid(x).laplacian(...)graph(edge_index, n).laplacian(...)tokens(...).transition(...)operator(A0, basis)
Example:
import sft_torch as sft
program = sft.grid(blocks).laplacian(weight=0.3).compile("cuda")
kappa = program.kappa()
tail = program.tail()
This package is intentionally separate from sft while it is being developed.
Version 0.1.0 is scoped to the Hermitian Torch lane: torch.linalg.eigh,
orthonormal eigenvectors, Hellmann-Feynman W, and Omega tail diagnostics.
It is not a full Torch port of sft 0.3 and does not yet implement
the full non-Hermitian/EP production stack. Experimental support now includes
biorthogonal W, small EP/Puiseux helpers, branch tracking utilities, and
conditioned-continuation diagnostics; these APIs are guarded by tests but should
still be treated as early theory-epic functionality.
Install
From a local checkout:
python3 -m pip install -e ".[dev,parity]"
For a wheel/sdist release, the PyPI package name is sftransform and the
Python import name is sft_torch:
python3 -m pip install sftransform
Build and install a local release artifact:
python3 -m pip install build
python3 -m build
python3 -m pip install dist/*.whl
python3 -c "import sft_torch; print(sft_torch.__version__)"
Install directly from the repository:
python3 -m pip install "git+ssh://git@github.com/dimaq12/spectral-flow-torch.git"
Quickstart
import torch
import sft_torch as sft
x = torch.sin(torch.linspace(0, 8, 256, dtype=torch.float64))
program = sft.sequence(x).fourier_bands(n_bands=16).compile("cpu")
W = program.W
predicted = program.predict(torch.zeros(program.M, dtype=program.dtype))
tail = program.tail(strict=False)
Production Readiness
The current Hermitian layer is a production candidate, not just a smoke demo. The test suite is split by intent:
unit: fast deterministic contracts and guardrails.parity: numeric parity against the NumPy/SciPysft.OperatorFamily.integration: cross-layer Omega/commonOperators and SFT x Omega gates.realdata: tiny deterministic fixtures forsequence,grid,graph,tokens, and explicitoperatorlifts.slowandcuda: optional paths for profiler/GPU validation.
Run the default CPU suite:
python3 -m pytest
Run targeted production groups:
python3 -m pytest -m parity
python3 -m pytest -m integration
python3 -m pytest -m realdata
python3 -m pytest -m "not slow and not cuda"
Run CUDA/profiler checks when a CUDA build is available:
python3 -m pytest -m cuda
Benchmarks
sft_torch.bench reports machine-readable metrics for CPU/CUDA runs:
python3 -m sft_torch.bench core --json
python3 -m sft_torch.bench graph --n 1000 --k 64 --device cuda --json
python3 -m sft_torch.bench grid --n 32 --batch 2048 --device cuda --json
python3 -m sft_torch.bench tail --n 7680 --json
The installed console command is also available as:
sftransform-bench core --json
Each result includes time_ms, device, dtype, batch, N, M,
eigh_count, svd_count, basis_kind, materialized_elements,
peak_memory, throughput, accuracy where applicable, and the selected
execution plan.
Store benchmark output outside source-controlled files:
python3 -m sft_torch.bench core --json --output .benchmarks/core.json
Release Docs
RELEASE_NOTES.mdrecords the0.1.0scope and validation commands.NONHERMITIAN_ROADMAP.mdtracks the separate future biorthogonal / EP work.PUBLISHING.mdrecords the PyPI build, upload, and install verification flow.
Known Gaps
- CUDA tests are skip-if-no-CUDA in this workspace.
- Full multi-slice
grid[B,H,W]batching is still a v1 limitation; the first slice is used by the current lift. - Directed and normalized graph Laplacians intentionally raise
NotImplementedErroruntil their semantics are fixed. - The
taillayer exposes strict Omega mode fork | N; convenience mode is explicit and should not be used as a proof gate. - Non-Hermitian support is experimental: left/right eigenvectors,
biorthogonal
W, EP2 topology, Puiseux inverse, and conditioned diagnostics exist, but full production branch tracking, Jordan fusion, and EP-safe inverse workflows remainv0.2+roadmap items.
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 Distribution
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 sftransform-0.1.0.tar.gz.
File metadata
- Download URL: sftransform-0.1.0.tar.gz
- Upload date:
- Size: 46.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
590e5cd4411adb0f80ca2b2ec45a749b15e716e79ecbb9165e2d3f900f109972
|
|
| MD5 |
a51e6a2f50d206f888b0f2ad60770d2e
|
|
| BLAKE2b-256 |
0353e0cac3dc966bf406658805b70f8f3e221fe6793e11480105330c7426d29f
|
File details
Details for the file sftransform-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sftransform-0.1.0-py3-none-any.whl
- Upload date:
- Size: 33.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14cf961007ef4e925100b2f22166a7ca77ae3a831aa7bac761f44ac30825506b
|
|
| MD5 |
e53579efe10e246fcdf54cc7913c376e
|
|
| BLAKE2b-256 |
fd1389a6741a72ae71a6a0949bf9d24d19c2da45c2ecc6d3007f861f191f4f73
|