Add gpudb — GPU-accelerated DuckDB on CUDA + Apple Silicon Metal#1898
Open
singhpratech wants to merge 7 commits into
Open
Add gpudb — GPU-accelerated DuckDB on CUDA + Apple Silicon Metal#1898singhpratech wants to merge 7 commits into
singhpratech wants to merge 7 commits into
Conversation
gpudb adds gpu_sum / gpu_min / gpu_max aggregate operators that DuckDB transparently dispatches to the GPU when one is available, with a hybrid CPU/GPU planner that picks the backend for each cardinality regime. Notable: this is the first published SQL execution engine that targets Apple Silicon GPUs via Metal (Sirius CIDR 2026 and cuDF are CUDA-only). The extension auto-selects backend at load time and falls back to CPU cleanly when no GPU is present. Source: https://github.com/singhpratech/duckdbgpumetaldbram Pinned ref: v0.1.1 = f0be207946084505aaaadd6e08345b412e8e8eb7 License: Apache-2.0
singhpratech
added a commit
to singhpratech/duckdbgpumetaldbram
that referenced
this pull request
May 10, 2026
Match the version submitted to duckdb/community-extensions#1898. Two specific corrections versus the prior text: 1. CUDA 21.8× was listed for "500M × 1M groups" — that scale-cell actually shows Metal 4.89× and CUDA at ~4.44× (BENCHMARK.md L88). The 21.8× CUDA result lives at 50M × 10M groups (L1347). 2. CUDA 4.8× was listed for "TPC-H SF1 GROUP BY" — the BENCHMARK.md SF1 GROUP BY re-bench (L40) shows Metal 1.93× with no comparable CUDA cell at the same baseline. Removed pending re-bench. Other numbers (Metal 5.28× SUM 1B, Metal 4.89× GROUP BY 500M×1M, Metal 2.08× TPC-H SF1) all map to specific cells and are kept. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
v0.1.1 had a launch-day install blocker: the C entry symbol was named gpudb_duckdb_init_c_api but DuckDB looks up <extension_name>_init_c_api, where extension name = "gpudb". This produced "did not contain function gpudb_init_c_api: undefined symbol" on every LOAD. v0.1.2 (sha 87e70adc) renames the entry to gpudb_init_c_api and wires duckdb/extension-ci-tools' append_extension_metadata.py into the build so the .duckdb_extension is produced with a proper footer. Verified: `duckdb -unsigned -c "LOAD '...'"` now works on RTX 4090 (CUDA) and M4 Max (Metal); gpu_sum/min/max/GROUP BY/OVER() all match native sum/min/max output.
Updates description.yml from v0.1.2 single-thread baseline to v0.1.3 multi-thread baseline (DuckDB CLI default, 16 threads on M4 Max). The most-attacked workload — TPC-H SF10 GROUP BY l_orderkey at 15M unique groups — was 1.78x slower than DuckDB CPU multi-thread in v0.1.2. v0.1.3 ships a 32K-partition slot-lock hash aggregate that flips it to 1.30x faster. SF1 GROUP BY l_orderkey (1.5M unique) goes from a draw to 1.40x. Multi-aggregate fusion wins (25.5x / 22.0x / 9.7x) are unchanged. Repo ref pinned to v0.1.3 = 3ebcd764d28d16848cb11c49ad85d2a93819747d. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…hon3 toolchain - ref -> ae4bd9cd80e (feat/ext-community-ci-scaffold): adds the root Makefile (c_api_extensions template), vendored C-API headers, and a loadable-extension build that needs no libduckdb — fixes 'No rule to make target set_duckdb_version' - requires_toolchains: python3 (c_api makefiles use a venv, capi_quack precedent) - excluded_platforms: add windows_amd64 (Linux + macOS only for v0.1.x) - restore hardware_requirements / known_limitations keys dropped in the original submission Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…mpty file) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
|
Hi maintainers 👋 — the earlier This exact workflow (DuckDB v1.5.2, ci-tools Could you approve the workflow run when you get a chance? Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the gpudb community extension (now at v0.1.3).
What it does
gpudb registers
gpu_sum,gpu_min,gpu_maxaggregate operators that DuckDB transparently dispatches to the GPU. Two backends share one codebase:A hybrid CPU/GPU planner picks the backend per cardinality regime. CPU fallback is automatic when no GPU is present.
What's new in v0.1.3 (since the original PR)
Hybrid Metal GROUP BY that auto-dispatches between two paths per query:
atomic_fetch_add). Sweet spot:expected_groups ∈ [1024, 16M].ulong4loads, in-block 8-bit multi-split scatter via simdgroup prefix-sum. For very low or very high cardinality.Env override:
GPUDB_METAL_GROUPBY_PATH=slotlock|radixto force a path.This flipped the most-attacked workload — TPC-H SF10 GROUP BY
l_orderkeyat 15M unique groups — from CPU 1.78× faster (v0.1.2) to Metal 1.30× faster.Why it's interesting
Verified numbers — Apple Silicon (M4 Max) vs DuckDB CPU 16-thread
The DuckDB CLI uses 16 threads by default on M4 Max — these comparisons are vs that real default, not single-thread. Each row is pinned to a specific BENCHMARK.md cell; no cross-cell glue.
l_quantityl_extendedpricel_orderkeyl_quantityHOTl_extendedprice(1.35M unique)l_orderkey(1.5M unique)l_orderkey(15M unique)l_quantity(50 unique)9 wins, 1 honest loss documented. The loss is structural — the CPU's hash table fits in L1 cache for ≤ 1K unique groups; no GPU implementation can beat it, and the auto-dispatcher routes those workloads to the radix path anyway.
Verified numbers — NVIDIA RTX 4090 (vs single-thread CPU baseline)
Source / details
3ebcd764d28d16848cb11c49ad85d2a93819747dscripts/local_check.shAuthor note
Solo project; happy to iterate on description, build harness, or excluded_platforms list if anything in the standard CI workflow doesn't fit. The extension is built via CMake from
src/extension/duckdb_loadable.cppagainst pre-builtlibduckdb-libs/.