ComplexTorch
Homepage | Documentation | Changelog
Complex PyTorch
(Available on PyPI)
Author: Josiah W. Smith, Ph.D.
A lightweight complex-valued neural network package built on PyTorch.
This is a package built on PyTorch with the intention of implementing light-weight interfaces for common complex-valued neural network operations and architectures. Notably, we include efficient implementations for linear, convolution, and attention modules in addition to activation functions and normalization layers such as batchnorm and layernorm.
Although there is an emphasis on 1-D data tensors, due to a focus on signal processing, communications, and radar data, many of the routines are implemented for 2-D and 3-D data as well.
What's new
See CHANGELOG.md for the full release history. Version 2.0
brings major feature-parity expansion (RNN/LSTM, Transformer, ARD/Variational
Dropout, masked layers, transforms, signal, datasets, models subpackages); see
the changelog for the breaking changes around MultiheadAttention and
default bias=True. Version 2.0.1 adds symmetry-aware modules
(U(1)-equivariant / invariant building blocks from
SurReal and
CDS, with reference networks under
complextorch.models) plus SpectralPool{1,2,3}d
(Rippel 2015 /
Trabelsi 2018) for frequency-domain
downsampling.
Documentation
Live docs: https://josiahwsmith10.github.io/complextorch/latest/ — including
an executable Getting Started notebook
and a full API reference auto-generated from docstrings. The accompanying
paper is at docs/complextorch_paper.pdf.
Dependencies
This library requires numpy and PyTorch.PyTorch should be installed to your environment using the compute platform (CPU/GPU) settings for your machine. PyTorch will not be automatically installed with the installation of complextorch and MUST be installed manually by the user.
Installation:
IMPORTANT: Prior to installation, install PyTorch to your environment using your preferred method using the compute platform (CPU/GPU) settings for your machine.
Using pip
pip install complextorch
From the source:
git clone https://github.com/josiahwsmith10/complextorch.git
cd complextorch
pip install -r requirements.txt
pip install . --use-pep517
Basic Usage
import torch
import complextorch as cT
x = torch.randn(64, 5, 7, dtype=torch.cfloat)
model = cT.nn.Conv1d(5, 16, kernel_size=3)
y = model(x)
Development
The test suite mirrors complextorch/ 1:1 under tests/ and covers every public class and helper. CI enforces 100% line coverage on Python 3.10 / 3.11 / 3.12 — any PR that drops coverage fails automatically.
pip install '.[test]' # pytest, pytest-cov, pytest-xdist, hypothesis
pytest # auto-parallel (-n auto) from pyproject
pytest --cov=complextorch --cov-report=term-missing --cov-fail-under=100 # mirror CI exactly
pytest --cov=complextorch --cov-report=html && open htmlcov/index.html # browse uncovered lines
When adding a new module, add a matching tests/.../test_<module>.py. Fast/Slow numerical equivalence checks share weights via load_state_dict; loss tests sweep the reduction matrix; round-trip invariants (Fast/Slow, polar, casting, FFT) live under tests/invariants/ and use Hypothesis. Prefer per-line # pragma: no cover over whole-function exclusions so dead code stays visible.
Metadata
Release files for complextorch 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| complextorch-2.1.1.tar.gz | 112.4 kB | With provenance | Details for complextorch-2.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| complextorch-2.1.1-py3-none-any.whl | Python 3 | none | any | Details for complextorch-2.1.1-py3-none-any.whl |
Total release size: 248.9 kB
Release files / complextorch-2.1.1.tar.gz
| Download URL | complextorch-2.1.1.tar.gz |
|---|---|
| Size | 112.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50014d826899401e2b4a8a3cf13f28df98aa0bdf5f30eaed0cce39abfa72716f
|
|
BLAKE2b-256 checksum How to use checksums |
3688975039695bcac809ea0877c7e25da1130c6e7dff803f5542cf378edb67a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.
Transparency logRelease files / complextorch-2.1.1-py3-none-any.whl
| Download URL | complextorch-2.1.1-py3-none-any.whl |
|---|---|
| Size | 136.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
604105023e5ed27406399d9c785cb658f8123ba19e99072e4e954603dec11f68
|
|
BLAKE2b-256 checksum How to use checksums |
34eadc137af25a9b1d7377fb6af0fd28ccc6042d7a5010f43899d9ef2afcf92e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.
Transparency logSecurity for complextorch 2.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for complextorch-2.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.