Skip to content

Exploring whether a Rust/SIMD backend could be useful to PyWavelets #865

Description

@AlephNotation

Hi everyone!

I started this project while exploring portable SIMD programming in Rust. Wavelet transforms seemed like a particularly good fit, and PyWavelets was unusually valuable as a source of ground truth.

After a few days I now have a safe Rust implementation of real-valued 1D DWT/IDWT and multilevel wavedec/waverec. I got curious as to whether we the SIMD implementation gains would hold through a python interface equivalent to PyWavelets.

On an apple M4 max, measured in the same CPython interpreter with the same numpy inputs:

  • The reusable-plan api is 3.54× faster at the median across 70 cases and wins all 70.
  • A conservative cold path, including wavelet construction and planning on every rust call, is 2.14× faster at the median and wins 64/70.
  • For representative 4096 point f64 transforms, the cold-path gains range from 1.52× to 2.80×.

Output creation and destruction are included. The repository contains the methodology, compatibility tests, environment metadata, and all 4,200 raw timing samples:

I realize this is coming out of nowhere, and adding a rust toolchain would be a substantial deviation for PyWavelets. I want to be super clear that I am in no way suggesting that the existing implementation should simply be replaced. Besides, my current implementation only covers a subset of PyWavelets.

That said, if this is something you guys would be interested in, I would be interesting in doing the work.

If the build or maintenance implications make Rust a nonstarter, I completely understand. I wanted to ask before investing in a deeper integration prototype.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions