You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GPU Dataframe experience report, and engine selection above the command graph
#3316
Thanks @ibgreen for the pointer to GPU Dataframe. I wired it into my planner this week and wanted to report back with numbers, then float one design idea.
What I did
duckdb-deck-demo places each node of a graph in DuckDB SQL, a JS loop or a fused WGSL kernel, based on a calibrated cost model. A GPU filter there could only be a discard mask. GPU Dataframe's compacted rowIndices plus a GPU-resident selectedCounts fill exactly that gap. I run luma's filter over my existing GPUBuffers on my existing GPUDevice (new WebGPUDevice(props, device, adapter, info) plus Buffer({handle}), which works around attach() until #3313 lands). The planner can now choose "GPU compaction" as a placement (FINDINGS §12).
luma 9.4.2, Apple Metal-3, v > cut feeding a point draw, median of 9, with every engine's count checked against the CPU:
4M rows, 5% kept
update (slider tick → drained frame)
frame
requery DuckDB + re-upload
31.6 ms
0.31 ms
our kernel, discard mask
6.2 ms
5.3 ms
GPU Dataframe → drawIndirect
1.8 ms
0.30 ms
Two findings worth your attention:
Batch topology dominates. The same 4M rows as 1954 × 2048-row batches (DuckDB-Wasm's size, as zero-copy views of one buffer) cost 90 ms per filter and 2.4 s to compile, against 1.6 ms and 27 ms as one batch. I'm preparing an @luma.gl/arrow PR for packed ingest, plus a PR or issue on the per-batch cost. Links to follow.
The expression language is the limit, and that's fine. With no functions, %, vectors or conditionals, GPU Dataframe is a filter engine beside our kernels rather than a replacement. The planner encodes that as a capability check.
The design idea: the command graph picks kernels; something above it should pick engines
GPUCommandGraphAutotuner already does adapter-keyed, persisted timing for choosing between equivalent kernels (operation × variant × workload bucket). My planner does the same thing one level up, choosing between equivalent engines (SQL vs JS vs WGSL kernel vs GPU compaction). It uses constants calibrated at startup by measuring at two sizes and taking the slope (calibrate.ts), because hand-derived constants were off by up to 32×.
Two things luma could make easier:
Profiles as a cost source. If GPUCommandGraphAutotuningProfile calibrations were queryable ("mean ms per row for operation X at about N rows"), a planner above luma could price GPU Dataframe candidates from luma's own measurements instead of keeping a second set of constants. My compaction constants are currently hardcoded from one machine, which is the weakest part of the model.
Limits as constraints, not errors. The planner treats maxStorageBuffersPerShaderStage as a hard constraint on each candidate. On a device at WebGPU defaults it moves a filter out of the fused kernel so the kernel fits in 8 bindings. GPU Dataframe already validates binding and batch capacity (validateGPUQueryBindingCapacity). GPUCommandGraphPreflightReport is nearly the right shape: per-node workload estimates, readByteLength/writeByteLength, maximum invocations. But it only exists on the compiled graph, and compile costs 27 ms to 2.4 s here. A planner pricing five candidates can't compile all five. If the same report were available from an uncompiled query plan, even as an estimate, a planner could reject over-limit candidates and price the rest before paying for compile.
Questions
Is GPUDataFrameQuery intended to gain a cost or size estimate before compile, for example rows in, estimated passes and bytes? That's the hook a planner needs.
Would you take a small explain() on compiled queries, listing passes, dispatches per batch and bytes, in the spirit of loaders.gl's explain output?
Longer term: is GPU SQL meant to be the front end, or is a lowering from loaders.gl's ColumnarPredicate (Tranche 9) the intended path? I've posted there too and would like the two to meet in the middle.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Thanks @ibgreen for the pointer to GPU Dataframe. I wired it into my planner this week and wanted to report back with numbers, then float one design idea.
What I did
duckdb-deck-demo places each node of a graph in DuckDB SQL, a JS loop or a fused WGSL kernel, based on a calibrated cost model. A GPU filter there could only be a discard mask. GPU Dataframe's compacted
rowIndicesplus a GPU-residentselectedCountsfill exactly that gap. I run luma's filter over my existingGPUBuffers on my existingGPUDevice(new WebGPUDevice(props, device, adapter, info)plusBuffer({handle}), which works aroundattach()until #3313 lands). The planner can now choose "GPU compaction" as a placement (FINDINGS §12).luma 9.4.2, Apple Metal-3,
v > cutfeeding a point draw, median of 9, with every engine's count checked against the CPU:drawIndirectTwo findings worth your attention:
@luma.gl/arrowPR for packed ingest, plus a PR or issue on the per-batch cost. Links to follow.%, vectors or conditionals, GPU Dataframe is a filter engine beside our kernels rather than a replacement. The planner encodes that as a capability check.The design idea: the command graph picks kernels; something above it should pick engines
GPUCommandGraphAutotuneralready does adapter-keyed, persisted timing for choosing between equivalent kernels (operation × variant × workload bucket). My planner does the same thing one level up, choosing between equivalent engines (SQL vs JS vs WGSL kernel vs GPU compaction). It uses constants calibrated at startup by measuring at two sizes and taking the slope (calibrate.ts), because hand-derived constants were off by up to 32×.Two things luma could make easier:
GPUCommandGraphAutotuningProfilecalibrations were queryable ("mean ms per row for operation X at about N rows"), a planner above luma could price GPU Dataframe candidates from luma's own measurements instead of keeping a second set of constants. My compaction constants are currently hardcoded from one machine, which is the weakest part of the model.maxStorageBuffersPerShaderStageas a hard constraint on each candidate. On a device at WebGPU defaults it moves a filter out of the fused kernel so the kernel fits in 8 bindings. GPU Dataframe already validates binding and batch capacity (validateGPUQueryBindingCapacity).GPUCommandGraphPreflightReportis nearly the right shape: per-node workload estimates,readByteLength/writeByteLength, maximum invocations. But it only exists on the compiled graph, and compile costs 27 ms to 2.4 s here. A planner pricing five candidates can't compile all five. If the same report were available from an uncompiled query plan, even as an estimate, a planner could reject over-limit candidates and price the rest before paying for compile.Questions
GPUDataFrameQueryintended to gain a cost or size estimate before compile, for example rows in, estimated passes and bytes? That's the hook a planner needs.explain()on compiled queries, listing passes, dispatches per batch and bytes, in the spirit of loaders.gl's explain output?ColumnarPredicate(Tranche 9) the intended path? I've posted there too and would like the two to meet in the middle.All reactions