← Back to Pull requests

Accelerate Delta OPTIMIZE ... ZORDER BY on the GPU for OSS Delta 3.3–4.3 [databricks] #16759

Closed
unknown closed this pull request without merging on Nov 19, 2026 01:07 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 21:33 UTC
Author

Fixes https://github.com/NVIDIA/cudf-spark/issues/16985.

Description

OPTIMIZE ... ZORDER BY on OSS Delta Lake 3.3–4.3 used to fall back to the CPU. This PR runs it on the GPU, using the existing GpuInterleaveBits, GpuHilbertLongIndex and range partition shuffle.

  • Removed the Z order fallback from the OPTIMIZE metas and the run-time Z order guard in GpuOptimizeTableCommand.

  • Z order columns are validated through GpuDeltaReorgTableCommand.validateZorderByColumns, so the errors match the CPU.

  • Z order on deletion vector tables now runs on the GPU. It reads live rows through the DVs and rewrites files without DVs, as Delta does.
  • Testing

    Added CPU vs GPU tests in delta_lake_optimize_table_test.py. They cover:

  • unpartitioned and partitioned tables

  • multiple Z order columns and mixed types

  • DV tables, partition predicates, multiple output files

  • repeated runs and empty tables

  • row tracking and CDF

  • invalid columns and the clustered table error

  • equal but differently formatted timestamp partitions (Delta 4.3 only)
  • They also compare the ZOrderStats/ZOrderFileStats metrics. Local runs passed on Delta 4.1.0, 4.3.0 and 3.3.3.

    Also found https://github.com/NVIDIA/cudf-spark/issues/16946 when running tests.

    Performance

    Spark 4.1.1 + Delta 4.3.0, 8 workers, 3 runs per arm. CPU and GPU were given matched resources. The workload ran OPTIMIZE ... ZORDER BY on a Delta table of 100M rows in 256 small files, with maxFileSize set to 128 MB. Each run used a fresh shallow clone of a CPU written seed, so the CPU and GPU runs started from identical layouts. It covered four cases:
    1. Z order on two columns (a bigint and an int hash), on an unpartitioned table.
    2. The same two columns on a table partitioned 8 ways.
    3. Four mixed columns (bigint, int, date and string), unpartitioned.
    4. The two column case on a table with deletion vectors on every input file (about 1% of rows deleted).

    | Case | CPU (s) | GPU (s) | Speedup | p-value |
    |---|---|---|---|---|
    | Unpartitioned, 2 columns | 11.5 | 5.3 | 2.16x | 0.011 |
    | Partitioned, 2 columns | 11.3 | 10.0 | 1.13x | not significant |
    | Unpartitioned, 4 mixed columns | 13.4 | 6.7 | 2.00x | 0.002 |
    | DV table, 2 columns | 14.2 | 7.8 | 1.81x | 0.001 |

    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: 346 lines (+259 / -87) across 4 files Reviewer: sdrp713 Review duration: 18933m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 346 lines diff across 4 files
    0.42
    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.350
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #16759"
    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: 42.4% (MEDIUM) · Higher = larger blast radius
    42.4%
    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: 16.7% · Safe to merge
    16.7%