High-performance H3 operations with GPU acceleration
Project description
FluidGeo H3-Turbo
FluidGeo H3-Turbo is a hardware-accelerated H3 spatial indexing library powered by SYCL (AdaptiveCpp). It provides high-performance, drop-in GPU/CPU-parallelized replacements for standard H3 operations, designed to operate seamlessly on NumPy arrays and PySpark DataFrames.
Quick Links & Resources
- PyPI Project Page: View releases, installation requirements, and package details.
- h3_turbo_benchmarks.ipynb: An interactive Jupyter notebook comparing GPU-accelerated operations against CPU-based
h3-pyandnumpyequivalents across various data sizes (raw compute, spatial joins, batch processing, and GPU index caching reuse). - spark_udf_tests.ipynb: Interactive Jupyter notebook demonstrating PySpark integration, UDF usage, and persistent spatial join optimizations.
Licensing
FluidGeo H3-Turbo is offered under a dual-license model:
- Academic & Non-Commercial: Free for research and educational purposes.
- Commercial & Enterprise: A yearly subscription is required for production environments.
- Features: Up to ~1000x speedup on Blackwell/Hopper GPUs, zero-copy pinned memory, multi-GPU scalability, and priority SYCL kernel support.
For enterprise trial keys, support, and pricing, contact: info@fluidgeollc.com
Installation
H3-Turbo is available on PyPI and comes with pre-compiled "fat" wheels for Linux (CUDA 12.x) supporting NVIDIA Ampere, Ada Lovelace, Hopper, and Blackwell architectures.
pip install h3-turbo
Hardware Initialization & Verification
Before executing large workloads, verify that your SYCL acceleration backend is correctly recognized and warm up the JIT compiler.
import h3_turbo
# 1. Check version (consistent with pyproject.toml)
print(f"H3 Turbo Version: {getattr(h3_turbo, '__version__', 'unknown')}")
# 2. Query active SYCL device
device = h3_turbo.device_name() # or h3_turbo.get_device_name()
print(f"Active Compute Device: {device}")
# 3. Warm up JIT compiler
h3_turbo.warmup()
print("JIT compilation warmed up and ready!")
Python API Reference
H3-Turbo functions are optimized for high-throughput batch operations on NumPy arrays.
1. Lat/Lon to Cell Conversion
Convert coordinates (lats, lons) to H3 cell indexes at a specific resolution.
import numpy as np
lats = np.random.uniform(37.7, 37.8, 1_000_000)
lngs = np.random.uniform(-122.5, -122.4, 1_000_000)
resolution = 9
# Returns a uint64 array of H3 indices
cells = h3_turbo.latlng_to_cell(lats, lngs, resolution)
2. Cell to Parent
Find the parent cells at a coarser resolution.
parent_res = 5
parents = h3_turbo.cell_to_parent(cells, parent_res)
3. Grid Disk (k-ring)
Compute the grid disk of radius k around cell(s). Supports both scalar origins and batch arrays.
# Scalar origin: returns 1D array of cells
single_disk = h3_turbo.grid_disk(0x8928308280fffff, k=2)
# Batch array: returns a 2D (N, max_k_size) array padded with 0s
disks = h3_turbo.grid_disk(cells, k=2)
4. Cell to Boundary
Get the lat/lng boundary coordinates of cells.
# Returns an (N, 7, 2) array of [lat, lng] boundary vertices
boundaries = h3_turbo.cell_to_boundary(cells)
# Unoptimized 10-vertex boundary layout (for specific legacy compatibility)
boundaries_10 = h3_turbo.cell_to_boundary_10(cells)
5. Spatial Join (Point-in-Polygon / Inclusion Check)
Check if points (pings) are within a set of zones.
- Production Overload: Strictly 3 parameters, running at maximum GPU performance (no scramble).
- Benchmarking Overload: Includes the optional
scramble_iterationsparameter (e.g., set to50for matching baseline/benchmark scrambles).
zones = np.array([0x8928308280fffff], dtype=np.uint64)
# 1. Production usage (no scramble_iterations needed)
mask = h3_turbo.spatial_join(cells, zones, resolution=9)
# 2. Benchmarking / verification usage
mask_bench = h3_turbo.spatial_join(cells, zones, resolution=9, scramble_iterations=50)
6. Persistent Joiner (Advanced Spatial Join)
For high-frequency point-in-polygon queries, avoid rebuilding the spatial index on every call by reusing a persistent instance. Use this when running many spatial join queries on the same set of zones.
# 1. Production usage (no scramble_iterations needed)
joiner = h3_turbo.PersistentJoiner(zones, resolution=9)
# 2. Benchmarking / verification usage
joiner_bench = h3_turbo.PersistentJoiner(zones, resolution=9, scramble_iterations=50)
# Run multiple joins efficiently
results = np.zeros(len(cells), dtype=np.uint8)
joiner.join(cells, results)
7. Batch Transform
In-place GPU resolution transformation of an array of H3 indices.
cells_to_transform = cells.copy()
# 1. Production usage (no scramble_iterations needed)
h3_turbo.batch_transform(cells_to_transform, res=8)
# 2. Benchmarking / verification usage
h3_turbo.batch_transform(cells_to_transform, res=8, scramble_iterations=50)
8. System Control & Cleanup
# Set your enterprise license key to unlock full performance
h3_turbo.set_license_key("YOUR_LICENSE_KEY")
# Manually release internal GPU queue and SYCL resources
h3_turbo.cleanup()
Spark / Databricks Integration
H3-Turbo provides high-throughput Pandas UDFs for PySpark, enabling distributed GPU execution.
import os
import sys
from pyspark.sql import SparkSession
from pyspark.sql.functions import col
# Ensure workers run in the environment containing pyarrow and h3_turbo
os.environ["PYSPARK_PYTHON"] = sys.executable
os.environ["PYSPARK_DRIVER_PYTHON"] = sys.executable
from spark_h3_turbo import (
latlng_to_cell_udf,
cell_to_parent_udf,
grid_disk_udf,
spatial_join_udf,
persistent_spatial_join_udf,
batch_transform_udf
)
spark = SparkSession.builder.appName("H3-Turbo-Spark").getOrCreate()
# 1. Lat/Lon to Cell
df = df.withColumn("h3", latlng_to_cell_udf(resolution=9)(col("lat"), col("lon")))
# 2. Cell to Parent
df = df.withColumn("parent", cell_to_parent_udf(parent_res=5)(col("h3")))
# 3. Grid Disk
df = df.withColumn("kring", grid_disk_udf(k=2)(col("h3")))
# 4. Spatial Join (Broadcast / Inclusion Check)
# Use spatial_join_udf for simple one-off queries
zones_list = [0x8928308280fffff]
df = df.withColumn("in_zone", spatial_join_udf(zones_list, res=9)(col("h3")))
# Use persistent_spatial_join_udf for large datasets. It caches the GPU spatial
# index once per PySpark worker process and reuses it across all partition batches,
# preventing index rebuild overhead.
df = df.withColumn("in_zone_persistent", persistent_spatial_join_udf(zones_list, res=9)(col("h3")))
# 5. Batch Transform
df = df.withColumn("transformed_h3", batch_transform_udf(res=8)(col("h3")))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file h3_turbo-0.1.14.tar.gz.
File metadata
- Download URL: h3_turbo-0.1.14.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e27865fde877dde27d300c06b237ded63429450e1ae36071211c908bd68ccf6c
|
|
| MD5 |
ce819d8ff0adf2da0e2f0b94119a8922
|
|
| BLAKE2b-256 |
ba5e0aabfb40f908ca3e4d00366a8ad0ecaacd9e9624a2aa2c88682dff0777d7
|
File details
Details for the file h3_turbo-0.1.14-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: h3_turbo-0.1.14-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 52.1 MB
- Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de6d109b38dad25142d98fd106676e2a4f9c153329db1b450ac0cce0f2aa1a27
|
|
| MD5 |
bc3669269398d9d1a95e5ca2e063fc01
|
|
| BLAKE2b-256 |
70ea4caee0ff49f9a518f8f9eca5f9ddd2274590fd884b6fdf7582df0ccfcec8
|
File details
Details for the file h3_turbo-0.1.14-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: h3_turbo-0.1.14-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 52.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
454d3dad00c87982b03b1ca7aec790c6c466097ad4b2ba7f401b7bb7333ce3a1
|
|
| MD5 |
52a986f803bfdaad9fd59267113a554f
|
|
| BLAKE2b-256 |
935e325bbafcc988fb7b6d5a75a40e3732eda6b201f030fe923b754666894d54
|
File details
Details for the file h3_turbo-0.1.14-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: h3_turbo-0.1.14-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 52.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7129a5b6e838286274147b4cb305bb2e07a31c78381b333c3e6dafc8cf3d2e6
|
|
| MD5 |
d019a08488f063921592fc036b762b74
|
|
| BLAKE2b-256 |
ab2d8a7b8cd0ee5f05d9ed87ca1fc9266c4f109295f6ef2161f4e44eb4e4233b
|
File details
Details for the file h3_turbo-0.1.14-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: h3_turbo-0.1.14-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 52.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0bd3fa19d0af36dc3c66712a550e1055125d0e04f0643bc873d2ece1b73367c
|
|
| MD5 |
6759a28f684fecc1d97886d485d544e8
|
|
| BLAKE2b-256 |
1016d58c73a79a83afc4b2bf8255a2bbe6bcdc635346d90ff73c19a33943d909
|