torchsde
SDE solvers and stochastic adjoint sensitivity analysis in PyTorch.
What it is and what it does
torchsde is a PyTorch library that solves stochastic differential equations with automatic differentiation and GPU acceleration. It implements SDE solvers that support backpropagation through the solution trajectory, enabling end-to-end learning of SDE-based generative and latent-variable models. The library handles both Itô and Stratonovich SDEs with configurable noise types and provides efficient adjoint sensitivity methods for gradient computation.
The package is built on torch, numpy, scipy, and trampoline, and is designed for researchers working with neural SDEs, latent SDE models, and SDE-based generative models like GANs. It abstracts away the numerical complexity of SDE solving while maintaining differentiability throughout the computation graph, making it suitable for probabilistic deep learning workflows.
Use it for:
- Training latent SDE models that fit stochastic processes to time-series data with learned drift and diffusion terms.
- Building generative models using neural SDEs as the generator component in adversarial training frameworks.
- Performing uncertainty quantification in neural networks by modeling outputs as solutions to SDEs.
- Implementing stochastic adjoint sensitivity analysis for gradient-based optimization of SDE parameters.
- Prototyping research on continuous-time stochastic processes in deep learning.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Solves stochastic differential equations (SDEs) with GPU support and efficient backpropagation through PyTorch, enabling gradient-based learning of SDE-based models.
Yes, if you are actively researching neural SDEs or latent stochastic models and can work with a frozen codebase. The package is well-designed and has no known vulnerabilities, but it is archived and abandoned—no future maintenance or updates should be expected. Use it for research prototyping or as a reference implementation, but be aware that you will be responsible for any fixes or adaptations needed for compatibility with newer PyTorch or Python versions.
Install
torchsde on PyPI
pip
pip install torchsdeuv
uv add torchsdepoetry
poetry add torchsdeInstalling torchsde
Before you install
Low install friction with a pure-wheel distribution. However, the package is archived and abandoned as of the latest release in September 2023, with no commits since December 2024. Depends on torch, numpy, scipy, and trampoline—all standard scientific Python libraries.
License in practice
Licensed under Apache License 2.0 (permissive), allowing commercial and private use with minimal restrictions.
Quickstart
pip install torchsde
import torch
import torchsde
class SDE(torch.nn.Module):
noise_type = 'general'
sde_type = 'ito'
def f(self, t, y):
return y
def g(self, t, y):
return y
sde = SDE()
y0 = torch.zeros(32, 3)
ts = torch.linspace(0, 1, 20)
ys = torchsde.sdeint(sde, y0, ts)
Requires Python >=3.8 and PyTorch >=1.6.0; GPU support depends on a compatible CUDA-enabled PyTorch installation.
Verify before relying
- Whether the archived repository will receive security patches or maintenance updates in the future.
- Compatibility with recent PyTorch versions beyond 1.6.0 and current Python 3.x releases.
- Performance characteristics and numerical stability compared to other SDE solvers.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — numpy, scipy, torch, trampoline |
| Maintenance | abandoned — 1,053 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 1,827,243/month — #3,513 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: torchsde-0.2.6-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
opacusOpacus enables training PyTorch models with…
permissive · top 15,000 on PyPI
torchcdeProvides differentiable GPU-capable solvers for…
permissive · top 15,000 on PyPI
torchdiffeqProvides PyTorch-based ODE solvers with…
permissive · top 5,000 on PyPI
diffraxDiffrax provides numerical solvers for…
permissive · top 15,000 on PyPI
zukoZuko implements normalizing flows in PyTorch as…
permissive · top 15,000 on PyPI
pytorch_revgradImplements a gradient reversal layer for…
permissive · top 15,000 on PyPI
torch-emaComputes exponential moving averages of PyTorch…
unclear · top 15,000 on PyPI
pytorch-forecastingPyTorch Forecasting provides neural network…
permissive · top 15,000 on PyPI
gpytorchGPyTorch is a PyTorch-based Gaussian process…
permissive · top 5,000 on PyPI
torch-optimizerProvides a collection of alternative…
permissive · top 15,000 on PyPI