Fix RDD actions over a single-partition GPU shuffle [databricks] #17226
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
gerashegalov
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 internalspark.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'sDataset.rddruns inside one, so there onlyqueryExecution.toRddand PySpark'sDataFrame.rddshow the bug.This PR builds a
GpuSinglePartitionerper shuffle on the driver, with the modes that chose its writer and serializer, so these actions return whatcollect()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 anIllegalStateExceptionnaming 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
d2hMemCopyTimedebug 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
RapidsShuffleThreadedReaderSuitereads 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.GpuSinglePartitioningSuiteruns 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.GpuPartitioningSuitechecks 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'sGpuOptimizeWriteExchangeExec.Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance
This PR was built and prepared using an AI assistant.