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

File metadata

File hashes

Hashes for winder-0.1.0b3-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7691c7f48de2e2f5a9ac524ed8df795779f18c567790560d56326ca32e2c373f
MD5 d9b4be87d578649f76302d7acf1bdd2e
BLAKE2b-256 af84dfa483ce25f3b88a2d3ebf057f0d6383e426341c4a779fe70c02218b5dbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b3-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3a52ba4d7b145d3911a052d749c0b775c1980fe9aae03d8c61ccf06c17700e71
MD5 aa037d1ecc243801634a3ef107492e85
BLAKE2b-256 54feda15ca4f4a4777ab506dce260cdb634413cdd22670cac36d865d44d82772

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b3-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8cd96aff2528d9dbd327a78b790d9cb871786e5aaba6fc36c9d36a8be24a56f5
MD5 27e0a5dd0e1c5d360d9076790b85fce0
BLAKE2b-256 72295ca47b65869986d009d9812c6f08dd16652f50010317f9d98f403a49a36b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b9450e0db9e411d1cbb53c532eac948cb416bc230bd7929540d47e33bc8d4b63
MD5 8c0845e17bb5e24aa79a832a25910d0f
BLAKE2b-256 c049d47bb51c2538217b2531ef41811bc29b0662026797be4ab6db0fec8b13cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f86de813929db67056a85bc67d37deb487ac119a5710b8c7c5de353d73705b71
MD5 88a8c683a4f66f9c6e0bda2019893f08
BLAKE2b-256 e5067a4da843f077eee04dc3dd917ed3c85a1ec05801765c057c98c96954b951

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1f9e401f127d2d4d55bfc734c510985471efdf0728be158d463694985141674a
MD5 31fb9b0aabe4c876ac69d1b1fc718233
BLAKE2b-256 85c1e985c6c4b72ecb3610ade049c9740a8423959852ca51c71214b65b9b35ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 11c3278ae9d95b8218ee084eb1547cfed142de99032f7e738d61f2b516fa17dc
MD5 8dcd9b332ef7f23b824cf4e244700f1b
BLAKE2b-256 21fe2adc42bf8ad325ff80f3dbf3730a8d26eea6a4b20f289b9ff434a9eecec7

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