← Back to Pull requests

Add GPU unhex decoding to JNI #5294

Closed
unknown closed this pull request without merging on Oct 21, 2026 13:32 UTC
View on GitHub
unknown unknown commented on Oct 14, 2026 19:53 UTC
Author

Add native GPU unhex decoding

Related to NVIDIA/cudf-spark#12579. The Spark plugin integration will follow in a separate PR.

Description

Add hexToBytes to cudf-spark-jni. It decodes hexadecimal strings to binary byte lists, treats an odd leading digit as a zero-padded nibble, and returns null for invalid input. The native decoder validates and then decodes one thread per row when every row fits in a 32-character chunk, and fixed-size character chunks otherwise, so one long string does not serialize a batch. Add JNI and Java entry points, native and Java correctness tests, and a batch-shape benchmark.

Testing

  • CUDA Docker build and all ten focused native HexToBytesTests and all 77 CAST_STRING tests pass.

  • CastStringsTest.hexToBytesTest passes.

  • With the matching local Spark plugin integration, focused CPU/GPU correctness tests pass on Spark 3.3, 3.4, 4.0, and 4.1.
  • Performance

    The end-to-end numbers below were measured on 6a38abf5. The query is dominated by the Parquet scan, so they are unchanged within noise by later decoder changes. The native benchmark and unhex operator-time comparisons for 44404de5 are in the review thread on hex.cu.

    End-to-end Spark 4.1.1 UNHEX query on 67,108,864 unique 16-character hex strings (1 GiB of logical input), with five warmups and ten timed queries. Both plans process the same Parquet input; the CPU run uses vanilla upstream Spark without the RAPIDS plugin. The GPU run uses this JNI implementation and the matching local Spark plugin integration. Medians include scan, decode, aggregate, and collect().

    | Workload | Vanilla CPU Spark | GPU Spark |
    | --- | ---: | ---: |
    | All short strings | 1,608.7 ms | 324.3 ms |
    | One 1 MiB hex string among short strings | 1,708.2 ms | 345.7 ms |

    Host: AMD Ryzen Threadripper PRO 5975WX and NVIDIA Quadro RTX 6000. Local mode uses four CPU task slots and one Parquet partition. This shows a roughly 5× end-to-end GPU speedup for this workload; it does not claim a speedup for smaller batches.

    Diff: 253 lines (+189 / -64) across 3 files Reviewer: gerashegalov Review duration: 9698m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 253 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.331
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5294"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.4% · Safe to merge
    15.4%