Published September 21, 2025 | Version v0.1.0
Software Open

aaronstevenwhite/spectrans: Spectrans v0.1.0

Authors/Creators

  • 1. University of Rochester

Description

Spectrans v0.1.0

This is the first public release of Spectrans, a modular library for spectral transformer implementations in PyTorch. This library provides alternatives to traditional attention mechanisms using spectral transforms.

๐ŸŽฏ Key Features

Core Implementations

  • Fourier Neural Operator (FNO): Operator learning in Fourier space
  • FNet: Pure Fourier transform-based token mixing
  • Global Filter Network (GFNet): Learnable filters in frequency domain
  • Adaptive Fourier Neural Operator (AFNO): Adaptive frequency filtering
  • Wavelet Transformers: Multi-resolution analysis with wavelets
  • Linear Spectral Transform (LST): Linear complexity attention alternative
  • Spectral Cross-Attention: Efficient cross-attention in spectral domain

Transform Support

  • Fast Fourier Transform (FFT): 1D and 2D implementations
  • Discrete Cosine Transform (DCT)
  • Discrete Sine Transform (DST)
  • Discrete Wavelet Transform (DWT): 1D and 2D with multiple wavelet families
  • Hadamard Transform
  • Short-Time Fourier Transform (STFT)

Features

  • ๐Ÿ”ง Modular Architecture: Mix and match components with registry system
  • ๐Ÿ“ Mathematical Rigor: Proper complex number handling and gradient flow
  • โšก Linearithmic Complexity: O(n log n) alternatives to O(nยฒ) attention
  • ๐ŸŽ›๏ธ Configuration System: YAML-based configuration for experiments
  • ๐Ÿงช Comprehensive Testing: Full test coverage with gradient checks
  • ๐Ÿ“š Documentation: Detailed API docs and examples

๐Ÿ“‹ Requirements

  • Python โ‰ฅ 3.13
  • PyTorch โ‰ฅ 2.5.0
  • NumPy โ‰ฅ 2.0.0
  • See pyproject.toml for complete dependencies

๐Ÿš€ Installation

pip install spectrans

๐Ÿ’ป Quick Start

import torch
from spectrans.models import FNet

# Create an FNet model
model = FNet(
    vocab_size=30000,
    hidden_dim=768,
    num_layers=12,
    max_sequence_length=512,
    num_classes=2
)

# Or use specific components directly
from spectrans.layers.mixing import FourierMixing
mixing_layer = FourierMixing(hidden_dim=768)

# Forward pass
input_ids = torch.randint(0, 30000, (2, 128))
output = model(input_ids=input_ids)

## ๐Ÿ“– Documentation

Comprehensive documentation is available on [read the docs](https://spectrans.readthedocs.io).

## ๐Ÿค Contributing

We welcome contributions! Please see our [Contributing Guide](https://github.com/aaronstevenwhite/spectrans/blob/main/CONTRIBUTING.md) for details.

## ๐Ÿ“„ License

MIT License. See [LICENSE](https://github.com/aaronstevenwhite/spectrans/blob/main/LICENSE) file for details.

Files

aaronstevenwhite/spectrans-v0.1.0.zip

Files (363.2 kB)

Name Size Download all
md5:32f743796ed932c4e4c619b30fa6e7d8
363.2 kB Preview Download

Additional details

Related works