Skip to main content

Differentiable scientific computing library

Project description

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:


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)


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


  • python 3.7 or higher
  • pytorch 1.8 or higher (install here)

Getting started

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

python -m pip install xitorch

Or if you want to install from source:

git clone
cd xitorch
python -m pip install -e .


Neural mirror design (example 01):

neural mirror design

Initial velocity optimization in molecular dynamics (example 02):

molecular dynamics

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xitorch-0.3.0.tar.gz (94.1 kB view hashes)

Uploaded source

Built Distribution

xitorch-0.3.0-py3-none-any.whl (117.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page