Skip to content

Commit 00abf60

Browse files
bench: run the full compress suite under --gpu-decompress (#9399)
Co-authored-by: Claude <[email protected]> Signed-off-by: Joe Isaacs <[email protected]>
1 parent fe6fe3b commit 00abf60

17 files changed

Lines changed: 781 additions & 45 deletions

File tree

‎benchmarks/compress-bench/README.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ rendered before the failure summary, so a dataset the GPU cannot decode still le
117117
the matrix with numbers — the process exits non-zero either way.
118118

119119
The dataset list in `src/main.rs` therefore holds only datasets a `--gpu-verify` run has confirmed.
120-
Several others are waiting on `vortex-cuda` kernel gaps (`u16` in `date_time_parts`, a
121-
`vortex.masked` kernel, and a CPU fallback reached with device-resident buffers); they are listed
122-
with their reasons next to `gpu_datasets`. Add one there once its gap is closed and verification
123-
passes.
120+
It now covers the whole compress suite: the kernel gaps that kept `taxi`, `Arade`, `CMSprovider`,
121+
`Euro2016`, `HashTags` and the `StructListOfInts` wide tables off it — `u16` components in
122+
`date_time_parts`, per-element `RunEnd` validity, and missing `vortex.masked` and `vortex.list`
123+
kernels — have since been closed. Add a new dataset there once verification passes.
124+
125+
`airquality` and `rplace` download from pcodec's public bucket, which the CPU suite skips to avoid
126+
creating egress charges for pcodec. The GPU suite runs every entry on its explicit list, so both
127+
are fetched on each GPU run.

‎benchmarks/compress-bench/src/main.rs‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -241,24 +241,23 @@ async fn run_compress(
241241

242242
// Datasets run in GPU mode. Add one only after a `--gpu-verify` run has confirmed its CUDA
243243
// decode end to end; a dataset here that cannot decode fails the benchmark job. Between them
244-
// these cover FSST strings, bit-packed numerics and columns with nulls.
245-
//
246-
// Not yet listed, each blocked on a `vortex-cuda` gap rather than on the benchmark:
247-
//
248-
// - `taxi` and `Arade`: `Unsupported ptype u16`. The CUDA `date_time_parts` kernel dispatches
249-
// with `match_each_signed_integer_ptype!` where the CPU canonicaliser uses
250-
// `match_each_integer_ptype!`. Widening the fused kernel takes 4³ = 64 PTX instantiations
251-
// to 8³ = 512, so it is not a free change.
252-
// - `Euro2016` and `HashTags`: `No CUDA kernel for encoding vortex.masked`.
253-
// - `CMSprovider`: `expected host buffer` — a CPU fallback is reached with device-resident
254-
// buffers, which `CudaArrayExt::execute_cuda` refuses.
255-
// - `StructListOfInts`: its list layouts have no verified CUDA decode path.
256-
let gpu_datasets: [&dyn Dataset; 4] = [
244+
// these cover FSST strings, bit-packed numerics, timestamps, columns with nulls, and lists.
245+
let gpu_datasets: Vec<&dyn Dataset> = [
257246
&TPCHLCommentCanonical as &dyn Dataset,
258247
&TPCHLCommentChunked,
248+
&TaxiData,
249+
PBI_DATASETS.get(Arade),
259250
PBI_DATASETS.get(Bimbo),
251+
PBI_DATASETS.get(CMSprovider),
252+
PBI_DATASETS.get(Euro2016),
260253
PBI_DATASETS.get(Food),
261-
];
254+
PBI_DATASETS.get(HashTags),
255+
&DownloadableDataset::AirQuality,
256+
&DownloadableDataset::RPlace,
257+
]
258+
.into_iter()
259+
.chain(structlistofints.iter().map(|d| d as &dyn Dataset))
260+
.collect();
262261

263262
let all_datasets: Vec<&dyn Dataset> = [
264263
&TaxiData as &dyn Dataset,
@@ -283,14 +282,17 @@ async fn run_compress(
283282
.collect();
284283

285284
let datasets: Vec<&dyn Dataset> = if mode.is_gpu() {
286-
gpu_datasets.to_vec()
285+
gpu_datasets
287286
} else {
288287
all_datasets
289288
}
290289
.into_iter()
291290
.filter(|d| {
292291
if let Some(filter) = datasets_filter.as_ref() {
293292
filter.is_match(d.name())
293+
} else if mode.is_gpu() {
294+
// The GPU suite is an explicit list, so every entry on it runs.
295+
true
294296
} else {
295297
// These download data from pcodec's public bucket, presumably creating egress charges
296298
// for pcodec. As such, we do not run in CI.

‎encodings/onpair/src/array.rs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,27 @@ fn build_dictionary(
232232
.map_err(|e| vortex_err!(InvalidArgument: "Unsafe OnPair dictionary: {e}"))
233233
}
234234

235+
/// A safety-validated dictionary built from host-materialized parts, owned
236+
/// independently of any array.
237+
///
238+
/// [`dict_view`] reaches the same parts through host-only accessors, which panics when
239+
/// the array's buffers are device-resident. Callers that have already copied the
240+
/// dictionary blob and its widened offsets to the host — the CUDA executor, which stages
241+
/// the dictionary on the host regardless — build through this instead.
242+
pub struct OnPairDictionary(CompactDictionary<OnPairDictionaryStorage>);
243+
244+
impl OnPairDictionary {
245+
/// Validates `(bytes, offsets)` and seals them into a dictionary.
246+
pub fn try_new(bytes: ByteBuffer, offsets: Buffer<u32>) -> VortexResult<Self> {
247+
Ok(Self(build_dictionary(bytes, offsets)?))
248+
}
249+
250+
/// Borrows the dictionary as a view.
251+
pub fn as_view(&self) -> CompactDictionaryView<'_> {
252+
self.0.as_view()
253+
}
254+
}
255+
235256
/// A safety-validated [`CompactDictionaryView`] over `array`'s dictionary.
236257
///
237258
/// The first successful initialization widens the `dict_offsets` child and

‎vortex-btrblocks/src/builder.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ impl BtrBlocksCompressorBuilder {
175175
float::ALPRDScheme.id(),
176176
float::FloatRLEScheme.id(),
177177
float::NullDominatedSparseScheme.id(),
178+
string::NullDominatedSparseScheme.id(),
178179
string::StringDictScheme.id(),
179180
binary::BinaryDictScheme.id(),
180181
];
@@ -270,6 +271,22 @@ mod tests {
270271
);
271272
}
272273

274+
/// `vortex.sparse` has no CUDA decode kernel, so no sparse scheme may survive this preset.
275+
#[test]
276+
fn cuda_compatible_excludes_every_sparse_scheme() {
277+
let builder = BtrBlocksCompressorBuilder::default().only_cuda_compatible();
278+
for excluded in [
279+
integer::SparseScheme.id(),
280+
float::NullDominatedSparseScheme.id(),
281+
string::NullDominatedSparseScheme.id(),
282+
] {
283+
assert!(
284+
!builder.schemes.iter().any(|s| s.id() == excluded),
285+
"{excluded} should be excluded"
286+
);
287+
}
288+
}
289+
273290
#[test]
274291
fn cuda_compatible_uses_fsst_for_strings() {
275292
let builder = BtrBlocksCompressorBuilder::default().only_cuda_compatible();

‎vortex-cuda/kernels/src/date_time_parts.cu‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,34 @@ __device__ void date_time_parts(const DaysT *__restrict days,
4343
}
4444

4545
#define EXPAND_DAYS(X) \
46+
X(u8, uint8_t) \
47+
X(u16, uint16_t) \
48+
X(u32, uint32_t) \
49+
X(u64, uint64_t) \
4650
X(i8, int8_t) \
4751
X(i16, int16_t) \
4852
X(i32, int32_t) \
4953
X(i64, int64_t)
5054

5155
#define EXPAND_SUBSECONDS(d, DT, s, ST) \
56+
GENERATE_DATE_TIME_PARTS_KERNEL(d, DT, s, ST, u8, uint8_t) \
57+
GENERATE_DATE_TIME_PARTS_KERNEL(d, DT, s, ST, u16, uint16_t) \
58+
GENERATE_DATE_TIME_PARTS_KERNEL(d, DT, s, ST, u32, uint32_t) \
59+
GENERATE_DATE_TIME_PARTS_KERNEL(d, DT, s, ST, u64, uint64_t) \
5260
GENERATE_DATE_TIME_PARTS_KERNEL(d, DT, s, ST, i8, int8_t) \
5361
GENERATE_DATE_TIME_PARTS_KERNEL(d, DT, s, ST, i16, int16_t) \
5462
GENERATE_DATE_TIME_PARTS_KERNEL(d, DT, s, ST, i32, int32_t) \
5563
GENERATE_DATE_TIME_PARTS_KERNEL(d, DT, s, ST, i64, int64_t)
5664

5765
#define EXPAND_SECONDS(d, DT) \
66+
EXPAND_SUBSECONDS(d, DT, u8, uint8_t) \
67+
EXPAND_SUBSECONDS(d, DT, u16, uint16_t) \
68+
EXPAND_SUBSECONDS(d, DT, u32, uint32_t) \
69+
EXPAND_SUBSECONDS(d, DT, u64, uint64_t) \
5870
EXPAND_SUBSECONDS(d, DT, i8, int8_t) \
5971
EXPAND_SUBSECONDS(d, DT, i16, int16_t) \
6072
EXPAND_SUBSECONDS(d, DT, i32, int32_t) \
6173
EXPAND_SUBSECONDS(d, DT, i64, int64_t)
6274

63-
// Generate all 64 kernels (4³)
75+
// Generate all 512 kernels (8³: every signed and unsigned integer width per component)
6476
EXPAND_DAYS(EXPAND_SECONDS)

‎vortex-cuda/kernels/src/list.cu‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
#include "config.cuh"
5+
#include "types.cuh"
6+
7+
// Converts Arrow-style `List` offsets into `ListView` offset/size pairs.
8+
//
9+
// `List` stores `list_len + 1` monotonically increasing offsets; a `ListView` stores one offset
10+
// and one size per list. Both outputs are written by the same thread so the two views of a list
11+
// are always produced together.
12+
template <typename OffsetT>
13+
__device__ void list_views(const OffsetT *const __restrict offsets,
14+
OffsetT *const __restrict out_offsets,
15+
OffsetT *const __restrict out_sizes,
16+
uint64_t list_len) {
17+
const uint32_t elements_per_block = blockDim.x * ELEMENTS_PER_THREAD;
18+
const uint64_t block_start = static_cast<uint64_t>(blockIdx.x) * elements_per_block;
19+
const uint64_t block_end = min(block_start + elements_per_block, list_len);
20+
21+
for (uint64_t idx = block_start + threadIdx.x; idx < block_end; idx += blockDim.x) {
22+
const OffsetT start = offsets[idx];
23+
out_offsets[idx] = start;
24+
out_sizes[idx] = static_cast<OffsetT>(offsets[idx + 1] - start);
25+
}
26+
}
27+
28+
#define GENERATE_LIST_VIEWS_KERNEL(offset_suffix, OffsetT) \
29+
extern "C" __global__ void list_views_##offset_suffix(const OffsetT *const __restrict offsets, \
30+
OffsetT *const __restrict out_offsets, \
31+
OffsetT *const __restrict out_sizes, \
32+
uint64_t list_len) { \
33+
list_views<OffsetT>(offsets, out_offsets, out_sizes, list_len); \
34+
}
35+
36+
FOR_EACH_INTEGER(GENERATE_LIST_VIEWS_KERNEL)

‎vortex-cuda/kernels/src/runend.cu‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,45 @@ __device__ void runend_decode_kernel(const EndsT *const __restrict ends,
127127
}
128128
}
129129

130+
// Expands run-end encoded validity bits into a packed output bitmap.
131+
//
132+
// Mirrors `runend_decode_kernel`, but each thread owns one complete output byte so that
133+
// threads never race on bits within the same byte. Runs are located with a global binary
134+
// search per element rather than the shared-memory cache: validity expansion runs once per
135+
// array and is not the decode hot path.
136+
template <typename EndsT>
137+
__device__ void runend_bool_kernel(const EndsT *const __restrict ends,
138+
uint64_t num_runs,
139+
const uint8_t *const __restrict values,
140+
uint64_t values_bit_offset,
141+
uint64_t offset,
142+
uint64_t output_len,
143+
uint8_t *const __restrict output) {
144+
const uint64_t output_bytes = (output_len + 7) / 8;
145+
const uint32_t elements_per_block = blockDim.x * ELEMENTS_PER_THREAD;
146+
const uint64_t block_start = static_cast<uint64_t>(blockIdx.x) * elements_per_block;
147+
const uint64_t block_end = min(block_start + elements_per_block, output_bytes);
148+
149+
for (uint64_t byte_idx = block_start + threadIdx.x; byte_idx < block_end; byte_idx += blockDim.x) {
150+
const uint64_t row_start = byte_idx * 8;
151+
uint8_t packed = 0;
152+
#pragma unroll
153+
for (uint32_t bit = 0; bit < 8; ++bit) {
154+
const uint64_t row = row_start + bit;
155+
if (row < output_len) {
156+
uint64_t run_idx = upper_bound(ends, num_runs, row + offset);
157+
if (run_idx >= num_runs) {
158+
run_idx = num_runs - 1;
159+
}
160+
const uint64_t value_idx = values_bit_offset + run_idx;
161+
const uint8_t value = (values[value_idx / 8] >> (value_idx % 8)) & 1;
162+
packed |= static_cast<uint8_t>(value << bit);
163+
}
164+
}
165+
output[byte_idx] = packed;
166+
}
167+
}
168+
130169
#define GENERATE_RUNEND_KERNEL(value_suffix, ValueType, ends_suffix, EndsType) \
131170
extern "C" __global__ void runend_##value_suffix##_##ends_suffix( \
132171
const EndsType *const __restrict ends, \
@@ -155,3 +194,21 @@ GENERATE_RUNEND_KERNELS_FOR_VALUE(i64, int64_t)
155194
GENERATE_RUNEND_KERNELS_FOR_VALUE(f16, __half)
156195
GENERATE_RUNEND_KERNELS_FOR_VALUE(f32, float)
157196
GENERATE_RUNEND_KERNELS_FOR_VALUE(f64, double)
197+
198+
#define GENERATE_RUNEND_BOOL_KERNEL(ends_suffix, EndsType) \
199+
extern "C" __global__ void runend_bool_##ends_suffix(const EndsType *const __restrict ends, \
200+
uint64_t num_runs, \
201+
const uint8_t *const __restrict values, \
202+
uint64_t values_bit_offset, \
203+
uint64_t offset, \
204+
uint64_t output_len, \
205+
uint8_t *const __restrict output) { \
206+
runend_bool_kernel<EndsType>(ends, num_runs, values, values_bit_offset, offset, output_len, output); \
207+
}
208+
209+
// Validity bitmaps use a different physical layout and launch unit, but dispatch over the
210+
// same run-end index types.
211+
GENERATE_RUNEND_BOOL_KERNEL(u8, uint8_t)
212+
GENERATE_RUNEND_BOOL_KERNEL(u16, uint16_t)
213+
GENERATE_RUNEND_BOOL_KERNEL(u32, uint32_t)
214+
GENERATE_RUNEND_BOOL_KERNEL(u64, uint64_t)

‎vortex-cuda/src/canonical.rs‎

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ use std::sync::Arc;
55

66
use async_trait::async_trait;
77
use futures::future::try_join_all;
8+
use vortex::array::ArrayRef;
89
use vortex::array::Canonical;
910
use vortex::array::IntoArray;
1011
use vortex::array::VortexSessionExecute;
1112
use vortex::array::arrays::BoolArray;
1213
use vortex::array::arrays::DecimalArray;
1314
use vortex::array::arrays::ExtensionArray;
15+
use vortex::array::arrays::ListViewArray;
1416
use vortex::array::arrays::PrimitiveArray;
1517
use vortex::array::arrays::StructArray;
1618
use vortex::array::arrays::VarBinViewArray;
1719
use vortex::array::arrays::bool::BoolDataParts;
1820
use vortex::array::arrays::decimal::DecimalDataParts;
1921
use vortex::array::arrays::extension::ExtensionArrayExt;
22+
use vortex::array::arrays::listview::ListViewDataParts;
2023
use vortex::array::arrays::primitive::PrimitiveDataParts;
2124
use vortex::array::arrays::struct_::StructDataParts;
2225
use vortex::array::arrays::varbinview::BinaryView;
@@ -29,6 +32,19 @@ use vortex::buffer::Buffer;
2932
use vortex::buffer::ByteBuffer;
3033
use vortex::error::VortexResult;
3134

35+
/// Copy a canonical child array to the host.
36+
async fn child_into_host(child: ArrayRef) -> VortexResult<ArrayRef> {
37+
#[expect(
38+
clippy::disallowed_methods,
39+
reason = "CanonicalCudaExt threads no session through"
40+
)]
41+
Ok(child
42+
.execute::<Canonical>(&mut legacy_session().create_execution_ctx())?
43+
.into_host()
44+
.await?
45+
.into_array())
46+
}
47+
3248
/// Move all canonical data from to_host from device.
3349
#[async_trait]
3450
pub trait CanonicalCudaExt {
@@ -102,18 +118,15 @@ impl CanonicalCudaExt for Canonical {
102118
n @ Canonical::Null(_) => Ok(n),
103119
Canonical::Bool(bool) => {
104120
let len = bool.len();
105-
let validity = bool.validity()?;
121+
let validity = validity_into_host(bool.validity()?).await?;
106122
let BoolDataParts { bits, meta } = bool.into_data().into_parts(len);
107123

108124
let bits = BitBuffer::new_with_offset(
109125
bits.try_into_host()?.await?,
110126
meta.len(),
111127
meta.offset(),
112128
);
113-
Ok(Canonical::Bool(BoolArray::new(
114-
bits,
115-
validity_into_host(validity).await?,
116-
)))
129+
Ok(Canonical::Bool(BoolArray::new(bits, validity)))
117130
}
118131
Canonical::Primitive(prim) => {
119132
let PrimitiveDataParts {
@@ -153,6 +166,7 @@ impl CanonicalCudaExt for Canonical {
153166
validity,
154167
dtype,
155168
} = varbinview.into_data_parts();
169+
let validity = validity_into_host(validity).await?;
156170

157171
// Copy all device views to host
158172
let host_views = views.try_into_host()?.await?;
@@ -167,11 +181,27 @@ impl CanonicalCudaExt for Canonical {
167181
let host_buffers = try_join_all(host_buffers).await?;
168182
let host_buffers: Arc<[ByteBuffer]> = Arc::from(host_buffers);
169183

170-
let validity = validity_into_host(validity).await?;
171184
Ok(Canonical::VarBinView(unsafe {
172185
VarBinViewArray::new_unchecked(host_views, host_buffers, dtype, validity)
173186
}))
174187
}
188+
Canonical::List(list) => {
189+
let ListViewDataParts {
190+
elements,
191+
offsets,
192+
sizes,
193+
validity,
194+
..
195+
} = list.into_data_parts();
196+
let validity = validity_into_host(validity).await?;
197+
198+
Ok(Canonical::List(ListViewArray::try_new(
199+
child_into_host(elements).await?,
200+
child_into_host(offsets).await?,
201+
child_into_host(sizes).await?,
202+
validity,
203+
)?))
204+
}
175205
Canonical::Extension(ext) => {
176206
// Copy the storage array to host and rewrap in ExtensionArray.
177207
#[expect(

0 commit comments

Comments
 (0)