Skip to main content

Fast Differentiable Winding Numbers on GPU

Project description

winder

Building massively parallel, GPU-accelerated C++/CUDA spatial structures to evaluate geometric winding numbers with extreme performance.

⚠️ Active Beta Warning winder is currently in active pre-release development. The API is unstable and subject to breaking changes. Advanced features—such as analytical field derivatives—are currently being implemented. Use with caution in production environments.


💡 The Concept

winder is designed to compute 3D geometric winding numbers across massive query grids entirely on the GPU. By leveraging highly optimized spatial data structures (such as specialized 8-ary Bounding Volume Hierarchies), the library collapses the typical $\mathcal{O}(N \times M)$ brute-force complexity of mesh evaluation down to high-speed logarithmic bounds.

Whether you are evaluating solid angles of open sheets, identifying inside/outside boundaries of complex closed manifolds, or computing continuous volumetric fields for graphics and physical simulations, winder handles millions of primitives and queries seamlessly. Integration to torch, tensorflow, jax, etc works via DLPack-capsules.

For an in-depth dive into the underlying mathematical principles, spatial layout partitioning, and performance benchmarks, read our formal write-up:

👉 Read the Technical Report


🚀 Installation

Because winder is currently in beta, releases are published to PyPI as pre-releases. To install it, you must explicitly pass the --pre flag to your package manager:

pip install winder --pre

System Requirements

  • OS: Linux (ManyLinux 2.28+ compliant distributions)
  • Compute: NVIDIA GPU
  • Driver: NVIDIA Driver supporting CUDA 13.3 or newer (the wheel bundles its own CUDA 13 runtime components, but relies on your host system driver).

🛠️ Quick Start & Usage

winder integrates directly with PyTorch tensors, executing heavy compute pipelines in CUDA space without unnecessary host-to-device memory roundtrips.

  1. Interactive Documentation You can explore the available internal module bindings, arguments, and function structures directly through Python's built-in inspection tool:
import winder
# View the full module documentation, signatures, and docstrings
help(winder)
  1. Basic Example: Brute-Force vs. Accelerated Compute

Here is a minimal script generating spatial queries and evaluating their winding numbers using both the exact baseline evaluator and the optimized hierarchical tree system:

import torch
import winder

# Verify CUDA availability
if not torch.cuda.is_available():
    print("No cuda device found. Returning.")
    exit()

device = torch.device("cuda:0")
print(f"Running winder on device: {device}")

#  Generate a batch of spatial query points (e.g., 1000,000 points in 3D space)
queries = torch.rand((1000000, 3), dtype=torch.float32, device=device)

# Define a simple triangle mesh layout [num_triangles, 3_vertices, 3_coordinates]
# Here we define a single right-angle triangle positioned on the XY plane
triangles = torch.tensor([
    [[0.0, 0.0, 0.0], 
     [1.0, 0.0, 0.0], 
     [0.0, 1.0, 0.0]]
], dtype=torch.float32, device=device)

# Create winder enginge
engine = winder.WinderEngine(triangles)

print("Evaluating winding fields...")
# Method A: Calculate using the exact O(N*M) brute force method
winding_brute = engine.brute_force(queries)

# Method B: Calculate using the optimized accelerated tree structure
winding_fast = engine.compute(queries)

# Load DLPack-capsules into torch tensors
winding_brute = torch.from_dlpack(winding_brute)
winding_fast = torch.from_dlpack(winding_fast)

# Compare results
print(f"Brute-force output shape: {winding_brute.shape}")
print(f"Accelerated output shape: {winding_fast.shape}")
# ... do whatever you want

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

winder-0.1.0b2-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

winder-0.1.0b2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

winder-0.1.0b2-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

winder-0.1.0b2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

winder-0.1.0b2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

winder-0.1.0b2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

winder-0.1.0b2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file winder-0.1.0b2-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for winder-0.1.0b2-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 17d88aff0ba01f8fa05baa51d895c2918c10873ebe5190bb98b91d519004022c
MD5 534b7807f7927123fae9f66853216ad6
BLAKE2b-256 3385ccd1981a8fc0994a8b63865d08b4b3413d626045048cfe250c5bd5836d0f

See more details on using hashes here.

File details

Details for the file winder-0.1.0b2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for winder-0.1.0b2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 71b33c52f6b0bd0e0387499ad5ecf02abff074928f2eb8af22d16af8ab36f5d0
MD5 a9ef3b7f40afc94ecc759564b8ae42d5
BLAKE2b-256 aa29bb24567f7a7e400f8214f6ac9feffd2b8f090f58d6dba91556835a4ba732

See more details on using hashes here.

File details

Details for the file winder-0.1.0b2-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for winder-0.1.0b2-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4a6b9467c70d25bc4c6af55ba3be9593c912584f45b84b4200d4ca7bbcd3cc22
MD5 13b0b1661c0e23488063442e9719eb29
BLAKE2b-256 5cbe059c04e6ea96b43103ef616da48282b7630ceb30a332073526a108ead604

See more details on using hashes here.

File details

Details for the file winder-0.1.0b2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for winder-0.1.0b2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2498a3b0f6ca93d01141d2901873b74347caaf746e52000cc74dd597c04f48dc
MD5 2dba05423e6f5c920524d9afd1935108
BLAKE2b-256 5fab6876ae141bde82c80a0ab0b654e91b4d2d85fb7303b30eb03584a01725cd

See more details on using hashes here.

File details

Details for the file winder-0.1.0b2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for winder-0.1.0b2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3e54dd47f644a21b90f3c3cfaa3c94825c25bdc51f5723687a7166d4fa45cd02
MD5 460037d80d46cbd8d500d4b61458da7e
BLAKE2b-256 1e3812c90f7790be6ddd616c915f763a44908fc01a3c149e4ac532ad55890c33

See more details on using hashes here.

File details

Details for the file winder-0.1.0b2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for winder-0.1.0b2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d77cfd0b78b1bd133d5803fa8d25458864b01c8b1379087aa1e544c9abafaf8
MD5 f0eb716acb5a44a411f7c46c235c325d
BLAKE2b-256 6ca4ac8aae93761d0eca383f75b2f6d3329454d274d97906beb8eeb24f6da20b

See more details on using hashes here.

File details

Details for the file winder-0.1.0b2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for winder-0.1.0b2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 36d67d60e4a9674126247627ba92ad4cf79f3650533571f3db7f6d06f598ab7d
MD5 cbabffda1ac9b82842bfbadcd433af82
BLAKE2b-256 0e620c1fd38e2b4d18ecfc555a8990de268a2a597192d3eb5f135d445adb8aff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page