Describe the bug
The round function on GPU returns incorrect precision result. For round(3.1415, 3), GPU returns 3.142 while CPU correctly returns 3.141.
Steps/Code to reproduce bug
Spark-shell Reproduction Code
Environment Setup:
export SPARK_HOME=/path/to/spark-3.3.0
export RAPIDS_JAR=rapids-4-spark_2.12-25.12.0-SNAPSHOT-cuda12.jar
Reproduction Script: test-failures/reproduce-math-expressions-round.scala
// Test: round(3.1415, 3) returns 3.142 instead of 3.141
val floatTest = spark.range(1).select(
| lit(3.1415f).cast("float").as("original"),
| round(lit(3.1415f).cast("float"), 3).as("rounded")
| )
floatTest.show(false)
Run Command (with all 32 configuration parameters):
$SPARK_HOME/bin/spark-shell \
--master local[2] \
--conf spark.sql.optimizer.excludedRules=org.apache.spark.sql.catalyst.optimizer.ConvertToLocalRelation,org.apache.spark.sql.catalyst.optimizer.ConstantFolding \
--conf spark.rapids.sql.enabled=true \
--conf spark.plugins=com.nvidia.spark.SQLPlugin \
--conf spark.sql.queryExecutionListeners=org.apache.spark.sql.rapids.ExecutionPlanCaptureCallback \
--conf spark.rapids.sql.explain=ALL \
--conf spark.rapids.sql.test.isFoldableNonLitAllowed=true \
--conf spark.rapids.sql.csv.read.decimal.enabled=true \
--conf spark.rapids.sql.format.avro.enabled=true \
--conf spark.rapids.sql.format.avro.read.enabled=true \
--conf spark.rapids.sql.format.hive.text.write.enabled=true \
--conf spark.rapids.sql.format.json.enabled=true \
--conf spark.rapids.sql.format.json.read.enabled=true \
--conf spark.rapids.sql.incompatibleDateFormats.enabled=true \
--conf spark.rapids.sql.python.gpu.enabled=true \
--conf spark.rapids.sql.rowBasedUDF.enabled=true \
--conf spark.rapids.sql.window.collectList.enabled=true \
--conf spark.rapids.sql.window.collectSet.enabled=true \
--conf spark.rapids.sql.window.range.byte.enabled=true \
--conf spark.rapids.sql.window.range.short.enabled=true \
--conf spark.rapids.sql.expression.Ascii=true \
--conf spark.rapids.sql.expression.Conv=true \
--conf spark.rapids.sql.expression.GetJsonObject=true \
--conf spark.rapids.sql.expression.JsonToStructs=true \
--conf spark.rapids.sql.expression.StructsToJson=true \
--conf spark.rapids.sql.exec.CollectLimitExec=true \
--conf spark.rapids.sql.exec.FlatMapCoGroupsInPandasExec=true \
--conf spark.rapids.sql.exec.WindowInPandasExec=true \
--conf spark.rapids.sql.hasExtendedYearValues=false \
--conf spark.unsafe.exceptionOnMemoryLeak=true \
--conf spark.sql.session.timeZone=America/Los_Angeles \
--jars $RAPIDS_JAR \
< reproduce-math-expressions-round.scala
Expected behavior
When calling round(3.1415, 3), the function should return 3.141 (rounded to 3 decimal places).
Actual behavior
GPU returns 3.142 instead of 3.141.
Environment details
- Spark Version: 3.3.0
- RAPIDS Version: 25.12.0-SNAPSHOT
- CUDA Version: 12.x
- Test Suite: MathExpressionsSuite
- Test Name: round/bround/floor/ceil
Additional context
- Original Spark Test Location:
spark/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MathExpressionsSuite.scala (line 643)
- Test Logic: Validates rounding functions with various scales and data types
- Impact: Affects numerical accuracy in calculations
Describe the bug
The
roundfunction on GPU returns incorrect precision result. Forround(3.1415, 3), GPU returns3.142while CPU correctly returns3.141.Steps/Code to reproduce bug
Spark-shell Reproduction Code
Environment Setup:
Reproduction Script:
test-failures/reproduce-math-expressions-round.scalaRun Command (with all 32 configuration parameters):
Expected behavior
When calling
round(3.1415, 3), the function should return3.141(rounded to 3 decimal places).Actual behavior
GPU returns
3.142instead of3.141.Environment details
Additional context
spark/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MathExpressionsSuite.scala(line 643)