1.3¶
Released 2026-11-22. A performance release. The PyTorch transform on a GPU is 18–75x faster than 1.2 for a single image (forward plus backward), up to ~500x faster for batches, and up to ~900x faster (nearly 1,000x forward) with CUDA graphs. Building a transform takes up to ~13x less time and uses up to 65% less memory on both backends. The NumPy transform is 1.5–2x faster without any extra library and up to 7.6x faster with SciPy installed.
The PyTorch UDCT is now an nn.Module, the monogenic transform is available in PyTorch, and there are four new gallery examples. For the mechanisms behind the speedups, with diagrams, see Curvelets 1.3 under the hood.
Speed¶
Each comparison is 1.2 against 1.3. The tables come from different benchmark runs on different machines; How these were measured lists the setups.
PyTorch on a GPU¶
RTX 4090, float32, real transform, wall time with a synchronization per call. Both versions ran on the same machine with torch 2.15.0 and the same script (benchmarks/stack_bench.py). Round trip is forward plus backward.
Case |
1.2 round trip |
1.3 round trip |
Speedup |
|---|---|---|---|
2D 512² |
17.9 ms |
0.98 ms |
18x |
2D 1024² |
78.6 ms |
1.75 ms |
45x |
2D 2048² |
170.8 ms |
2.82 ms |
61x |
3D 64³ |
143.1 ms |
1.93 ms |
74x |
3D 128³ |
141.0 ms |
2.09 ms |
67x |
For a batch of 8 images the forward transform is 117–494x faster. 1.2 has no batch dimension, so its time is a Python loop over the images; part of the gain is native batching.
Case (batch of 8, forward) |
1.2 (loop) |
1.3 |
Speedup |
|---|---|---|---|
2D 512² |
81.4 ms |
0.61 ms |
134x |
2D 1024² |
354 ms |
1.42 ms |
249x |
2D 2048² |
760 ms |
6.51 ms |
117x |
3D 64³ |
624 ms |
1.26 ms |
494x |
3D 128³ |
649 ms |
4.91 ms |
132x |
With UDCT(cuda_graphs=True), a single forward takes 0.072 ms at 512², 0.165 ms at 1024² and 0.098 ms at 3D 64³ (133x, 261x and 797x faster than 1.2), and a single-image round trip takes 0.14 ms at 512², 0.34 ms at 1024² and 0.19 ms at 3D 64³ (119x, 210x and 667x faster). For a batch of 8 with cuda_graphs=True, a round trip takes 0.52 ms at 512² (15,300 images/s, 250x) and 1.13 ms at 3D 64³ (7,060 images/s, 908x round trip; 0.58 ms or 974x forward). Graphs help launch-bound sizes (small and medium inputs, small batches); for large batches the plain path is as fast or faster.
Building a transform¶
UDCT(...) construction is dominated by window building. It is 3–13x faster in 1.3, and the NumPy windows are bit-identical to 1.2. Intel i7-8565U laptop (4 cores), fresh process per case, window code unchanged from 1.2 until these changes.
Backend |
Shape (scales, wedges per direction) |
1.2 |
1.3 |
|---|---|---|---|
NumPy |
2048² (5, 6) |
18.95 s |
1.50 s (12.7x) |
NumPy |
128³ (3, 3) |
5.52 s |
0.53 s (10.5x) |
NumPy |
1024² (4, 6) |
1.61 s |
0.38 s (4.3x) |
torch |
2048² (5, 6) |
21.92 s |
2.06 s (10.6x) |
torch |
128³ (3, 3) |
8.58 s |
0.82 s (10.4x) |
torch |
1024² (4, 6) |
1.93 s |
0.52 s (3.7x) |
Peak memory during construction at 1024² is 65% lower for NumPy and 40% lower for torch. A built transform can be reused: pickle (NumPy) or torch.save and torch.load (torch) restore it in 0.1–0.2 s, against about 2 s to build at 2048².
NumPy¶
32-vCPU AMD EPYC 9575F, float32, real transform, forward plus backward, best of several runs. “NumPy engine” is the code changes alone with no extra library; “SciPy” is the new default when SciPy is installed.
Case |
1.2 |
1.3, NumPy engine |
1.3, SciPy |
|---|---|---|---|
512² |
14.9 ms |
9 ms (1.6x) |
9 ms (1.7x) |
2048² |
355 ms |
199 ms (1.8x) |
164 ms (2.2x) |
128³ |
266 ms |
176 ms (1.5x) |
101 ms (2.6x) |
256³ |
4984 ms |
2355 ms (2.1x) |
659 ms (7.6x) |
Complex and monogenic 1024² transforms are 2.1–2.9x faster forward with a multithreaded FFT engine. The host was shared, so single numbers move by up to about 2x between runs; the trends are consistent.
What made it faster¶
Algorithms¶
Fused execution plan (torch). One plan replaces the loop over wedges, so the number of kernel launches no longer grows with the wedge count. (#84)
No host syncs or per-call casts on the hot path. (#83)
Device-specific folds: a cache-blocked scatter on CPUs and deterministic gather folds on GPUs. (#85)
Real-arithmetic gather folds that apply conjugates on the fly and trace into a single
torch.compilegraph. (#90)L2-aware batching: on accelerators, batches whose rows exceed the L2 cache run row by row, which cuts peak memory 2–4x. (#91)
Native batching:
forward,backward,vectandstructaccept leading batch dimensions, andUDCT.filter(x, fn)appliesfnto the flat coefficients between a forward and a backward transform. (#86)Sparse window construction with broadcasts, sparse flips and a thread pool. Torch uses the same builder as NumPy. (#103, #107, #114)
Faster NumPy folds with plain assignment where bins are distinct, cached real weights and one accumulator in the backward transform. (#97)
Technologies¶
CUDA graphs.
UDCT(..., cuda_graphs=True)records each flat forward and backward once and replays it, including under autograd. (#92)Fused Triton fold kernel. On CUDA the fold runs as one CSR kernel per direction with no atomics, 10–36% faster end to end. (#94, #125)
torch.compile support. the flat
forward(x, structured=False)andbackwardcompile withfullgraph=True. (#90, #111)Pluggable FFT engines for NumPy:
UDCT(..., fft_engine=None | "scipy" | "numpy" | "auto" | "fftw" | "mkl_fft", fft_workers=None). The default is SciPy when it is installed andnumpy.fftotherwise. AMD’s FFTW is detected at run time, and"auto"times the installed engines once per shape. New extras:curvelets[scipy],curvelets[fftw]andcurvelets[mkl]. See NumPy backend. (#97)Usable-CPU detection. Worker counts use the process’s CPU affinity rather than
os.cpu_count(), andfft_workersalso sets the number of window-building threads. (#97, #114)
New features¶
curvelets.torch.UDCTis annn.Modulewith adjoint gradients..to(),.cuda()and.double()work, and it can be a submodule.forward(x, structured=False)returns the flat coefficients andbackwardaccepts them, in both NumPy and PyTorch. (#104)UDCT.forward(x, structured=False)returns the flat coefficients thatvectwould produce, andUDCT.backwardaccepts either layout. This replaces the two-stepvect(forward(x))andbackward(struct(v)), in both NumPy and PyTorch, and PyTorch skips building the nested list.forward_vectandbackward_vectare deprecated aliases. (#132)The monogenic transform is available in PyTorch, matching
curvelets.numpy.UDCT, withUDCT.monogenic(), batching, CUDA graphs and gradients. (#111)UDCT(..., dtype=...)fixes the precision to float32 or float64 at construction, with newdtypeandcoefficient_dtypeproperties. (#87)Per-stage GPU profiling tools and a benchmark harness in
benchmarks/. (#81, #89)
New examples¶
Curvelet-Domain Hessian Action: an image-domain inverse Hessian filter in the curvelet domain. (#66)
Comparison of Transform Atoms: what a single coefficient looks like for the UDCT, the DWT, the DTCWT and the scattering transform, plus a speed comparison with other libraries in the FAQ. (#95)
Monogenic vs. Real Transform: amplitude and phase, regularity estimation and local orientation with monogenic and real curvelets. (#115)
plot_15_monogenic_fault_detection.py: synthetic faults and fault zones scored by ROC AUC, testing whether monogenic curvelets detect faults better. (#116)
Bug fixes¶
import curveletsfailed on Python 3.12 and later after a barepip install curveletsbecausetyping_extensionswas imported unconditionally. (#98)Window construction now warns when an axis length is not a multiple of
lcm(4, *decimation_ratios)—a tighter anti-aliasing and partition-of-unity condition than divisibility by the decimation ratios alone (Nguyen & Chauris 2010), without which periodized folding silently loses about1e-2in round-trip accuracy. (#124)Backpropagation through
UDCTModulefailed on CUDA because of a device mismatch instruct(), and.to()dropped the precomputed index maps so every later call recomputed them. (#82)A transform loaded onto another device (for example
torch.load(..., map_location="cpu")of a transform that had run on CUDA) failed with a Triton error. The plan is now rebuilt for the new device, and pickling andtorch.saveare tested for both backends. (#109)A real input to the complex PyTorch transform failed in the adjoint path. It now receives the real part, following PyTorch’s convention. (#104)
Empty batches no longer crash the row-by-row batch loop or fail in oneMKL FFT on CPU builds of PyTorch < 2.15. (#91, #133)
Doctest and docstring corrections in the monogenic transform. (#111)
2-D
UDCTwithwedges_per_direction >= 6reconstructed only to~5.6e-9instead of machine precision because the auto-selectedwindow_overlapexceeded the aliasing-free decimation bound \(\frac{8}{9}(1 + 2\alpha) \le 1 \iff \alpha \le 1/16\). Auto-selected overlaps are now capped at1/16(0.0625) in both NumPy and PyTorch, and explicit overlaps that produce non-injective folds emit a warning. (#123)high_frequency_mode="wavelet"was not an exact adjoint or Parseval tight frame in NumPy or PyTorch, causing dot-product tests and PyTorch autogradgradcheckto fail acrossreal,complex, andmonogenictransforms even though round-trip reconstruction succeeded. Symmetric wavelet-scale scaling is now used across both backends, sobackwardis the exact adjoint offorward. (#127)
Security hardening¶
The PyPI release workflow pins actions to commit SHAs, installs build tools from a hash-locked file, builds without isolation, checks that the built files match the release tag, attests SLSA build provenance and PyPI digital attestations, and keeps a read-only token for the build job. (#100, #133)
CODECOV_TOKENis no longer available to CI jobs that run third-party code. The test matrix only uploads coverage artifacts, and a separate job with no Python packages uploads them. Workflows use read-only permissions, pin every GitHub Action to a commit SHA (with a 30-day Dependabot cooldown) and do not persist credentials. (#99, #133)uvdependency resolution (used across CI, Format, Read the Docs and Nox via a pinnedastral-sh/setup-uvanduv pip install --torch-backend=cpu), the release build lock and all pre-commit hooks (frozen to commit SHAs) and theiradditional_dependenciesenforce a 30-day minimum release age (exclude-newer = "30 days") and exact version pins. (#133)
Upgrading from 1.2¶
Python 3.11 or newer is required. Python 3.9 and 3.10 are no longer supported, and 3.15 is added. (#72)
The PyTorch transform has a fixed precision.
UDCTis created withfloat32unlessdtypesays otherwise, and an input of another precision raises aTypeErrorthat names the fix. Passdtype=torch.float64or call.double()to transform float64 data. (#87)Use
UDCTinstead ofUDCTModule.UDCTModulestill works and emits aDeprecationWarning.UDCT(..., transform_kind=k)replaces it, andforward(x, structured=False)andbackwardgive the flat layout.forward_vectandbackward_vectremain as deprecated aliases. (#104)Torch window values differ from 1.2 by at most 1.5e-5 (indices are unchanged), because torch now builds its windows in float64 like NumPy. (#107)
Default
window_overlapforwedges_per_direction >= 6is now capped at1/16(0.0625) instead of0.09(for 6) or0.16(for 12), so default coefficients forwedges_per_direction >= 6differ from 1.2;wedges_per_direction=3is unchanged. (#123)Wavelet-mode coefficients now form a tight frame. With
high_frequency_mode="wavelet", the highest-scale wavelet band’s forward coefficients are scaled by \(1 / \sqrt{2}\) inrealandmonogenicmodes, andcomplexwavelet mode emits a single direction (1 wedge) at the highest scale instead of2 * ndimduplicate copies. (#127)
Project¶
The CI test matrix is skipped for documentation-, docstring- and example-only changes, fails fast on pull requests and skips retesting up-to-date merges. (#102, #110, #112, #115)
The torch guide is organized around usage tips, and the public API carries
versionaddedandversionchangednotes for 1.3. (#101, #105)The pre-commit hooks and their dependencies are updated and pinned (including ruff from 0.9.7 to 0.17.1), and
docs/requirements.txtis replaced byuv pip install --torch-backend=cpuwith dependency groups inpyproject.toml. (#133)FDCT patent information added to the README. (#69)
How these were measured¶
PyTorch on a GPU: one RTX 4090 pod with both versions in identical environments (torch 2.15.0+cu132, Triton 3.9.0, Python 3.12.3) and the same script. Two interleaved rounds agreed within about 3%.
Building a transform: Intel i7-8565U laptop, Python 3.14.2, NumPy 2.5.5, torch 2.15.0, a fresh process per case, with 10–20% noise.
NumPy: 32 vCPUs of an AMD EPYC 9575F, Python 3.13, NumPy 2.5.5, SciPy 1.18.1, 32 workers.
Every table holds the other factors fixed unless the feature does not exist in 1.2 (native batching, CUDA graphs and FFT engines).