skillfed

torchsde

SDE solvers and stochastic adjoint sensitivity analysis in PyTorch.

torchsde v0.2.6 1.8M downloads/30d#3,513 on PyPI1,726
Permissive license Abandoned released

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 torchsde

uv

uv add torchsde

poetry

poetry add torchsde

Installing 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

License :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3

Tags

stochastic differential equation solverSDE solver pytorchneural SDEdifferentiable SDElatent SDE learningstochastic adjoint sensitivitySDE backpropagation
stochastic-processesdifferentiable-computingresearch-code

More Artificial Intelligence packages

Further reading