Skip to main content

xitorch: differentiable scientific computing library

Build Docs Code coverage

xitorch is a PyTorch-based library of differentiable functions and functionals that can be widely used in scientific computing applications as well as deep learning.

The documentation can be found at: https://xitorch.readthedocs.io/

Example

Finding root of a function:

import torch
from xitorch.optimize import rootfinder

def func1(y, A):  # example function
    return torch.tanh(A @ y + 0.1) + y / 2.0

# set up the parameters and the initial guess
A = torch.tensor([[1.1, 0.4], [0.3, 0.8]]).requires_grad_()
y0 = torch.zeros((2, 1))  # zeros as the initial guess

# finding a root
yroot = rootfinder(func1, y0, params=(A,))

# calculate the derivatives
dydA, = torch.autograd.grad(yroot.sum(), (A,), create_graph=True)
grad2A, = torch.autograd.grad(dydA.sum(), (A,), create_graph=True)

Modules

  • linalg: Linear algebra and sparse linear algebra module
  • optimize: Optimization and root finder module
  • integrate: Quadrature and integration module
  • interpolate: Interpolation

Requirements

  • python >=3.8.1,<3.12
  • pytorch 1.13.1 or higher (install here)

Getting started

After fulfilling all the requirements, type the commands below to install xitorch

python -m pip install xitorch

Or to install from GitHub:

python -m pip install git+https://github.com/xitorch/xitorch.git

Finally, if you want to make an editable install from source:

git clone https://github.com/xitorch/xitorch.git
cd xitorch
python -m pip install -e .

Note that the last option is only available per PEP 660, so you will require pip >= 23.1

Used in

Gallery

Neural mirror design (example 01):

neural mirror design

Initial velocity optimization in molecular dynamics (example 02):

molecular dynamics

Metadata

Release files for xitorch 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xitorch 0.5.1
File Size Uploaded
xitorch-0.5.1.tar.gz 96.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xitorch 0.5.1
File Interpreter ABI Platform
xitorch-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 218.5 kB

Release files / xitorch-0.5.1.tar.gz

Download URL xitorch-0.5.1.tar.gz
Size 96.3 kB
Tags Source
SHA-256 checksum
How to use checksums
79c5fb8a072f51125ee87aa8a1b60f8f2f6e8abc4723c000639dbc292c23c70b
BLAKE2b-256 checksum
How to use checksums
1c2da22282c917f9dadb209a570c3934119632ba7fd39a958d405f7f110afc3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.8.12 Linux/5.19.0-32-generic

Release files / xitorch-0.5.1-py3-none-any.whl

Download URL xitorch-0.5.1-py3-none-any.whl
Size 122.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8aeaea4be231987f9f22a79c5bde49cf33d7a7ac386c87ac03ff1048e0044bba
BLAKE2b-256 checksum
How to use checksums
e260616b7fa9c056701459e7144725749f7745de65489fa727498868aa680678
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.8.12 Linux/5.19.0-32-generic

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page