Skip to content

[SPARK-59162][ML] Replace BLAS calls with while loops in GBT models - #58461

Closed
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:ml-gbt-while-loop-dev-6
Closed

[SPARK-59162][ML] Replace BLAS calls with while loops in GBT models#58461
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:ml-gbt-while-loop-dev-6

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Replace the BLAS dot products in GBTClassificationModel.margin and
GBTRegressionModel.predict with indexed while loops that accumulate each tree prediction and
weight directly. Remove the now-unused BLAS imports.

Why are the changes needed?

The BLAS calls first allocate an array containing every tree prediction and then invoke native BLAS
for a small dot product on every model prediction. Direct accumulation avoids the temporary array
and native-call overhead, reducing prediction overhead and Spark Connect server pressure.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

The existing GBT classifier and regressor suites passed:

build/sbt 'mllib/testOnly org.apache.spark.ml.classification.GBTClassifierSuite'
build/sbt 'mllib/testOnly org.apache.spark.ml.regression.GBTRegressorSuite'

Was this patch authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (GPT-5)

zhengruifeng added a commit that referenced this pull request Sep 2, 2026
### What changes were proposed in this pull request?

Replace the BLAS dot products in `GBTClassificationModel.margin` and
`GBTRegressionModel.predict` with indexed `while` loops that accumulate each tree prediction and
weight directly. Remove the now-unused BLAS imports.

### Why are the changes needed?

The BLAS calls first allocate an array containing every tree prediction and then invoke native BLAS
for a small dot product on every model prediction. Direct accumulation avoids the temporary array
and native-call overhead, reducing prediction overhead and Spark Connect server pressure.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

The existing GBT classifier and regressor suites passed:

```
build/sbt 'mllib/testOnly org.apache.spark.ml.classification.GBTClassifierSuite'
build/sbt 'mllib/testOnly org.apache.spark.ml.regression.GBTRegressorSuite'
```

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (GPT-5)

Closes #58461 from zhengruifeng/ml-gbt-while-loop-dev-6.

Authored-by: Ruifeng Zheng <ruifengz@apache.org>
Signed-off-by: Ruifeng Zheng <ruifengz@apache.org>
(cherry picked from commit 9b81792)
Signed-off-by: Ruifeng Zheng <ruifengz@apache.org>
@zhengruifeng

Copy link
Copy Markdown
Contributor Author

Merge Summary:

Posted by merge_spark_pr.py

@zhengruifeng
zhengruifeng deleted the ml-gbt-while-loop-dev-6 branch September 2, 2026 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants