gpudb
GPU-accelerated analytical operators for DuckDB on NVIDIA CUDA and Apple Silicon Metal. First SQL execution engine that targets Apple Silicon GPUs.
Maintainer(s): singhpratech
Installing and Loading
INSTALL gpudb FROM community;LOAD gpudb;Example
LOAD gpudb;-- Drop-in aggregates (BIGINT and DOUBLE overloads)SELECT gpu_sum(value::BIGINT) FROM range(1000000) AS t(value);
-- Verify against native sumSELECT gpu_sum(value::BIGINT) AS gpu, sum(value::BIGINT) AS nativeFROM range(1000000) AS t(value);About gpudb
gpudb adds drop-in aggregate functions:
gpu_sum(BIGINT | DOUBLE)gpu_min(BIGINT | DOUBLE)gpu_max(BIGINT | DOUBLE)
Smaller integer types (INTEGER, SMALLINT, TINYINT) widen implicitly
to the BIGINT overload. All three work in plain aggregation, GROUP BY,
and window frames (OVER (), OVER (ORDER BY ...),
OVER (PARTITION BY ... ORDER BY ...)), and match native DuckDB
semantics: empty input and all-NULL groups return SQL NULL (v0.2.0),
and the DOUBLE min/max overloads use the same NaN-aware total order as
native DuckDB — NaN sorts greatest (v0.3.0).
v0.3.0 replaces the buffered v0.1.x aggregate path with streaming accumulator states. End-to-end queries through the SQL aggregates now run at parity with native DuckDB (1.00–1.20× on rewritten TPC-H queries), where v0.1.x could be substantially slower on the same queries. DuckDB feeds aggregates pre-grouped 2048-row chunks, so the SQL aggregate path deliberately streams running accumulators instead of round-tripping chunks through the GPU.
The GPU backends (CUDA on NVIDIA sm_70+, Metal on Apple Silicon M1+) power the operator-level engine and benchmark tooling that ship in the source tree, where whole columns are resident on the device. Headline operator-level results, all traceable to rows in the project’s append-only BENCHMARK.md with reproduction steps:
- Apple M4 Max vs DuckDB CPU 16-thread: multi-aggregate fusion over TPC-H SF10 columns 9.7×–25.5×; SF10 GROUP BY at 1.35M unique keys 3.9×; honest loss documented at 50 unique keys (CPU 14× faster, structural).
- NVIDIA RTX 4090: resident-column SUM ~17.9×; GROUP BY 50M rows × 10M unique groups 13.7× (vs single-thread CPU baseline).
Community-extension binaries are built without the CUDA toolchain for now (full Metal path on Apple Silicon; clean CPU fallback on Linux); build from source for the CUDA backend. If no GPU is available the extension falls back cleanly — same SQL surface either way.
Source: https://github.com/singhpratech/duckdbgpumetaldbram
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| gpu_max | aggregate | NULL | NULL | |
| gpu_min | aggregate | NULL | NULL | |
| gpu_sum | aggregate | NULL | NULL |
Overloaded Functions
This extension does not add any function overloads.
Added Types
This extension does not add any types.
Added Settings
This extension does not add any settings.