burn icon indicating copy to clipboard operation
burn copied to clipboard

Complex numbers

Open ifsheldon opened this issue 10 months ago • 4 comments

Feature description

Support for complex numbers in tensors.

Feature motivation

I saw your presentation on Scientific Computing in Rust and come to know burn. As I skim through the doc and issue list, it seems there's no complex number support yet. I'm writing some code for quantum computing simulation, and it'd be super cool to writing it in Rust, but I need complex numbers.

(Optional) Suggest a Solution

Perhaps we can add the most simplistic support for it by treating a complex number as a 2D vector with specific ops.

ifsheldon avatar Jun 07 '25 10:06 ifsheldon

Trying to do something similar. Anybody mind if I work on this?

prakash-shekhar avatar Jun 18 '25 03:06 prakash-shekhar

Seeing two options on how to do this:

  1. Treat complex as a special case of float tensors and basically reuse the existing FloatKind and FloatTensorPrimitive, and just handle complex-specific behavior in the ops.
  2. Make complex a first-class kind and introduce a ComplexKind, add ComplexTensorPrimitive and ComplexTensorOps. It’s more upfront work for backends, but keeps type system clean.

Any thoughts on what would be better @laggui ?

prakash-shekhar avatar Jun 18 '25 04:06 prakash-shekhar

Complex numbers have different semantics than floats. I would opt for a different kind (option 2).

laggui avatar Jun 19 '25 12:06 laggui

Since there are multiple possible ways of implementing complex tensors (mentioned here), and we want to support at least 2 of them (complex as a real and imaginary tensor and a tensor of complex primitives), what naming scheme for the types would make it clear which is which?

I'm guessing we don't want to wrap it in an enum but rather treat them as distinct kinds that support the same ops, partially because I suspect they won't be used interchangeably.

skewballfox avatar Aug 17 '25 22:08 skewballfox