cudf icon indicating copy to clipboard operation
cudf copied to clipboard

[BUG] cudf-polars: any node with a Null-dtype column is rejected, e.g. `pl.lit(None)`

Open Matt711 opened this issue 1 month ago • 1 comments

The translator in translate.py returns an ErrorNode for every IR node whose schema contains pl.Null ("No GPU support for ... with Null column dtype"), so pl.lit(None) followed by with_columns, select, or unique never runs on the GPU. libcudf has type_id.EMPTY, and DataType already maps pl.Null to it, so the check looks like a blanket guard rather than a missing type.

Without raise_on_fail the query silently falls back to the CPU. With it, the error is a plain NotImplementedError per node. Replacing a column with an untyped null is a common way to blank out a column, so users will hit this in ordinary pipelines. Fix would be to allow the Null dtype where the node only passes it through (HStack, Projection, Distinct), and keep the guard for nodes that cannot handle EMPTY columns. I have not checked which IR nodes actually can.

Repro is:

import polars as pl

t0 = pl.LazyFrame({"c0": ["x"]})
t0.with_columns(pl.lit(None).alias("c0")).collect(engine=pl.GPUEngine(raise_on_fail=True))
t0.select(pl.lit(None).alias("c0")).unique().collect(engine=pl.GPUEngine(raise_on_fail=True))
t0.with_columns(pl.lit(None).alias("c1")).select("c1", "c0").collect(engine=pl.GPUEngine(raise_on_fail=True))

Each raises NotImplementedError: No GPU support for HStack/Distinct/Projection ... Null. The CPU engine returns a frame with a Null column.

Related: pola-rs/polars#30392, #30393, #30394 (original reports).

Environment: Polars 2.1.0, cudf-polars 26.12.00a616 (nightly wheels), Tesla V100, driver 535.161.08.

Tools: Claude Code

Matt711 avatar Nov 02 '26 14:11 Matt711

I'd like to work on this.

I can reproduce all three cases on today's nightly (cudf-polars 26.12.00a725, Polars 2.1.0). Removing the guard alone isn't enough: the pass-through nodes then return Int8 instead of Null (the Literal maps EMPTY to INT8 and nothing casts back), and a DataFrameScan with a Null input column, or a unique keyed on it, reaches libcudf with EMPTY and fails with "Invalid type_id".

My plan follows the Time and Array pass-through handling (#23773):

  • keep Null columns as all-null INT8 on the device, with pl.Null as the logical dtype
  • cast them back to Null in DataFrame.to_polars, and convert Null input columns when scanning a Polars frame
  • replace the blanket check with a pass-through allowlist (HStack, Select, SimpleProjection, Filter, Slice, Sort, Union, HConcat, Distinct, and Join when the Null column isn't a key), keeping the error for the rest
  • tests for the in-memory and streaming executors

Happy to narrow or widen that list if you have a preference.

jontb avatar Nov 06 '26 02:11 jontb