Skip to main content

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 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. The Hermitian lane is the default production path. The non-Hermitian lane is now coverage-gated for the theory stands listed in THEORY_COVERAGE.md: biorthogonal W, Hessian/proxy diagnostics, projector branch tracking, EP/Puiseux/Jordan helpers, and conditioned continuation.

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/SciPy sft.OperatorFamily.
  • integration: cross-layer Omega/commonOperators and SFT x Omega gates.
  • realdata: tiny deterministic fixtures for sequence, grid, graph, tokens, and explicit operator lifts.
  • slow and cuda: 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 grouped theory coverage validation:

python3 -m sft_torch.validate --out-dir .benchmarks/validation

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
python3 -m sft_torch.bench nonhermitian --n 6 --k 3 --batch 4 --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.md records the 0.1.0 scope and validation commands.
  • THEORY_COVERAGE.md maps theory/commonOperators stands to package coverage.
  • NONHERMITIAN_ROADMAP.md tracks the remaining future biorthogonal / EP work.
  • PUBLISHING.md records the PyPI build, upload, and install verification flow.

Known Gaps

  • CUDA tests are skip-if-no-CUDA in this workspace.
  • Multi-slice grid[B,H,W] batching is explicit via batch_mode="first", "mean", or "block"; richer temporal/video operators remain future work.
  • Directed graph Laplacian is implemented as an explicit non-Hermitian out-degree lift. Normalized graph Laplacian is implemented for undirected graphs.
  • The tail layer exposes strict Omega mode for k | N; convenience mode is explicit and should not be used as a proof gate.
  • Pseudospectrum and numerical-range dashboards are optional diagnostics and are intentionally kept out of hot paths.
  • Fully automatic global EP-safe inverse workflows remain roadmap work; local Puiseux/Jordan chart helpers are coverage-gated.

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

sftransform-0.2.0.tar.gz (57.4 kB view details)

Uploaded Source

Built Distribution

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

sftransform-0.2.0-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

Details for the file sftransform-0.2.0.tar.gz.

File metadata

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

File hashes

Hashes for sftransform-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7c633e9c2f2d3100dac3308adc6fdc1d6ae61ed1b730741fc94ceb77c330800c
MD5 9cf31edc6a8d5f14e9b47a4143ad6b31
BLAKE2b-256 0349731fd75042c45a6b7c73008d57bfe18d2709c8dc105d2ea53b139d4498f1

See more details on using hashes here.

File details

Details for the file sftransform-0.2.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for sftransform-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f92fbbc4b4878e509eb0afca0657fe476fad18bdf094d0eb0f254d5f862d0f84
MD5 3ea33190d5c78ea635d75f8aaba364f1
BLAKE2b-256 c1cdb218d68955732715c1f6d119944f2a9e1bcde82e91ba8008f89e134b1f92

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