Skip to content

[POC] Back libcudf scalars with Arrow-compatible column storage - #23765

Draft
GregoryKimball wants to merge 14 commits into
NVIDIA:mainfrom
GregoryKimball:scalar-refactor
Draft

[POC] Back libcudf scalars with Arrow-compatible column storage#23765
GregoryKimball wants to merge 14 commits into
NVIDIA:mainfrom
GregoryKimball:scalar-refactor

Conversation

@GregoryKimball

@GregoryKimball GregoryKimball commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Background

cudf::scalar and cudf::column currently use incompatible device layouts:

  • Scalar validity is stored separately from column null-mask metadata. Consequently, scalar::is_valid() synchronizes with the device (#8064), and scalar validity cannot safely be interpreted as a column bitmask (#22757).
  • Fixed-width, decimal, string, list, and struct scalars use type-specific storage instead of column-compatible data, masks, offsets, and children.
  • Algorithms duplicate scalar/column paths or materialize temporary one-row columns (#18858, #10892).
  • Device code uses a separate hierarchy of typed scalar views that lacks a generic, const-correct interface (#13160, #4365).
    These are different logical abstractions, but they do not need different physical storage. A scalar can own the same Arrow-compatible layout as a one-row column while retaining scalar-specific constructors and accessors.
    This implements the central storage proposal from #19465.

Summary

  • Backs numeric, chrono, fixed-point, string, list, and struct scalars with one-row cudf::column storage.
  • Adds allocation-free const and mutable scalar column views.
  • Makes host null-count metadata authoritative, so scalar::is_valid() no longer synchronizes.
  • Provides mutable scalar views for value writes while requiring validity to be established explicitly.
  • Preserves existing typed scalar constructors and value accessors as compatibility facades.
  • Migrates compiled binary operations, JIT literals, search, sequence, copying, reductions, shared iterators, string kernels, and decoded-key dictionary operations to standard column device views.
  • Removes scalar conversion allocations, typed device-view adapters, and const_casts from migrated consumers.
  • Retains owning one-row materialization for internally synthesized JIT temporaries whose lifetime would otherwise be too short.

Benchmark results

image

For order-32 FLOAT32 polynomials, the JIT path improves most because it avoids per-literal one-row materialization. AST and binary-op paths show smaller gains because they already used lightweight scalar adapters.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Cover numeric, decimal, string, and list materialization before replacing their independent storage representations.
Unify fixed-width, decimal, string, list, and struct scalar ownership with Arrow-compatible column storage so scalar views are allocation-free and host validity checks no longer synchronize.
Pass the scalar's owned one-row view directly so AST literals avoid materializing an auxiliary column while retaining exact nullability.
@copy-pr-bot

copy-pr-bot Bot commented Aug 21, 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.

@github-actions github-actions Bot added the libcudf Affects libcudf (C++/CUDA) code. label Aug 21, 2026
Keep zero-copy storage for AST literals whose owners outlive execution while materializing internally synthesized scalars such as rescale parameters.
@GregoryKimball GregoryKimball changed the title Scalar refactor [POC] Back libcudf scalars with one-row column storage Aug 22, 2026
Remove scalar conversion allocations and const casts by consuming owned one-row views directly, including null-aware string operations.
Remove scalar conversion allocations and const casts by comparing directly against owned one-row column views.
Read sequence inputs through one-row column device views, removing typed scalar adapters and const casts.
Retain scalar-backed column device views at call sites and broadcast row zero through standard column iterators, removing typed scalar adapters and const casts.
Read separators and null replacements through retained one-row column device views, removing string scalar adapters and const casts.
Expose mutable one-row column views for scalar value producers while keeping host null counts authoritative and requiring explicit reconciliation after device mask writes.
Keep scalar validity coherent through host metadata and ordered mask updates, matching the column producer contract without a scalar-specific synchronization API.
Avoid one-row materialization and typed scalar device views by consuming the scalar's owned column storage directly.
Update developer and API guidance to describe one-row column storage and column device views as the preferred access path.
Measure construction latency and peak memory for nullable numeric and variable-size string scalars.
@github-actions github-actions Bot added the CMake CMake build issue label Aug 22, 2026
@GregoryKimball GregoryKimball changed the title [POC] Back libcudf scalars with one-row column storage [POC] Back libcudf scalars with Arrow-compatible column storage Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CMake CMake build issue libcudf Affects libcudf (C++/CUDA) code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant