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

File metadata

File hashes

Hashes for winder-0.1.0b4-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f892bad92603bb3cb648534d8ca706e5eecd3f85b7c147f86a76faac526f1c2d
MD5 c9295971b516ce1cf2869765bc9e27a7
BLAKE2b-256 e189be85fee84af04e3aca7eb2e2ce6cfd79aec0edf40c5b5776abad65a782e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5e7eeaf87ba680b3d9d07cd8492509196cc7df4aae1350a14478696ae32560a8
MD5 ca0ab66dfaa2b10d42cd12f2008d2055
BLAKE2b-256 db3d35b17ac8b98ff687ad74240ab78fb4ebf0c5c25fb53e7743554fdfd4b84b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b4-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 57cc8b6436e27540f7e4fb92ae5af07b55378a930b96ee2e0b01ff1c12e8a0e5
MD5 b9b6ca0a0231734856de4231fcd9ad7c
BLAKE2b-256 dde03d2898622b799446c53276eef3ad4bacb0dfa0f9d4893a1b742004fbf649

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a080d1e3dffcf9330744cecdf7e3eb78aea3d8607fa40054f5ebc0f2e89403f4
MD5 a0f07202a11e882918e59d69b32fc52b
BLAKE2b-256 0f2a83c154c323e6b73285960369aec323ebcb987457baa7dca07594d210c009

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 57594612ce74ca7734c925bf4d4e1ef4fad920f633ec6f86da4ecb6b608b345f
MD5 eb469cdc341cd11819f06a4ffcd3f811
BLAKE2b-256 770bee632e762b21d4e3eb0b8e805fedd3be30d913b013b586f36971239937fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aa17f10c5941b4c5ad29d89807768a4494d5d5bcdde9286f885d37e87a8f27cd
MD5 2a0fea5744b78c461d71efd5b8e4cf3f
BLAKE2b-256 5d12e0475ea2788efd1abe4a708e3f314b46ce534de25e9b4c36087f61e57501

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for winder-0.1.0b4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 536166544e6a523d9e15ec10c6245e47b1afaf6500a2c8c75498bbc1ff37fb59
MD5 590397e386acf25f52244c24dcef6a3f
BLAKE2b-256 0a1160d18bfabbc427409dd335e18da9c11e889715ae056c8eb57208848ed8b4

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