GPU geometry for PyTorch point clouds. Fast k-NN, farthest-point sampling, interpolation, and ray tracing.
Documentation · API reference · Benchmarks
Performance
25.3x faster k-NN than torch_cluster GPU and 9.2x faster approximate FPS than fpsample CPU, averaged across all 20 benchmark workloads (arithmetic mean of per-workload ratios).
torchbvh k-NN/MLS rows were refreshed on 2026-10-07; the 160 competitor, grid_sample and FPS rows retain their 2026-09-23 measurements. See the benchmark protocol and data and MLS numerical behavior.
About
torchbvh provides CUDA operations for 2D and 3D float32 point clouds, including fixed-size batches:
- k-NN: BVH-accelerated nearest-neighbor search.
- FPS: exact and bucketed approximate farthest-point sampling.
- Interpolation: moving least squares (MLS) over scattered point features.
- Ray tracing: segment and triangle intersections.
Installation
Install CUDA-enabled PyTorch, a matching CUDA toolkit with NVCC, and a supported C++ compiler, then install torchbvh:
pip install torchbvh
See the build guide for compiler and source-install details.
Quickstart
import torch
import torchbvh as tb
points = torch.rand(10_000, 3, device="cuda")
queries = torch.rand_like(points)
with tb.BVH(points) as bvh:
neighbors, distances_sq = bvh.knn(queries, k=4)
sample = tb.fps(points, target_tokens=2_500, mode="approx_bucketed")
features = torch.rand(10_000, 64, device="cuda")
values = tb.mls_interpolate(points, queries, features, k=4)
See the examples for exact FPS, ray tracing, and gradients.
Share point geometry within a forward
other_queries = queries + 0.01
with tb.PointGeometry(points) as geometry:
values = tb.mls_interpolate(points, queries, features, k=4, geometry=geometry)
other = tb.mls_interpolate(points, other_queries, features, k=4, geometry=geometry)
# Saved tensors remain available for backward after the geometry closes.
Create a new geometry object each model forward. The original tensor must stay
unchanged while the object is open. Conditional MLS accepts true_geometry
and false_geometry; multihead MLS accepts geometry.
See prepared geometry
for lifecycle rules and automatic dispatch eligibility.
References
The BVH implementation builds on Chitalu, Dubach, and Komura (2020) and ImplicitBVH.jl. Released under the MIT license.
Metadata
Release files for torchbvh 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| torchbvh-0.3.2.tar.gz | 1.3 MB | Details |
Release files / torchbvh-0.3.2.tar.gz
| Download URL | torchbvh-0.3.2.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
789e9e2ba9b3fe5d9334dcb838b5df87ea7a193e1eff2f888a791a4c5ed95ad2
|
|
BLAKE2b-256 checksum How to use checksums |
69b6404ff4c5349ee1663fe2df4de4368b7426ac1fa4589585277f937606a7bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|