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.0 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.0b1-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.0b1-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.0b1-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.0b1-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.0b1-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.0b1-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.0b1-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.0b1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for winder-0.1.0b1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52b8b94ec8185258cccbe0944915357626c83cf0f3dd1330cda7601172a2614d
MD5 8bfe5f81e23bc00625c3641d2008a4b1
BLAKE2b-256 e739513e4b64d207c830e08a816f5338621f15fb4595b200788e8274f3cfac6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9e0dd96fffc07a90fe7285bd38b6a6e9fe061d96e0e6e341c65da5fb63bd73ea
MD5 4acc5f61c410a445ad467a88a2933df6
BLAKE2b-256 da76d69edbea310790f66f28de47963add344939c55616c9b670036c142d5a0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ea1b9de25dfad96597b4a56cbeb0967b4f13d6a2849b9681ba994332dc228c0c
MD5 ecc549b0ef60a01cf878c9e956eb4e0f
BLAKE2b-256 db236204a92f51f3e735b7b4872a6e1d9b597ec28b4542ecdd401b7e1dcc6c73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eeed8acac824c971d892eef84f06f5b99557c9e7d22d7184e423e93ccbfda96e
MD5 0c73b454e6478c3636f4ce7f0aa664b7
BLAKE2b-256 4bc928aeb928346f8910ee8cdef178ba6a301b6c1b8d826a9013d7dff4f2f380

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c60af04db4d95e52f20f90ac7a4fb76e9154b619a2b2043ac30d2079b46faa18
MD5 ba88f06ad024401eaaa775f2c1a8eaff
BLAKE2b-256 4d6fae42d01e9588a2ceab4b041c336d36c55b32278b7e4042ef49ca548640b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b3a6bbffd72a471fc1df4ab8cfd8b7b78b3fb2c26e9aaca228437895dbc317c5
MD5 460ca5d96b6a27d7e1ec211ab1aa1a2d
BLAKE2b-256 cff0c5fb6f703bfc0214a626325fb0750397504c5aed72f6ddf3d161cb0910c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 50cace44ef8f683fc7fda420fe149aea0f7d81f6b7cf358a7ac3d287757459c0
MD5 e9213f3482c707e35e4c211b995ffe14
BLAKE2b-256 4b9db4601209b69447c1645b1540c47e0ce584acd73b03a2a691aba7cd034c2a

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