Skip to content

Feature/file downgrade - #96

Merged
rapids-bot[bot] merged 44 commits into
NVIDIA:mainfrom
felipeblazing:feature/file-downgrade
Apr 14, 2026
Merged

rapids-bot[bot] merged 44 commits into
NVIDIA:mainfrom
felipeblazing:feature/file-downgrade

Conversation

@felipeblazing

Copy link
Copy Markdown
Contributor

Add the ability to downgrade files. We are still experimenting with different approaches so this isn't ready to be merged in

felipeblazing and others added 17 commits April 2, 2026 08:20
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…and idisk_io_backend headers

- Add disk_table_allocation struct mirroring host_table_allocation for disk tier
- Add disk_data_representation class with RAII file deletion
- Add idisk_io_backend abstract interface with io_backend_type enum
- Add generate_disk_file_path with atomic counter for collision-free names
- Add libkvikio to pixi.toml for both nightly and stable tracks
- Add find_package(kvikio) and PRIVATE link to cucascade_objects in CMakeLists.txt
- Register disk_data_representation.cpp and disk_file_format.cpp in src/data/CMakeLists.txt
…y serialization

- Define disk_file_header (32-byte, magic CUCS, version 1, 4KB-aligned data offset)
- Add DISK_FILE_MAGIC, DISK_FILE_FORMAT_VERSION, DISK_FILE_ALIGNMENT constants
- Add constexpr align_up utility for power-of-two alignment
- Implement recursive serialize_column_metadata and deserialize_column_metadata
- Use std::memcpy for all buffer I/O to avoid unaligned access UB
…nd factory

- Add io_backend_internal.hpp shared header for cross-TU factory declarations
- Implement kvikio_io_backend using kvikio::FileHandle pread/pwrite for host I/O
- Implement gds_io_backend stub with registered_buffer RAII type (no-op without cufile.h)
- Add make_io_backend factory dispatching KVIKIO and GDS backend types
- Register new source files in src/data/CMakeLists.txt
…rmat

- Factory tests: make_io_backend creates kvikio and gds backends
- Host I/O round-trip: write/read 4KB via kvikio backend
- Unique path generation: generate_disk_file_path produces distinct paths
- Serialization round-trip: nested column_metadata (STRUCT<STRING, LIST<INT32>>)
- Alignment utility: align_up rounds to 4KB boundaries
- Register test in test/CMakeLists.txt
…_builtin_converters overload

- Add public get_mount_path() accessor to disk_access_limiter
- Add register_builtin_converters overload accepting shared_ptr<idisk_io_backend>
- Add disk_io_backend.hpp include to representation_converter.hpp
…r in converter registry

- Add convert_host_data_to_disk: writes disk_file_header + serialized column_metadata + 4KB-aligned column data
- Add convert_disk_to_host_data: reads file, validates header, reconstructs host_table_allocation with 8-byte-aligned layout
- Add RAII disk_file_guard for partial write cleanup
- Add write_host_buffer_to_disk and read_disk_buffer_to_host helpers handling block-boundary spanning
- Add recompute_file_offsets (4KB alignment) and recompute_host_offsets (8-byte alignment) helpers
- Add write_column_buffers and read_column_buffers recursive helpers
- Add memory_space::get_disk_mount_path() for disk tier mount path access
- Modify register_builtin_converters to delegate to new overload with default KVIKIO backend
- Add register_builtin_converters overload capturing shared_ptr<idisk_io_backend> in disk converter lambdas
…ypes and null masks

- Create test/data/test_disk_host_converters.cpp with round_trip_test helper
- Add tests for all 10 numeric types, BOOL8, 5 timestamp, 5 duration, 3 decimal types
- Add null mask tests for all-null, no-null, and mixed-null patterns
- Register new test file in test/CMakeLists.txt
- Add STRING column tests (with and without nulls)
- Add LIST column tests (flat and nested LIST<LIST<INT32>>)
- Add STRUCT column tests (flat, nested, with null mask)
- Add DICTIONARY32 column round-trip test
- Add sliced column tests (with and without nulls, compact via table copy)
- Add write_gpu_column_buffers for recursive GPU->disk writes via write_device
- Add convert_gpu_to_disk for GPU table -> disk file conversion
- Add alloc_and_read_from_disk helper for disk -> GPU device buffer reads
- Add reconstruct_column_from_disk for recursive column reconstruction from disk
- Add convert_disk_to_gpu for disk file -> GPU table conversion
- All column types handled: STRING, LIST, STRUCT, DICTIONARY32, fixed-width, decimal

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rters

- Register gpu_table_representation -> disk_data_representation converter (CONV-01)
- Register disk_data_representation -> gpu_table_representation converter (CONV-02)
- All four disk converters now registered: host_data<->disk and GPU<->disk (CONV-05)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- 18 TEST_CASEs covering numeric, bool, timestamp, duration, decimal,
  null masks, string, list, struct, dictionary, and sliced columns
- Direct 3-step GPU->disk->GPU path (no host intermediate)
- Registered new test file in test/CMakeLists.txt
- Explicit kvikIO backend round-trip test via register_builtin_converters overload
- GDS backend stub throws test via REQUIRE_THROWS
- Addresses TEST-10 requirement for both backend behaviors
@felipeblazing
felipeblazing marked this pull request as draft April 2, 2026 13:22
@copy-pr-bot

copy-pr-bot Bot commented Apr 2, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

felipeblazing and others added 11 commits April 2, 2026 09:52
Synthesize findings from parallel research into stack, features,
architecture, and pitfalls analysis. The GDS backend's 11.8x throughput
gap is caused by D2D staging copies and serialized wave processing;
the kvikIO backend's 5.6x gap by single-threaded defaults. All fixes
use existing APIs with no new dependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Checks NVMe mount (/mnt/disk_2), filesystem type, and disk space
- Checks nvidia-fs kernel module and GPU BAR1 size
- Audits cufile.json configuration (per_buffer_cache_size_kb, allow_compat_mode, etc.)
- Prints PASS/WARN/FAIL status with color output and tuning recommendations
- Identifies per_buffer_cache_size_kb=1024 as too small for 4MB benchmark SLOT_SIZE
…ounters

- Change disk_config.mount_paths from /tmp to /mnt/disk_2 (NVMe SSD)
- Add gdsio hardware baseline constants (write: 6.73 GiB/s, read: 13.35 GiB/s)
- Add gdsio_write_GiBs and gdsio_read_GiBs counters to all 10 benchmark functions
- kvikIO: switch write_device/read_device from synchronous write()/read()
  to parallel pwrite()/pread() with 16-thread pool and 16MB task size.
  Use POSIX for host I/O to avoid O_DIRECT alignment issues with metadata.
- Pipeline: add configurable direct_io flag (O_DIRECT for benchmarks,
  page cache for production). Add CUDA stream ordering via events to
  prevent D2H race conditions with caller's stream.
- Add direct_io parameter to make_io_backend() factory (default false).
- Switch default backend from kvikIO to Pipeline (faster throughput).
- Fix COLUMN_METADATA_FIXED_SIZE from 56 to 60 (buffer overrun bug).
- Cast INT32 offsets to INT64 for cudf 26.06+ STRING/LIST compatibility.
- Benchmarks pass direct_io=true for accurate disk throughput measurement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Root cause: test helpers (make_typed_table, make_typed_table_with_nulls)
created columns using a local rmm::cuda_stream that was destroyed before
the returned table was freed. With cuda_async_memory_resource, cudaFreeAsync
on a destroyed stream caused undefined behavior (SIGSEGV, invalid args).

Fix: replace local streams with cudf::get_default_stream() in test helpers.

Additional converter fixes found during investigation:
- Batch copy accumulator clearing between reconstruction phases
- Stream synchronization before INT32->INT64 offset cast in batch mode
- DICTIONARY32 column support in disk round-trip
- STRUCT null mask flush before batch submission
- Recursive compound-type comparison utility for test validation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add read benchmarks for kvikIO and Pipeline backends (DiskToGpu)
- Add write+read benchmarks for all column types (numeric, string, list,
  struct) across both backends (BENCH-05)
- Fix O_DIRECT pread failure for nested columns: fall back to buffered
  I/O when file offset or size is not 512-byte aligned
- Disable GDS backend stub test (nvidia-fs not available)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@felipeblazing

Copy link
Copy Markdown
Contributor Author

/ok to test
f929395

@felipeblazing

Copy link
Copy Markdown
Contributor Author

/ok to test f929395

@felipeblazing
felipeblazing marked this pull request as ready for review April 2, 2026 21:45
felipeblazing and others added 2 commits April 2, 2026 18:00
…'t fit

- Query cudaMemGetInfo at startup, set memory manager capacity to 90%
  of available GPU memory instead of hardcoding 16 GiB
- Skip benchmarks with SkipWithMessage when data size exceeds 75% of
  free GPU memory (prevents OOM on CI with 16 GB T4 GPUs)
- Fall back to /tmp when /mnt/disk_2 is not available (CI environments)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@felipeblazing

Copy link
Copy Markdown
Contributor Author

/ok to test 0eeed86

@joosthooz joosthooz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see everything yet, but wanted to post some initial questions

Comment thread benchmark/benchmark_main.cpp Outdated

#include <benchmark/benchmark.h>

BENCHMARK_MAIN();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to separate this out into a new file?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this file,
just link against benchmakr_main and it provides the main for you @felipeblazing

Comment thread src/data/kvikio_io_backend.cpp Resolved
Comment thread src/data/pipeline_io_backend.cpp Outdated
auto read_off = src_offset;
auto actual_sz = next_chunk;
auto read_fd = fd;
read_future = std::async(std::launch::async,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a new thread for every chunk, we may want to consider using a threadpool instead. Not just for the overhead, but to have a handle on how many of these I/O operations are active at the same time

@joosthooz

Copy link
Copy Markdown
Contributor

Other question: can't we use the (pretty new) cudftable format for this purpose? https://docs.rapids.ai/api/libcudf/stable/group__io__writers#ga18b2cd6a0deed1c4fbc43c2fc6b3094d

@felipeblazing

Copy link
Copy Markdown
Contributor Author

Other question: can't we use the (pretty new) cudftable format for this purpose? https://docs.rapids.ai/api/libcudf/stable/group__io__writers#ga18b2cd6a0deed1c4fbc43c2fc6b3094d

Using pack means you need more gpu memory to downgrade when you are already strapped for memory. This avoids that. We could pr this to cudf at some point.

felipeblazing and others added 2 commits April 10, 2026 09:53
Each disk memory_space now owns its I/O backend instance. Users can
register custom backends via io_backend_registry, set a default, and
override per disk space. Converters resolve the backend from the disk
memory_space at conversion time instead of capturing a global instance.

- Add set_default/get_default_name/create_default_backend to io_backend_registry
- Add get_io_backend() and two-arg disk constructor to memory_space
- Simplify register_builtin_converters to single overload (no backend param)
- Remove io_context struct and ctx parameter from prior commit

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* @param file_offset Byte offset within the file to start reading from.
* @param stream CUDA stream for synchronization.
*/
virtual void read_device(const std::string& path,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take filesystem path instead of string

* @param file_offset Byte offset within the file to start writing at.
* @param stream CUDA stream for synchronization.
*/
virtual void write_device(const std::string& path,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could take in a cudf::device_span, then you don't need to create write_device, write_host and ...

you could just add write and read

* @return The smallest multiple of alignment >= value.
*/
[[nodiscard]] constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcept
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since rmm is a dependecy, it already proivide align_up and down for us

felipeblazing and others added 2 commits April 10, 2026 13:44
- Replace custom cucascade::align_up with rmm::align_up (aminaramoon)
- Change idisk_io_backend path params from std::string to std::filesystem::path (aminaramoon)
- Simplify method names: write_device/write_host → write, read_device/read_host → read,
  write_device_batch → write_batch, read_device_batch → read_batch (aminaramoon)
- Replace per-chunk std::async with persistent io_worker thread in pipeline_io_backend (joosthooz)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Disk files now contain only raw 4KB-aligned column data buffers.
Metadata is kept in memory in disk_table_allocation and used directly
by the read paths instead of being serialized to disk and re-read.

This eliminates serialization/deserialization overhead, host I/O calls
for header+metadata on every write and read, and a cudaMemcpyAsync +
device buffer allocation in the GPU->disk path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@felipeblazing

Copy link
Copy Markdown
Contributor Author

/ok to test 6db1002

@aminaramoon aminaramoon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments

Comment thread src/data/representation_converter.cpp Outdated

// Set CUDA device to target GPU
int previous_device = -1;
CUCASCADE_CUDA_TRY(cudaGetDevice(&previous_device));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rmm has set_device_id_raii that does this, should be better to use that isntead

Comment thread benchmark/benchmark_main.cpp Outdated

#include <benchmark/benchmark.h>

BENCHMARK_MAIN();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this file,
just link against benchmakr_main and it provides the main for you @felipeblazing

} // namespace

std::string generate_disk_file_path(std::string_view base_path)
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you will (unlikel) have name collision when let's in doris mathias is running two sirius in the same machine.
instead use

#include <cstdlib>
#include <unistd.h>

std::filesystem::path create_secure_temp_file(std::string base_path) {
    std::string pattern = base_path + "/batch_XXXXXX.cucascade";
    int fd = mkstemps(pattern.data(), 10); // 10 is the length of ".cucascade"
    if (fd != -1) {
        close(fd); // You now have a guaranteed unique file created
        return pattern;
    }
    return {};
}

that guarantees a new file that no one else can claim

…device guard

- Remove benchmark_main.cpp, link benchmark::benchmark_main instead (aminaramoon)
- Use mkstemps() for cross-process safe unique disk file paths (aminaramoon)
- Replace manual cudaGet/SetDevice with rmm::cuda_set_device_raii in
  convert_host_to_gpu, convert_host_fast_to_gpu, convert_disk_to_gpu (aminaramoon)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@felipeblazing

Copy link
Copy Markdown
Contributor Author

/ok to test 0f6d2ad

@felipeblazing

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 9833849 into NVIDIA:main Apr 14, 2026
11 checks passed
aminaramoon added a commit to aminaramoon/cucs that referenced this pull request Oct 29, 2026
…urce device

Bugs of the converters that copy a GPU table's buffers one by one
(GPU -> host_data_representation and GPU -> DISK); they predate the io stack
split (plan_column_copy and the fast GPU -> host converter come from NVIDIA#52, the
GPU -> DISK converter from NVIDIA#96, view-backed gpu_table_representation from NVIDIA#116;
the DISK device guard was last reshaped by the step-2 "serve DISK spaces
through io_context" commit).

- Sliced sources. A view-backed representation may hold a slice, but the
  serializers copy every buffer of a column and its children from the start,
  and plan_column_copy() only asserted offset 0 in debug builds: in release
  builds a nullable slice starting at row 37 round-tripped as the table's
  leading rows with unshifted validity, and a prefix slice (offset 0) kept the
  extent of the table it was cut from in its children (DICTIONARY32 indices,
  STRING / LIST offsets, STRUCT fields), so it was restored with the wrong row
  count. needs_compaction() detects both (non-zero offset anywhere, or a child
  extent that does not match its parent's rows), and serializable_view()
  compacts such a table first (cudf::table's deep copy), on the conversion
  stream after the writer ordering, with the source device current; the copy
  lives until the transfer completed. It needs device memory for the whole
  table on the source GPU; if that fails, the conversion fails and the batch
  stays where it is.
- Failures after enqueued work. If the compaction (or anything later) throws
  after work reading the source was enqueued on the conversion stream, the
  stream is synchronized (drain_on_unwind, under the source-device guard)
  before the exception propagates, so the caller may release or mutate the
  source.
- Source device. GPU -> DISK waited for the writer on `stream` before making the
  source device current and switched only around the write: with a null
  `stream` the wait went to the default stream of the caller's current device
  while the io context read the sources on the source device's default stream,
  which had not waited. GPU -> host_data made it current only around the
  compaction. Both now keep the source device current from the writer ordering
  through the copies / write and the release of the compacted copy.

Regressions [disk]: view-backed nested nullable slice [37, 2011) and prefix
slices [0, 10) of a 100-row DICTIONARY32 / STRING / LIST / STRUCT table
through host_data and DISK; a compaction whose second column allocation is
refused (seam: a memory resource refusing large allocations) leaves the
conversion stream idle when the error arrives, on both routes; [multi_gpu]: a
GPU 1 table (also sliced) written late by a non-blocking stream spilled to DISK
from GPU 0 on the default stream, and a GPU 1 table converted to host_data
from GPU 0 on a GPU 1 stream.
copy-pr-bot Bot pushed a commit that referenced this pull request Oct 29, 2026
…urce device

Bugs of the converters that copy a GPU table's buffers one by one
(GPU -> host_data_representation and GPU -> DISK); they predate the io stack
split (plan_column_copy and the fast GPU -> host converter come from #52, the
GPU -> DISK converter from #96, view-backed gpu_table_representation from #116;
the DISK device guard was last reshaped by the step-2 "serve DISK spaces
through io_context" commit).

- Sliced sources. A view-backed representation may hold a slice, but the
  serializers copy every buffer of a column and its children from the start,
  and plan_column_copy() only asserted offset 0 in debug builds: in release
  builds a nullable slice starting at row 37 round-tripped as the table's
  leading rows with unshifted validity, and a prefix slice (offset 0) kept the
  extent of the table it was cut from in its children (DICTIONARY32 indices,
  STRING / LIST offsets, STRUCT fields), so it was restored with the wrong row
  count. needs_compaction() detects both (non-zero offset anywhere, or a child
  extent that does not match its parent's rows), and serializable_view()
  compacts such a table first (cudf::table's deep copy), on the conversion
  stream after the writer ordering, with the source device current; the copy
  lives until the transfer completed. It needs device memory for the whole
  table on the source GPU; if that fails, the conversion fails and the batch
  stays where it is.
- Failures after enqueued work. If the compaction (or anything later) throws
  after work reading the source was enqueued on the conversion stream, the
  stream is synchronized (drain_on_unwind, under the source-device guard)
  before the exception propagates, so the caller may release or mutate the
  source.
- Source device. GPU -> DISK waited for the writer on `stream` before making the
  source device current and switched only around the write: with a null
  `stream` the wait went to the default stream of the caller's current device
  while the io context read the sources on the source device's default stream,
  which had not waited. GPU -> host_data made it current only around the
  compaction. Both now keep the source device current from the writer ordering
  through the copies / write and the release of the compacted copy.

Regressions [disk]: view-backed nested nullable slice [37, 2011) and prefix
slices [0, 10) of a 100-row DICTIONARY32 / STRING / LIST / STRUCT table
through host_data and DISK; a compaction whose second column allocation is
refused (seam: a memory resource refusing large allocations) leaves the
conversion stream idle when the error arrives, on both routes; [multi_gpu]: a
GPU 1 table (also sliced) written late by a non-blocking stream spilled to DISK
from GPU 0 on the default stream, and a GPU 1 table converted to host_data
from GPU 0 on a GPU 1 stream.
copy-pr-bot Bot pushed a commit that referenced this pull request Oct 29, 2026
…urce device

Bugs of the converters that copy a GPU table's buffers one by one
(GPU -> host_data_representation, GPU -> DISK and GPU -> GPU); they predate
the io stack split (plan_column_copy and the fast GPU -> host converter come
from #52, the GPU -> GPU column walk from #52 / #116, the GPU -> DISK
converter from #96, view-backed gpu_table_representation from #116).

- Sliced sources. A view-backed representation may hold a slice, but the
  serializers copy every buffer of a column and its children from the start,
  and plan_column_copy() / reconstruct_column_p2p() only asserted offset 0 in
  debug builds: in release builds a nullable slice starting at row 37
  round-tripped as the table's leading rows with unshifted validity, and a
  prefix slice (offset 0) kept the extent of the table it was cut from in its
  children (DICTIONARY32 indices, STRING / LIST offsets, STRUCT fields), so it
  was restored with the wrong row count (GPU -> GPU failed with
  cudaErrorInvalidValue or "Invalid offsets column size" instead, or, for a
  fixed-width slice, silently returned the wrong rows). needs_compaction()
  detects both (non-zero offset anywhere, or a child extent that does not
  match its parent's rows), and serializable_view() compacts such a table
  first (cudf::table's deep copy), with the source device current, after the
  writer ordering; the copy lives until the transfer completed. GPU -> host
  and GPU -> DISK compact on the conversion stream; GPU -> GPU compacts on a
  stream of the source space and synchronizes it before the cross-device
  copies on the target stream read the copy. It needs device memory for the
  whole table on the source GPU; if that fails, the conversion fails and the
  batch stays where it is.
- Failures after enqueued work. If the compaction (or anything later) throws
  after work reading the source was enqueued on the conversion stream, the
  stream is synchronized (drain_on_unwind, under the source-device guard)
  before the exception propagates, so the caller may release or mutate the
  source. GPU -> GPU does the same for its target stream: a failed allocation
  for column i+1 no longer returns while column i's peer copy is still queued
  (also before the compacted copy is freed), and the host-staged peer copy
  drains its stream before its pinned blocks go back to the pool.
- Source device. GPU -> host_data made the source device current only around
  the compaction; it now keeps it current from the writer ordering through
  the copies and the release of the compacted copy. GPU -> DISK already
  does (and refuses a stream of another device); the compaction now runs in
  that scope too.

Regressions [disk]: view-backed nested nullable slice [37, 2011) and prefix
slices [0, 10) of a 100-row DICTIONARY32 / STRING / LIST / STRUCT table
through host_data and DISK; a compaction whose second column allocation is
refused (seam: a memory resource refusing large allocations) leaves the
conversion stream idle when the error arrives, on both routes; [multi_gpu]: a
GPU 1 table (also sliced) written late by a non-blocking stream spilled to DISK
from GPU 0 on the default stream, a GPU 1 table converted to host_data from
GPU 0 on a GPU 1 stream, nested / prefix / fixed-width slices converted GPU 0
-> GPU 1 and GPU 1 -> GPU 0 and back, and failed GPU -> GPU conversions (an
allocation refused on the target, a compaction refused on the source) that
leave the source's writer finished when the error arrives. The test sources
that own a raw stream move it out of the moved-from object.
copy-pr-bot Bot pushed a commit that referenced this pull request Nov 2, 2026
…urce device

Bugs of the converters that copy a GPU table's buffers one by one
(GPU -> host_data_representation, GPU -> DISK and GPU -> GPU); they predate
the io stack split (plan_column_copy and the fast GPU -> host converter come
from #52, the GPU -> GPU column walk from #52 / #116, the GPU -> DISK
converter from #96, view-backed gpu_table_representation from #116).

- Sliced sources. A view-backed representation may hold a slice, but the
  serializers copy every buffer of a column and its children from the start,
  and plan_column_copy() / reconstruct_column_p2p() only asserted offset 0 in
  debug builds: in release builds a nullable slice starting at row 37
  round-tripped as the table's leading rows with unshifted validity, and a
  prefix slice (offset 0) kept the extent of the table it was cut from in its
  children (DICTIONARY32 indices, STRING / LIST offsets, STRUCT fields), so it
  was restored with the wrong row count (GPU -> GPU failed with
  cudaErrorInvalidValue or "Invalid offsets column size" instead, or, for a
  fixed-width slice, silently returned the wrong rows). needs_compaction()
  detects both (non-zero offset anywhere, or a child extent that does not
  match its parent's rows), and serializable_view() compacts such a table
  first (cudf::table's deep copy), with the source device current, after the
  writer ordering; the copy lives until the transfer completed. GPU -> host
  and GPU -> DISK compact on the conversion stream; GPU -> GPU compacts on a
  stream of the source space and synchronizes it before the cross-device
  copies on the target stream read the copy. It needs device memory for the
  whole table on the source GPU; if that fails, the conversion fails and the
  batch stays where it is.
- Failures after enqueued work. If the compaction (or anything later) throws
  after work reading the source was enqueued on the conversion stream, the
  stream is synchronized (drain_on_unwind, under the source-device guard)
  before the exception propagates, so the caller may release or mutate the
  source. GPU -> GPU does the same for its target stream: a failed allocation
  for column i+1 no longer returns while column i's peer copy is still queued
  (also before the compacted copy is freed), and the host-staged peer copy
  drains its stream before its pinned blocks go back to the pool.
- Source device. GPU -> host_data made the source device current only around
  the compaction; it now keeps it current from the writer ordering through
  the copies and the release of the compacted copy. GPU -> DISK already
  does (and refuses a stream of another device); the compaction now runs in
  that scope too.

Regressions [disk]: view-backed nested nullable slice [37, 2011) and prefix
slices [0, 10) of a 100-row DICTIONARY32 / STRING / LIST / STRUCT table
through host_data and DISK; a compaction whose second column allocation is
refused (seam: a memory resource refusing large allocations) leaves the
conversion stream idle when the error arrives, on both routes; [multi_gpu]: a
GPU 1 table (also sliced) written late by a non-blocking stream spilled to DISK
from GPU 0 on the default stream, a GPU 1 table converted to host_data from
GPU 0 on a GPU 1 stream, nested / prefix / fixed-width slices converted GPU 0
-> GPU 1 and GPU 1 -> GPU 0 and back, and failed GPU -> GPU conversions (an
allocation refused on the target, a compaction refused on the source) that
leave the source's writer finished when the error arrives. The test sources
that own a raw stream move it out of the moved-from object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request non-breaking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants