Add fixed-size rolling window support to cudf-polars#21964
Draft
tolleybot wants to merge 3 commits intorapidsai:mainfrom
Draft
Add fixed-size rolling window support to cudf-polars#21964tolleybot wants to merge 3 commits intorapidsai:mainfrom
tolleybot wants to merge 3 commits intorapidsai:mainfrom
Conversation
Translate Polars RollingFunction expression nodes (rolling_sum, rolling_min, rolling_max, rolling_mean, rolling_var, rolling_std) into GPU-executable operations via libcudf's rolling window API. The new FixedSizeRollingWindow expression class uses a synthetic sequential integer orderby column with grouped_range_rolling_window to implement row-count-based windows through the existing range-based API. This supports configurable window size, center alignment, min_periods, and ddof for variance/standard deviation. Closes rapidsai#20307
wence-
requested changes
Apr 2, 2026
Comment on lines
+218
to
+220
| Handles expressions like ``pl.col("x").rolling_sum(window_size=3)``. | ||
| Uses a synthetic sequential orderby column with the range-based | ||
| rolling window API to implement row-count-based windows. |
Contributor
There was a problem hiding this comment.
libcudf has a row-count based window API. You can use pylibcudf.rolling.rolling_window with integer arguments for the preceding_window and following_window parameters.
Author
There was a problem hiding this comment.
Good call, thanks. Switched to pylibcudf.rolling.rolling_window with integer preceding/following arguments directly. The synthetic orderby column and grouped_range_rolling_window detour are gone.
| agg_request = self._make_agg_request() | ||
| request = plc.rolling.RollingRequest(col.obj, min_periods, agg_request) | ||
|
|
||
| (result,) = plc.rolling.grouped_range_rolling_window( |
Contributor
There was a problem hiding this comment.
Yeah, this can just be rolling_window without needing to make the orderby column.
Author
There was a problem hiding this comment.
Fixed in the same commit. This now passes the integers through to rolling_window.
Use pylibcudf.rolling.rolling_window instead of constructing a synthetic orderby column for grouped_range_rolling_window. This simplifies the implementation and avoids unnecessary overhead.
00ce2b2 to
ed71430
Compare
Extract a _ddof property to deduplicate the three fn_params extraction sites, add a defensive error in _make_agg_request for unknown aggregation names, and remove the unused fixture column.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Translate Polars
RollingFunctionexpression nodes (rolling_sum,rolling_min,rolling_max,rolling_mean,rolling_var,rolling_std) into GPU-executable operations via libcudf's rolling window API.The new
FixedSizeRollingWindowexpression class uses a synthetic sequential integer orderby column withgrouped_range_rolling_windowto implement row-count-based windows through the existing range-based API. This supports configurable window size, center alignment,min_periods, andddoffor variance and standard deviation.Depends on pola-rs/polars#27108 which exposes
RollingFunctionin the Polars Python visitor.Closes #20307
xref #18633
Checklist