Differentiable Curves in PyTorch

What are Differentiable Parametric Curves?
Differentiable parametric curves are vector-valued functions of a scalar parameter that are built from components with well-defined gradients.
In these regulated sectors the practical value is not novelty for its own sake. It is the ability to keep a model auditable and explainable while retaining gradient-based optimization. A curve with a small number of coefficients is easier to review than a black-box MLP, and the same curve can be versioned, logged, and reproduced for compliance.
TorchCurves: A PyTorch Library for Differentiable Curves
TorchCurves is a PyTorch library that treats vector-valued parametric curves as learnable primitives [1]. Its central operation maps batches of scalar inputs to points on curves represented in B-spline or Legendre polynomial bases [1].
Curve coefficients can be optimized jointly with the surrounding model [1]. The library provides trainable modules, reusable basis modules, and a functional interface [1].
This design maps directly to production concerns in financial and regulated domains. A rate curve, revenue forecast, or risk profile can be defined once as a module, reused across services, and optimized with the same training loop used for the rest of the system. Because the basis is explicit, the number of parameters is bounded and interpretable, which helps with model risk documentation.
A minimal usage pattern illustrates the API shape:
import torch
from torchcurves import BSplineCurve
# learnable curve over a scalar domain, e.g., days
curve = BSplineCurve(num_control_points=8, degree=3, dim=1)
t = torch.linspace(0.0, 1.0, 100).unsqueeze(-1)
y = curve(t) # differentiable mapping
target = torch.zeros_like(y)
loss = (y - target).pow(2).mean()
loss.backward()
Coefficients are ordinary nn.Parameters, so they participate in standard optimizers, checkpointing, and TorchServe deployment. The functional interface also allows inference without a module wrapper when only evaluation is needed.
Applications and Benefits of Differentiable Curves
In education and healthtech, the same primitive represents enrollment or engagement trajectories, and patient monitoring trends, where smoothness and extrapolation behavior are important for safety and interpretability.
Benefits relevant across these sectors:
- Joint optimization. Curve coefficients can be optimized jointly with the surrounding model [1], enabling end-to-end training of a curve-conditioned predictor.
- Reusability. The library provides trainable modules, reusable basis modules, and a functional interface [1], which supports code sharing between research and production.
- Auditability. Fewer, explicit parameters than a deep MLP make review by compliance or clinical governance easier.
- Consistency. Batch mapping from scalar inputs to points is vectorized, so curves scale to large historical datasets without custom loops.

In practice, a service boundary often looks like an API gateway feeding an auth service, orders service, billing service, and a Redis cache. A curve module can sit inside the billing service to price a product over time, or inside a risk service to generate a smooth capital requirement profile. Because the module is PyTorch-native, it can be trained offline and served via TorchServe for high-performance inference.
Comparison with Related Libraries
TorchCurves is specialized for 1-D parametric curves with explicit bases. Related PyTorch libraries target different differentiable domains, which changes how they fit developer workflows.
| Library | Primary Domain | Differentiable Primitive | Typical Use |
|---|---|---|---|
| TorchCurves | Parametric curves | B-spline / Legendre basis with learnable coefficients | Smooth 1-D functions, time series, rate curves |
| NVIDIA Kaolin Wisp | Neural fields | Neural fields including NeRFs, NGLOD, instant-ngp and VQAD | 3D scene representation, volumetric rendering |
| Torch Lens Maker | Geometric optics | Optical elements as neural network layers | Differentiable lens design, ray optics |
NVIDIA Kaolin Wisp is a PyTorch library powered by NVIDIA Kaolin Core to work with neural fields (including NeRFs, NGLOD, instant-ngp and VQAD) [2]. NVIDIA Kaolin Wisp aims to provide a set of common utility functions for performing research on neural fields [2]. Wisp also comes with building blocks like differentiable renderers and differentiable data structures (like octrees, hash grids, triplanar features) which are useful to build complex neural fields [2].
Torch Lens Maker is an open-source Python library for differentiable geometric optics based on PyTorch [3]. The library uses PyTorch's automatic differentiation and numerical optimization algorithms with GPU support [3]. The library allows designers to treat optical elements as layers of a neural network, with light rays as data flowing through the network [3]. The library uses a similar API to PyTorch's neural network API, allowing designers to stack lenses and mirrors as if they were Conv2d and ReLU layers [3].
The comparison shows a clear split in intent. TorchCurves exposes trainable modules, reusable basis modules, and a functional interface for 1-D curve learning [1]. Wisp provides utility functions and differentiable renderers for neural fields [2]. Lens Maker provides differentiable geometric optics with an API analogous to torch.nn [3]. For banking, education, healthtech, fintech and tax returns, the need is for small, interpretable 1-D functions that can be logged, versioned, and explained to auditors. TorchCurves matches that need; Wisp and Lens Maker address 3-D scene and optics domains.
Conclusion
For developers in regulated industries, differentiable parametric curves offer a practical middle ground between rigid formulas and black-box models. TorchCurves provides a PyTorch-native way to treat vector-valued parametric curves as learnable primitives [1], with mapping via B-spline or Legendre polynomial bases [1], joint optimization of coefficients [1], and a module / functional API [1].
The subject applies in the same way across banking, education, healthtech, fintech and tax returns: the core requirement is smooth, auditable functions that can be optimized with gradients and deployed reliably. Where sector-specific constraints appear, they are constraints on the curve shape, data access, and governance — not on the primitive itself.
Using explicit bases keeps the parameter count bounded and interpretable, which supports model risk documentation and compliance review. The trainable module and functional interface allow the same curve definition to move from research experiments to production services without reimplementation. Joint optimization with the surrounding model lets domain quantities such as rate curves, enrollment trajectories, or vital trends be learned end-to-end while remaining inspectable.
This combination of differentiability, explicit parameterization, and PyTorch-native ergonomics is why TorchCurves is positioned for regulated, developer-facing workflows where auditability and reproducibility are non-negotiable.
References
- [2611.14516v1] TorchCurves: Differentiable Parametric Curves — arxiv.org
- NVIDIAGameWorks/kaolin-wisp — github.com (4 August 2024)
- Torch Lens Maker — victorpoughon.github.io (21 March 2025)