torchvinecopulib
A Python library for fitting and sampling vine copulas, using PyTorch.
- C/D/R-Vine full-sampling/ quantile-regression/ conditional-sampling, all in one package
- Flexible sampling order for experienced users
- Vectorized tensor computation with GPU (
device='cuda') support - Shorter runtimes for higher dimension simulations
- Pure
Pythonlibrary, inspired by pyvinecopulib on Windows, Linux, MacOS - IO and visualization support
Citation
If you use torchvinecopulib in your work, please cite:
Cheng, Tuoyuan, Thibault Vatter, Thomas Nagler, and Kan Chen. "Vine Copulas as Differentiable Computational Graphs." arXiv preprint arXiv:2506.13318 (2025).
@article{cheng2025vine,
title={Vine Copulas as Differentiable Computational Graphs},
author={Cheng, Tuoyuan and Vatter, Thibault and Nagler, Thomas and Chen, Kan},
journal={arXiv preprint arXiv:2506.13318},
year={2025},
url={https://arxiv.org/abs/2506.13318},
}
Examples
Visit the ./examples/ folder for .ipynb Jupyter notebooks.
Installation
- By
pipfromPyPI:
pip install torchvinecopulib torch
- Or
pipfrom./dist/*.whlor./dist/*.tar.gzin this repo. Need to use proper file name.
# inside project root folder
pip install ./dist/torchvinecopulib-1.1.0-py3-none-any.whl
# or
pip install ./dist/torchvinecopulib-1.1.0.tar.gz
(Recommended) uv for Dependency Management and Packaging
After git clone https://github.com/TY-Cheng/torchvinecopulib.git, cd into the project root where pyproject.toml exists,
# inside project root folder
uv sync --extra cpu -U
# or
uv sync --extra cu126 -U
Dependencies
# inside the `./pyproject.toml` file;
fastkde = "*"
numpy = "*"
pyvinecopulib = "*"
python = ">=3.11"
scipy = "*"
# optional to facilitate customization
torch = [
{ index = "torch-cpu", extra = "cpu" },
{ index = "torch-cu126", extra = "cu126" },
]
For PyTorch with cuda:
pip install torch --index-url https://download.pytorch.org/whl/cu126 --force-reinstall
# check cuda availability
python -c "import torch; print(torch.cuda.is_available())"
Documentation
-
Visit GitHub Pages website
-
Or build by yourself (need
Sphinx, themefuroand the GNUmake)
# inside project root folder
sphinx-apidoc -o ./docs ./torchvinecopulib && cd ./docs && make html && cd ..
# if using uv
uv run sphinx-apidoc -o docs torchvinecopulib/ --separate
uv run sphinx-build docs docs/_build/html
Tests
# inside project root folder
python -m pytest ./tests
# coverage report
coverage run -m pytest ./tests && coverage html
# if using uv
uv run coverage run --source=torchvinecopulib -m pytest ./tests
uv run coverage report -m
TODO
VineCop.rosenblatt- replace
dictwithtorch.Tensorusing somemod - vectorized union-find
- flatten
_visitlogic examples/someapplications.ipynb- flatten dynamic nested dicts into tensors
fastkde.pdfontotorch.Tensor
Contributing
We welcome contributions, whether it's a bug report, feature suggestion, code contribution, or documentation improvement.
- If you encounter any issues with the project or have ideas for new features, please open an issue on GitHub or privately email us. Make sure to include detailed information about the problem or feature request, including steps to reproduce for bugs.
Code Contributions
- Fork the repository and create a new branch from the
mainbranch. - Make your changes and ensure they adhere to the project's coding style and conventions.
- Write tests for any new functionality and ensure existing tests pass.
- Commit your changes with clear and descriptive commit messages.
- Push your changes to your fork and submit a pull request to the
mainbranch of the original repository.
Pull Request Guidelines
- Keep pull requests focused on addressing a single issue or feature.
- Include a clear and descriptive title and description for your pull request.
- Make sure all tests pass before submitting the pull request.
- If your pull request addresses an open issue, reference the issue number in the description using the syntax
#issue_number. - in-place ops can be slower
- torch.jit.script can be slower
License
This project is released under the MIT License (© 2024- Tuoyuan Cheng, Kan Chen).
See LICENSE for the full text, including our own grant of rights and disclaimer.
Third-Party Dependencies
See the “Third-Party Dependencies” section in LICENSE for details on the PyTorch, FastKDE, and pyvinecopulib licenses that govern those components.
Metadata
Release files for torchvinecopulib 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| torchvinecopulib-1.1.2.tar.gz | 52.4 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| torchvinecopulib-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 83.9 kB
Release files / torchvinecopulib-1.1.2.tar.gz
| Download URL | torchvinecopulib-1.1.2.tar.gz |
|---|---|
| Size | 52.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4d8cbc544b6fee71594b6200a08d5ba4aef440ba43eafc396c094dfefd66abc
|
|
BLAKE2b-256 checksum How to use checksums |
9731d3ab417a36e15822f9e0d304938f9fe612df30457506c01c3bd3b3ba60ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 28, 2025.
Transparency logRelease files / torchvinecopulib-1.1.2-py3-none-any.whl
| Download URL | torchvinecopulib-1.1.2-py3-none-any.whl |
|---|---|
| Size | 31.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61b174d9a6c72396dab290c1428e98ade72a251eabffaafb48db354052858534
|
|
BLAKE2b-256 checksum How to use checksums |
5f5a004dc544041554830b38ef4085e7c894ee81752a2a1302c897f8efc127d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 28, 2025.
Transparency logSecurity for torchvinecopulib 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for torchvinecopulib-1.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 28, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.