← Back to Pull requests

Fix RDD actions over a single-partition GPU shuffle [databricks] #17226

Open
unknown opened this pull request with 444 lines diff across 5 files
View on GitHub
unknown unknown commented on Dec 01, 2026 16:49 UTC
Author

Fixes #17002. Fixes #17003.

Description

An RDD action over a single-partition GPU exchange, such as df.repartition(1).rdd.count(), fails its map task in UCX and CACHE_ONLY modes. With the internal spark.rapids.shuffle.kudo.serializer.write.mode=GPU, it hangs in MULTITHREADED mode, and returns wrong results with no error when shuffle compression is off or Spark's own shuffle manager runs. Its map tasks slice for the default modes, because outside a SQL execution their conf lacks the session's settings. On Spark 4 with AQE on, Scala's Dataset.rdd runs inside one, so there only queryExecution.toRdd and PySpark's DataFrame.rdd show the bug.

This PR builds a GpuSinglePartitioner per shuffle on the driver, with the modes that chose its writer and serializer, so these actions return what collect() returns. It also adds two guards that fail the task on a lost batch. The threaded reader now reads only the threaded writer's shuffles.

Behavior changes

| What | Before | After |
|---|---|---|
| Threaded shuffle reader, on a non-empty block with no batch | Waited forever, skipped the block, or threw NoSuchElementException | Throws an IllegalStateException naming the block |
| A shuffle written with spark.rapids.shuffle.multiThreaded.writer.threads=0 | Threaded reader, which could hang or fail | Spark's reader |
| GPU kudo serializer, on a batch it cannot write | Wrote nothing | Throws an IllegalStateException |
| A single-partition shuffle's batch sizes | Read once per JVM, and shared by every query | Taken from the query that planned the shuffle |
| A single-partition shuffle's d2hMemCopyTime debug metric | Not recorded on a cluster. In local mode, recorded on the exchange that set it last | Recorded on the shuffle's own exchange |

Hash, range and round-robin partitioners already took these values from the driver.

Performance

Nothing new runs per row or per batch. The reader checks a header it reads anyway, and the serializer's new branch runs only on a batch it used to drop. A single-partition shuffle slices as before unless a session sets the batch sizes, which it now follows. With 0 writer threads, Spark's reader now reads what Spark's writer wrote.

Tests

RapidsShuffleThreadedReaderSuite reads blocks that are only an LZ4 frame, with one and two reader threads. Each case fails without the check, and asserts the failed block's release. It also runs two review queries with 0 writer threads, which failed before the fallback. GpuSinglePartitioningSuite runs both issues' actions in five setups with AQE off, and checks the serializer's throw and what serialization keeps. Reverting the fix fails every setup but the default. GpuPartitioningSuite checks the same for hash, round-robin and range partitioners. They ran locally at buildver 353, and the last two at 402. Not checked: UCX between executors, and the reader suite on Spark 4, which #14908 tracks. Only the Databricks premerge compiles one caller, Delta's GpuOptimizeWriteExchangeExec.

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
  • This PR was built and prepared using an AI assistant.

    Diff: 444 lines (+333 / -111) across 5 files Reviewer: gerashegalov Review duration: 5327m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 444 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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.365
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #17226"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 24.2% · Safe to merge
    24.2%