Skip to content

Add native stable CUDA sorting for bounded UTF-8 strings - #1272

Draft
aw471 wants to merge 4 commits into
compile/kumotabular-native-string-selectionfrom
compile/kumotabular-native-string-sort
Draft

aw471 wants to merge 4 commits into
compile/kumotabular-native-string-selectionfrom
compile/kumotabular-native-string-sort

Conversation

@aw471

@aw471 aw471 commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Sort bounded UTF-8 strings on CUDA with native tensor operations, including gathering the sorted payloads. Preserve stable ordering and place nulls last in both directions.

Description of the change

Sort packed words from least to most significant using stable argsort, then materialize values with bounded payload selection. The native path applies when the conservative string-length bound is at most 56 bytes; longer or unknown bounds retain the existing path. CPU sorting stays on Arrow because native eager sorting regressed there.

Stacked on bounded payload selection, which includes shared UTF-8 packing. Incremental production change: 30 added lines in one file, excluding tests and dependencies.

Validation

Local string, variable-length and packing suites: 117 passed. The combined preprocessing stack passed 141 focused CPU/CUDA tests; full pre-commit checks passed. Coverage includes stable duplicates, null payloads, UTF-8/NUL prefixes, empty inputs, strided and expanded views, and fullgraph compilation in both sort directions.

On one RTX PRO 6000 Blackwell GPU with PyTorch 2.14.0+cu130 and cuDF 26.10.02, sorting 40,000 Bank Marketing job strings, including output payload materialization, took 0.369 ms native compiled versus 3.269 ms registered compiled, an 8.9× improvement. Native eager took 0.847 ms versus 3.119 ms for the registered baseline.

Both compiled variants used Inductor with fullgraph=True; native capture produced one graph without registered sort or selection operations. Times are warm synchronized wall-clock medians from 25 alternating samples, excluding compilation. Across five synthetic full-sort cases with 32–40,000 strings and widths of 7–56 bytes, the compiled improvement was 3.6–10.2×.

@copy-pr-bot

copy-pr-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.13%. Comparing base (3600d42) to head (e726995).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                               Coverage Diff                               @@
##           compile/kumotabular-native-string-selection    #1272      +/-   ##
===============================================================================
+ Coverage                                        83.10%   83.13%   +0.02%     
===============================================================================
  Files                                              177      177              
  Lines                                            11461    11477      +16     
===============================================================================
+ Hits                                              9525     9541      +16     
  Misses                                            1936     1936              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant