trnfft¶
FFT and complex-valued tensor operations for AWS Trainium via NKI.
Trainium has no native complex number support and ships no FFT library. trnfft fills that gap with split real/imaginary representation, complex neural network layers, and NKI kernels optimized for the NeuronCore architecture.
Part of the trnsci scientific computing suite (github.com/trnsci).
Features¶
torch.fft-compatible API —fft,ifft,rfft,irfft,hfft,ihfft, the2/nvariants of each (fft2,ifftn,hfftn, ...),fftshift,ifftshift,fftfreq,rfftfreq,stft,istft. The transforms taketorch.fft'sn/s,dimandnormarguments with the same meaning.stft(window=None)uses a Hann window, wheretorch.stftuses ones; passwindowto match it.- ComplexTensor — split real/imaginary representation with full arithmetic
- Complex NN layers —
ComplexLinear,ComplexConv1d,ComplexBatchNorm1d,ComplexModReLU - NKI acceleration — DFT-GEMM, four-step and six-step FFTs, Stockham and butterfly stages, complex GEMM, ComplexLinear, and fused multiply kernels for Trainium. Validated on Trn2 (Neuron SDK 2.33, native TorchNeuron) and on trn1.2xlarge (XLA). See Benchmarks and the CHANGELOG.
- Plan-based caching — FFTW-style plan creation and reuse
trn-* suite¶
trnfft is one of six packages (plus an umbrella meta-package) in the trnsci scientific computing suite for AWS Trainium:
- trnblas — BLAS Level 1–3
- trnrand — Philox / Sobol RNG
- trnsolver — linear solvers, eigendecomposition
- trnsparse — sparse matrix ops
- trntensor — tensor contractions
- trnsci — umbrella meta-package
Quick example¶
import torch
import trnfft
signal = torch.randn(1024)
X = trnfft.fft(signal)
recovered = trnfft.ifft(X)
License¶
Apache 2.0 — Copyright 2026 Scott Friedman