Skip to content

[SPARK-58177][GRAPHX] Fix wrong operand in SVD++ aggregateMessages combiner#57314

Closed
Ma77Ball wants to merge 1 commit into
apache:masterfrom
Ma77Ball:SPARK-58177
Closed

[SPARK-58177][GRAPHX] Fix wrong operand in SVD++ aggregateMessages combiner#57314
Ma77Ball wants to merge 1 commit into
apache:masterfrom
Ma77Ball:SPARK-58177

Conversation

@Ma77Ball

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Fix the Phase-2 aggregateMessages combiner in SVDPlusPlus.run, which seeded the _2 accumulator from the wrong operand:

-          val out2 = g2._2.clone()
+          val out2 = g1._2.clone()
           BLAS.nativeBLAS.daxpy(out2.length, 1.0, g2._2, 1, out2, 1)

Why are the changes needed?

The next line adds g2 on top, so the result should be g1 + g2. Because the code started with g2 instead of g1, it computed g2 + g2 and discarded g1. Any node with two or more edges ended up with the wrong value. The matching code just below already does it the right way (g1 + g2).

Does this PR introduce any user-facing change?

No

How was this patch tested?

Verified with a unit test (UT) that feeds two concrete updates through the combiner and checks the merged _2 value, plus the existing suite: build/sbt "graphx/testOnly org.apache.spark.graphx.lib.SVDPlusPlusSuite" passes. With the faulty code, the output does not match the expected sum; with the fix, it does:

_2 value
Input g1._2 [3, 4]
Input g2._2 [30, 40]
Expected (g1._2 + g2._2) [33, 44]
Faulty code output [60, 80] (wrong: 2 * g2._2, drops g1._2)
Corrected code output [33, 44] (correct)

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

No

@Ma77Ball

Ma77Ball commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

cc @srowen @dongjoon-hyun @HyukjinKwon, PTAL when you have time.

@srowen srowen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch, you are right.
I've long since lost my setup to merge PRs, so I hope someone else who's active can merge this.

@Ma77Ball

Copy link
Copy Markdown
Contributor Author

Hello @srowen, thank you for the information and I'll keep that in mind for the future. I greatly appreciate the review.

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Ma77Ball, can we please also consider adding a regression test to SVDPlusPlusSuite?

@Ma77Ball

Copy link
Copy Markdown
Contributor Author

Thank you @uros-b and @HyukjinKwon for the review. For the regression test, I can open another Jira ticket and PR to work on this. Or would you prefer it to be done on this PR?

@Yicong-Huang Yicong-Huang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will help merge this then. Also LGTM

Yicong-Huang pushed a commit that referenced this pull request Jul 20, 2026
…mbiner

### What changes were proposed in this pull request?

Fix the Phase-2 `aggregateMessages` combiner in `SVDPlusPlus.run`, which seeded the `_2` accumulator from the wrong operand:

```diff
-          val out2 = g2._2.clone()
+          val out2 = g1._2.clone()
           BLAS.nativeBLAS.daxpy(out2.length, 1.0, g2._2, 1, out2, 1)
```

### Why are the changes needed?

The next line adds `g2` on top, so the result should be `g1 + g2`. Because the code started with `g2` instead of `g1`, it computed `g2 + g2` and discarded `g1`. Any node with two or more edges ended up with the wrong value. The matching code just below already does it the right way (`g1 + g2`).

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

No

### How was this patch tested?

Verified with a unit test (UT) that feeds two concrete updates through the combiner and checks the merged `_2` value, plus the existing suite: `build/sbt "graphx/testOnly org.apache.spark.graphx.lib.SVDPlusPlusSuite"` passes. With the faulty code, the output does not match the expected sum; with the fix, it does:

| | `_2` value |
|---|---|
| Input `g1._2` | `[3, 4]` |
| Input `g2._2` | `[30, 40]` |
| Expected (`g1._2 + g2._2`) | `[33, 44]` |
| Faulty code output | `[60, 80]` (wrong: `2 * g2._2`, drops `g1._2`) |
| Corrected code output | `[33, 44]` (correct) |

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

No

Closes #57314 from Ma77Ball/SPARK-58177.

Authored-by: Matthew B. <mgball@uci.edu>
Signed-off-by: Yicong-Huang <17627829+Yicong-Huang@users.noreply.github.com>
(cherry picked from commit b5e242e)
Signed-off-by: Yicong-Huang <17627829+Yicong-Huang@users.noreply.github.com>
@Yicong-Huang

Copy link
Copy Markdown
Contributor

Merge Summary:

Posted by merge_spark_pr.py

@Yicong-Huang

Copy link
Copy Markdown
Contributor

Sorry for the oversight of @uros-b 's comment. @Ma77Ball please feel free to open a [FOLLOWUP] PR to add the regression test.

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.

5 participants