torchbvh
GPU-native geometry primitives for PyTorch point-cloud workflows: BVH construction, exact k-NN search, MLS interpolation, displaced-query helpers, and FPS downsampling.
Performance
k-NN at N=10k, 3D, k=8 (RTX 3500 Ada, uniform distribution):
| Build + query | |
|---|---|
scipy_cKD-Tree CPU |
~23 ms |
torch_cluster GPU |
~6.8 ms |
cupy_knn GPU |
~4.1 ms |
torchbvh GPU |
~1.4 ms |
FPS at B=16, N=10k, 25% selection (RTX 3500 Ada):
| Time | |
|---|---|
fpsample CPU |
~833 ms |
torch_fpsample h=7 (CPU, fastest setting) |
~37 ms |
torchbvh GPU |
~21 ms |
See benchmarks/third_party_algorithm_comparison.ipynb for more detailed comparisons.
Install
pip install torchbvh
torchbvh builds a PyTorch CUDA extension. Source installs require PyTorch, a
compatible CUDA toolkit/NVCC, and a supported host compiler in the build environment.
Docs
Documentation can be found at torchbvh.readthedocs.io.
Quickstart
import torch
import torchbvh as tb
points = torch.randn(1024, 3, device="cuda")
bvh = tb.BVH(points)
# k-NN
idx, dists = bvh.knn(points, k=8) # (N,8) int64, (N,8) float32
# MLS interpolation — gradients flow through features
feat = torch.randn(1024, 16, device="cuda", requires_grad=True)
out = bvh.interpolate(points, feat, k=8) # (N, 16)
# FPS downsampling geometry
fps = tb.fps(points, target_tokens=256)
# fps.indices, fps.points, fps.nearest_anchor, fps.anchor_radius, ...
# Batched: pass (B, N, D) → returns (B, N, k)
Supports D in {2, 3}, k in {4, 8, 16}, CUDA float32 contiguous inputs.
References
torchbvh builds an implicit bounding volume hierarchy over 2-D or 3-D points.
The BVH layout follows the ostensibly-implicit tree formulation of Chitalu, Dubach, and
Komura, and the Python/CUDA implementation was ported from the Julia
ImplicitBVH.jl implementation.
- Floyd M. Chitalu, Christophe Dubach, and Taku Komura. "Binary Ostensibly-Implicit Trees for Fast Collision Detection." Computer Graphics Forum, 39(2), 509-521, 2020. DOI: 10.1111/cgf.13948.
ImplicitBVH.jl, StellaOrg. Julia implementation of the implicitly indexed BVH formulation from which thetorchbvhBVH code was ported: github.com/StellaOrg/ImplicitBVH.jl.
Metadata
Release files for torchbvh 0.1.1
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.1.1.tar.gz | 111.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| torchbvh-0.1.1-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
Total release size: 799.4 kB
Release files / torchbvh-0.1.1.tar.gz
| Download URL | torchbvh-0.1.1.tar.gz |
|---|---|
| Size | 111.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
952e941e6011c6ded417af6c356b6f5c4dbbc14521e5f4bc173303b4f95d37c4
|
|
BLAKE2b-256 checksum How to use checksums |
fc9e2b3c7851256f58d15ffd6093ea674dd357ea60358646fb7fb8192a17126d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Release files / torchbvh-0.1.1-cp313-cp313-win_amd64.whl
| Download URL | torchbvh-0.1.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 688.4 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
93bc367840cec941b9358dd539401561f44a75f5072c7d547b6f68ae512c26e4
|
|
BLAKE2b-256 checksum How to use checksums |
1584ac54a3b1281b0bbcff40f5cbd1af83c2c583dc6385f235a2d70f2998a4fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|