Skip to main content

torchbvh

GPU geometry for PyTorch point clouds. Fast k-NN, farthest-point sampling, interpolation, and ray tracing.

PyPI version Python versions Documentation License

Documentation · API reference · Benchmarks

Performance

20x faster k-NN than torch_cluster GPU and 9.2x faster approximate FPS than fpsample CPU, averaged across all 20 benchmark workloads.

Batched 3D benchmark: torchbvh k-NN and FPS compared with third-party libraries; interpolation on a regular grid provides context.

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.

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torchbvh 0.3.1
File Size Uploaded
torchbvh-0.3.1.tar.gz 392.3 kB Details

Release files / torchbvh-0.3.1.tar.gz

Download URL torchbvh-0.3.1.tar.gz
Size 392.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b21f989f2677fdc6a19f623de68f0d935495036e97f9849a364af9ff9c183ad9
BLAKE2b-256 checksum
How to use checksums
ea2d891df85ec90518d3f8d66064bed1fbe0224c2c7ee933819ca0ff36be28d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release history Release notifications | RSS feed

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

This release

0.3.1 This release

1 release file

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page