← Back to Pull requests

Add GPU support for Databricks Delta MERGE ChecksumExpression [databricks] #16727

Closed
unknown closed this pull request without merging on Nov 05, 2026 21:23 UTC
View on GitHub
unknown unknown commented on Nov 03, 2026 23:46 UTC
Author

Fixes #16489.

Description

On Databricks 17.3 and 18.3, Delta MERGE can wrap its materialized source in a Filter(checksum(cols) AND true). ChecksumExpression had no GPU rule, so the filter ran on the CPU and added an extra GpuColumnarToRow /
GpuRowToColumnar pair around it.

This adds GpuChecksumExpression so the filter stays on the GPU. It is modeled on the Databricks expression:

  • It always returns true. As a side effect, it adds a checksum of its children to the MERGE metric, which MERGE later verifies.

  • Per row, each child is hashed as pmod(xxhash64(child, seed), MOD) (a hash of 0 counts as 1), and the results are multiplied modulo MOD. This reuses GpuXxHash64 and GpuPmod.

  • Each batch contributes the product of its per row values, computed on the GPU with a halving reduction.

  • It is retryable (GpuExpressionRetryable). A failed attempt is undone by multiplying by the modular inverse of what it added, since the metric cannot take a negative value.

  • It falls back to the CPU for types that exceed the xxhash64 stack depth limit.

  • It can be disabled with spark.rapids.sql.expression.ChecksumExpression=false.
  • The rule is registered in DatabricksDeltaProvider173183Base, so it applies to both spark400db173 and spark410db183. No new configuration is added.

    Tests

    Added to delta_lake_merge_test.py:

  • test_delta_merge_cpu_command_checksum_expression_db173: the plan contains a GpuFilter with gpu_checksum_expression.

  • test_delta_merge_cpu_command_checksum_expression_types_db173: 11 nullable types, one batch and many batches, with OOM injection. checksumSource=ASSERT means a wrong metric fails the MERGE.

  • test_delta_merge_cpu_command_checksum_expression_disabled_db173.
  • Ran on DBR 17.3 and DBR 18.3: the new tests and the existing test_delta_merge_cpu_command_increment_metric_db173 pass on both, with none skipped.

    Performance

    NDS merge.tpl query 4 on 8 x Standard_NC8as_T4_v3, DBR 17.3 GPU, Parquet source (materialized), 277M row target, ANSI off. 1 warmup + 5 timed runs per mode, interleaved.

    | Mode | MERGE median | min | max |
    |---|---|---|---|
    | rule on | 63.2 s | 61.0 | 75.1 |
    | rule off | 64.9 s | 64.0 | 82.5 |
    | checksum off | 61.8 s | 60.4 | 74.2 |

    The table compares MERGE wall time with the new GPU rule on, with it off (the old CPU Filter, which adds extra row↔columnar transitions), and with the checksum turned off entirely (the floor). The rule is slightly faster than before and only about 0.5-2 s above that floor, so it removes the CPU fallback without a measurable performance cost.

    Checklists

    Documentation

  • Updated for new or modified user-facing features or behaviors

  • No user-facing change
  • Testing

  • Added or modified tests to cover new code paths

  • Covered by existing tests

  • (Please provide the names of the existing tests in the PR description.)
  • Not required
  • Performance

  • Tests ran and results are added in the PR description

  • Issue filed with a link in the PR description

  • Not required
  • Diff: 390 lines (+292 / -98) across 4 files Reviewer: gerashegalov Review duration: 2736m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 390 lines diff across 4 files
    0.43
    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%
    56%
    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.357
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #16727"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 43.1% (MEDIUM) · Higher = larger blast radius
    43.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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 18.6% · Safe to merge
    18.6%