← Back to Pull requests

Support more non-ANSI integral arithmetic in Project AST JIT [databricks] #16677

Closed
unknown closed this pull request without merging on Nov 23, 2026 09:26 UTC
View on GitHub
unknown unknown commented on Oct 30, 2026 04:20 UTC
Author

Contributes to #16676.

Description

Project AST JIT supported only non-ANSI INT/LONG addition and multiplication. Project AST JIT stays experimental and disabled by default (spark.rapids.sql.projectAstJitEnabled). When it is enabled, this PR extends it to:

  • Add, Subtract, Multiply, UnaryMinus and Abs on byte, short, int and long in non-ANSI mode. They keep Spark's wrapping semantics. cuDF narrows every intermediate to its declared type, so byte and short wrap at each step like Spark, including abs of a wrapped intermediate.

  • Lossless integral widening casts. The planner keeps them inside a consumer's JIT region, so Spark's implicit casts in mixed-width arithmetic, such as int_col + long_col, no longer split it into a separate tier. A widening cast counts toward maxGroupOps like other operations, but a cast alone is not compiled.
  • ANSI arithmetic is not included. cuDF's checked JIT operators can detect an overflow, but a JIT evaluation error reports only its error code, not the failing row or operation. The plugin needs those to raise the same Spark error as the regular GPU path. NVIDIA/cudf#24944 requests that information, and #16676 tracks ANSI support. Floating point is still excluded, because cuDF contracts a b + c into an FMA in JIT kernels (NVIDIA/cudf#24942).

    Planner tests that used integral subtraction as an expression JIT does not support now use bitwise operations, greatest, or float subtraction instead. Integral subtraction no longer leaves a simple-arithmetic legacy consumer that shares a subtree with a JIT consumer, so that test now checks that both consumers share the subtree in one JIT program.

    Tests:

  • GpuProjectAstJitSuite covers selection for each integral type, exclusion of each operator in ANSI and floating-point modes, widening casts staying inside a JIT region, and their count toward the group operation limit. It also runs JIT programs on the GPU and compares them with the regular GPU path at type boundaries for long, byte and short, including abs of a wrapped intermediate.

  • GpuProjectAstPlannerSuite covers selection and sharing with the new operations.

  • ast_test.py adds wrapping arithmetic for byte, short, int and long, and +, - and between each narrower and wider integral type. Like the other JIT tests, they are expected to fail on Dataproc Serverless (#16778).
  • Ran on Spark 3.5.2 (buildver=352):

  • mvn test -Dbuildver=352 -DwildcardSuites=GpuProjectAstJitSuite,GpuProjectAstPlannerSuite,GpuBroadcastHashJoinPostProjectionSuite,ProjectExprSuite,GpuArrayHofFusionSuite: 122 passed.

  • TESTS=ast_test.py ./integration_tests/run_pyspark_from_build.sh: 230 passed, 1 xpassed (test_columnar_pow, unrelated).
  • Not run locally: other Spark versions, Databricks, and the full integration test suite.

    Performance

    Hot run with a warm kernel cache, 200M rows of four INT32 columns read from Parquet, local[4], 8 GB pinned pool, RTX 5880 Ada. The expression is the depth-8 chain -abs(((i0 + i1) - i2) - i3) * 2 + k + i1 - i2 with one or four outputs (different k), followed by sum. Without this PR only part of it can use JIT. Medians of 5 iterations after 2 warmups, one process. Op time is Project op time summed across the 4 concurrent tasks. Results matched. These runs used an earlier revision of this branch that also had ANSI support; the non-ANSI path measured here is unchanged.

    | Outputs | Project op time, regular → JIT (ms) | End to end, regular → JIT (ms) |
    |---:|---:|---:|
    | 1 | 96.7 → 27.2 | 1305.2 → 1275.5 |
    | 4 | 195.7 → 48.8 | 1318.1 → 1256.8 |

    End-to-end savings are close to the op-time savings divided by the 4 concurrent tasks; the rest of this query is mostly the Parquet scan. Cold-start compilation of the new kernels was not measured; #16383 tracks cold-start 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: 542 lines (+406 / -136) across 6 files Reviewer: wjxiz1992 Review duration: 34866m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 542 lines diff across 6 files
    0.48
    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.377
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #16677"
    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: 48.0% (MEDIUM) · Higher = larger blast radius
    48.0%
    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: 20.8% · Safe to merge
    20.8%