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.0b5-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 MB view details)

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

winder-0.1.0b5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 MB view details)

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

winder-0.1.0b5-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 MB view details)

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

winder-0.1.0b5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 MB view details)

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

winder-0.1.0b5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 MB view details)

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

winder-0.1.0b5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 MB view details)

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

winder-0.1.0b5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 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.0b5-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for winder-0.1.0b5-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e8179ebda12e38cb4dcad49c00b9e421fb827ba185842ec4b824b33da90205b5
MD5 faf74b4f03e9754b4e2dcbde1f5a4861
BLAKE2b-256 9afee49cfc84e57aee6ee8a2e19b77691c2433b9b7f09456861f51b39b169029

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 37dd17edb4164ea968e63fb6e76bb07bcc27d1dcee8f68fd29490f41d7b54856
MD5 bacffff3f02ce0b77efe5b2573e2f7fb
BLAKE2b-256 bae6f5165e54f6e7c4c9a53840651e5d3478780ca05e7f6474773d8b0f7b4ed6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b5-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c6fb2462f63c62f34f22770da120e65f6bab06dcbcf08e6596229e3da3af86b
MD5 294fe1c1cdb38f3d6fbcc6241d2eb853
BLAKE2b-256 1e8656f9c1adcc563ee1796ddd12de00ec77ab3587406fa30546447ba0114f24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5d377936220693aa68d28cee0761152491894215df3f584b53ff2465bf2a81b3
MD5 d83abab1a87732dad8621295b0437db1
BLAKE2b-256 ec77803bb450176e72a4a69a20112983be4545c444d99d7726cb14a94834a153

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 192cdfe238d7ffcf7c7d40a74087f78f25adf8bdf4600250a2321904db61f9e5
MD5 45b0ef782ab6560c35cabf6ad6c3c545
BLAKE2b-256 655e8a4936818ef790530aff481aae5e0635b49b7d8e1eb5d4f0408ffe4310b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 56e2f7c530168c65f4f46e3ec046cc821b7c544bed99537cb11e9c9cbb6ca790
MD5 928c0743fed221a7bea944cf813025da
BLAKE2b-256 1a4012ee481ebbe14895dcddb6ca4cb4722b7f5a7639237131ffb16168f23476

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 51116a5929c1038257d3bf1125d25d13f20edace1d1182fc85414c2be73fc976
MD5 00cd64153b51e51b88c25d0e23efa668
BLAKE2b-256 08e47ce7cde5efb5e27dcdfa16a39dfa9c07d4a9b922d7411c042a4b33067180

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