Skip to content

[SPARK-57957][ML][TESTS] Deflake GaussianMixtureSuite 'GMM support instance weighting' on macOS using well-posed data#57035

Closed
HyukjinKwon wants to merge 1 commit into
apache:masterfrom
HyukjinKwon:ci-fix/agent5-gmm-macos-wellposed
Closed

[SPARK-57957][ML][TESTS] Deflake GaussianMixtureSuite 'GMM support instance weighting' on macOS using well-posed data#57035
HyukjinKwon wants to merge 1 commit into
apache:masterfrom
HyukjinKwon:ci-fix/agent5-gmm-macos-wellposed

Conversation

@HyukjinKwon

@HyukjinKwon HyukjinKwon commented Jul 6, 2026

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Change the GMM support instance weighting test to fit rDataset with k=2 instead of fitting k=5 on KMeansSuite.generateKMeansData(50, 3, 5).

Why are the changes needed?

The generated KMeans data is 5 clusters of identical points (zero within-cluster variance). Fitting k=5 Gaussians makes the covariances singular and the EM fit ill-posed, so the uniform-weighted and unweighted fits converge to different component-collapse patterns. On the macOS-26 runner (build_maven_java21_macos26) this deterministically fails the mixture-weight comparison (0.0197 vs 0.1047).

Reducing the instance weight (as in SPARK-37317, which reduced 100->90) and increasing maxIter were both verified on a macOS-26 runner to NOT help — increasing maxIter actually makes a component collapse further (7.6e-11 vs 0.116). Running the same unweighted == uniform-weighted invariant on well-posed data (rDataset, real variance, k=2 — already used stably by another test in this suite) makes both fits converge to the same optimum.

Does this PR introduce any user-facing change?

No, test-only.

How was this patch tested?

GaussianMixtureSuite on a macOS-26 GitHub Actions runner.

Also passes on Linux.

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

Yes.

This pull request and its description were written by Isaac.

…stance weighting' on macOS using well-posed data

### What changes were proposed in this pull request?
Change the `GMM support instance weighting` test to fit `rDataset` with `k=2` instead of fitting `k=5`
on `KMeansSuite.generateKMeansData(50, 3, 5)`.

### Why are the changes needed?
The generated KMeans data is 5 clusters of identical points (zero within-cluster variance). Fitting k=5
Gaussians makes the covariances singular and the EM fit ill-posed, so the uniform-weighted and unweighted
fits converge to different component-collapse patterns. On the macOS-26 runner
(`build_maven_java21_macos26`) this deterministically fails the mixture-weight comparison
(0.0197 vs 0.1047). Reducing the instance weight (as in SPARK-37317) and increasing maxIter were both
verified on macOS-26 to NOT help (maxIter makes a component collapse further, 7.6e-11 vs 0.116). Running
the same unweighted==uniform-weighted invariant on well-posed data (`rDataset`, real variance, k=2 -
already used stably by another test in this suite) makes both fits converge to the same optimum. Verified
green on a macOS-26 runner.

### Does this PR introduce _any_ user-facing change?
No, test-only.

### How was this patch tested?
Ran GaussianMixtureSuite on a macOS-26 GitHub Actions runner: 13 succeeded, 0 failed (previously the
instance-weighting test failed deterministically on macOS-26).

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

This pull request and its description were written by Isaac.
HyukjinKwon added a commit that referenced this pull request Jul 6, 2026
…tance weighting' on macOS using well-posed data

### What changes were proposed in this pull request?
Change the `GMM support instance weighting` test to fit `rDataset` with `k=2` instead of fitting `k=5` on `KMeansSuite.generateKMeansData(50, 3, 5)`.

### Why are the changes needed?
The generated KMeans data is 5 clusters of identical points (zero within-cluster variance). Fitting k=5 Gaussians makes the covariances singular and the EM fit ill-posed, so the uniform-weighted and unweighted fits converge to different component-collapse patterns. On the macOS-26 runner (`build_maven_java21_macos26`) this deterministically fails the mixture-weight comparison (0.0197 vs 0.1047).

Reducing the instance weight (as in SPARK-37317, which reduced 100->90) and increasing maxIter were both verified on a macOS-26 runner to NOT help — increasing maxIter actually makes a component collapse further (7.6e-11 vs 0.116). Running the same `unweighted == uniform-weighted` invariant on well-posed data (`rDataset`, real variance, `k=2` — already used stably by another test in this suite) makes both fits converge to the same optimum.

### Does this PR introduce _any_ user-facing change?
No, test-only.

### How was this patch tested?
`GaussianMixtureSuite` on a macOS-26 GitHub Actions runner.

- **Before (failing on `apache/spark` macOS-26, `build_maven_java21_macos26`):** https://github.com/apache/spark/actions/runs/28753698265/job/85259893661 — `GMM support instance weighting *** FAILED ***`, `Expected 0.01972564065075309 and 0.10476714410584831 to be within 0.001`.
- **After (passing with this change, macOS-26 runner):** https://github.com/HyukjinKwon/spark-agent6/actions/runs/28773420633/job/85311928908 — `GaussianMixtureSuite: Tests: succeeded 13, failed 0`, `All tests passed.`

Also passes on Linux.

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

This pull request and its description were written by Isaac.

Closes #57035 from HyukjinKwon/ci-fix/agent5-gmm-macos-wellposed.

Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
(cherry picked from commit 0a6bbee)
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
HyukjinKwon added a commit that referenced this pull request Jul 6, 2026
…tance weighting' on macOS using well-posed data

### What changes were proposed in this pull request?
Change the `GMM support instance weighting` test to fit `rDataset` with `k=2` instead of fitting `k=5` on `KMeansSuite.generateKMeansData(50, 3, 5)`.

### Why are the changes needed?
The generated KMeans data is 5 clusters of identical points (zero within-cluster variance). Fitting k=5 Gaussians makes the covariances singular and the EM fit ill-posed, so the uniform-weighted and unweighted fits converge to different component-collapse patterns. On the macOS-26 runner (`build_maven_java21_macos26`) this deterministically fails the mixture-weight comparison (0.0197 vs 0.1047).

Reducing the instance weight (as in SPARK-37317, which reduced 100->90) and increasing maxIter were both verified on a macOS-26 runner to NOT help — increasing maxIter actually makes a component collapse further (7.6e-11 vs 0.116). Running the same `unweighted == uniform-weighted` invariant on well-posed data (`rDataset`, real variance, `k=2` — already used stably by another test in this suite) makes both fits converge to the same optimum.

### Does this PR introduce _any_ user-facing change?
No, test-only.

### How was this patch tested?
`GaussianMixtureSuite` on a macOS-26 GitHub Actions runner.

- **Before (failing on `apache/spark` macOS-26, `build_maven_java21_macos26`):** https://github.com/apache/spark/actions/runs/28753698265/job/85259893661 — `GMM support instance weighting *** FAILED ***`, `Expected 0.01972564065075309 and 0.10476714410584831 to be within 0.001`.
- **After (passing with this change, macOS-26 runner):** https://github.com/HyukjinKwon/spark-agent6/actions/runs/28773420633/job/85311928908 — `GaussianMixtureSuite: Tests: succeeded 13, failed 0`, `All tests passed.`

Also passes on Linux.

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

This pull request and its description were written by Isaac.

Closes #57035 from HyukjinKwon/ci-fix/agent5-gmm-macos-wellposed.

Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
(cherry picked from commit 0a6bbee)
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
HyukjinKwon added a commit that referenced this pull request Jul 6, 2026
…tance weighting' on macOS using well-posed data

### What changes were proposed in this pull request?
Change the `GMM support instance weighting` test to fit `rDataset` with `k=2` instead of fitting `k=5` on `KMeansSuite.generateKMeansData(50, 3, 5)`.

### Why are the changes needed?
The generated KMeans data is 5 clusters of identical points (zero within-cluster variance). Fitting k=5 Gaussians makes the covariances singular and the EM fit ill-posed, so the uniform-weighted and unweighted fits converge to different component-collapse patterns. On the macOS-26 runner (`build_maven_java21_macos26`) this deterministically fails the mixture-weight comparison (0.0197 vs 0.1047).

Reducing the instance weight (as in SPARK-37317, which reduced 100->90) and increasing maxIter were both verified on a macOS-26 runner to NOT help — increasing maxIter actually makes a component collapse further (7.6e-11 vs 0.116). Running the same `unweighted == uniform-weighted` invariant on well-posed data (`rDataset`, real variance, `k=2` — already used stably by another test in this suite) makes both fits converge to the same optimum.

### Does this PR introduce _any_ user-facing change?
No, test-only.

### How was this patch tested?
`GaussianMixtureSuite` on a macOS-26 GitHub Actions runner.

- **Before (failing on `apache/spark` macOS-26, `build_maven_java21_macos26`):** https://github.com/apache/spark/actions/runs/28753698265/job/85259893661 — `GMM support instance weighting *** FAILED ***`, `Expected 0.01972564065075309 and 0.10476714410584831 to be within 0.001`.
- **After (passing with this change, macOS-26 runner):** https://github.com/HyukjinKwon/spark-agent6/actions/runs/28773420633/job/85311928908 — `GaussianMixtureSuite: Tests: succeeded 13, failed 0`, `All tests passed.`

Also passes on Linux.

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

This pull request and its description were written by Isaac.

Closes #57035 from HyukjinKwon/ci-fix/agent5-gmm-macos-wellposed.

Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
(cherry picked from commit 0a6bbee)
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
HyukjinKwon added a commit that referenced this pull request Jul 6, 2026
…tance weighting' on macOS using well-posed data

### What changes were proposed in this pull request?
Change the `GMM support instance weighting` test to fit `rDataset` with `k=2` instead of fitting `k=5` on `KMeansSuite.generateKMeansData(50, 3, 5)`.

### Why are the changes needed?
The generated KMeans data is 5 clusters of identical points (zero within-cluster variance). Fitting k=5 Gaussians makes the covariances singular and the EM fit ill-posed, so the uniform-weighted and unweighted fits converge to different component-collapse patterns. On the macOS-26 runner (`build_maven_java21_macos26`) this deterministically fails the mixture-weight comparison (0.0197 vs 0.1047).

Reducing the instance weight (as in SPARK-37317, which reduced 100->90) and increasing maxIter were both verified on a macOS-26 runner to NOT help — increasing maxIter actually makes a component collapse further (7.6e-11 vs 0.116). Running the same `unweighted == uniform-weighted` invariant on well-posed data (`rDataset`, real variance, `k=2` — already used stably by another test in this suite) makes both fits converge to the same optimum.

### Does this PR introduce _any_ user-facing change?
No, test-only.

### How was this patch tested?
`GaussianMixtureSuite` on a macOS-26 GitHub Actions runner.

- **Before (failing on `apache/spark` macOS-26, `build_maven_java21_macos26`):** https://github.com/apache/spark/actions/runs/28753698265/job/85259893661 — `GMM support instance weighting *** FAILED ***`, `Expected 0.01972564065075309 and 0.10476714410584831 to be within 0.001`.
- **After (passing with this change, macOS-26 runner):** https://github.com/HyukjinKwon/spark-agent6/actions/runs/28773420633/job/85311928908 — `GaussianMixtureSuite: Tests: succeeded 13, failed 0`, `All tests passed.`

Also passes on Linux.

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

This pull request and its description were written by Isaac.

Closes #57035 from HyukjinKwon/ci-fix/agent5-gmm-macos-wellposed.

Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
(cherry picked from commit 0a6bbee)
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
HyukjinKwon added a commit that referenced this pull request Jul 6, 2026
…tance weighting' on macOS using well-posed data

### What changes were proposed in this pull request?
Change the `GMM support instance weighting` test to fit `rDataset` with `k=2` instead of fitting `k=5` on `KMeansSuite.generateKMeansData(50, 3, 5)`.

### Why are the changes needed?
The generated KMeans data is 5 clusters of identical points (zero within-cluster variance). Fitting k=5 Gaussians makes the covariances singular and the EM fit ill-posed, so the uniform-weighted and unweighted fits converge to different component-collapse patterns. On the macOS-26 runner (`build_maven_java21_macos26`) this deterministically fails the mixture-weight comparison (0.0197 vs 0.1047).

Reducing the instance weight (as in SPARK-37317, which reduced 100->90) and increasing maxIter were both verified on a macOS-26 runner to NOT help — increasing maxIter actually makes a component collapse further (7.6e-11 vs 0.116). Running the same `unweighted == uniform-weighted` invariant on well-posed data (`rDataset`, real variance, `k=2` — already used stably by another test in this suite) makes both fits converge to the same optimum.

### Does this PR introduce _any_ user-facing change?
No, test-only.

### How was this patch tested?
`GaussianMixtureSuite` on a macOS-26 GitHub Actions runner.

- **Before (failing on `apache/spark` macOS-26, `build_maven_java21_macos26`):** https://github.com/apache/spark/actions/runs/28753698265/job/85259893661 — `GMM support instance weighting *** FAILED ***`, `Expected 0.01972564065075309 and 0.10476714410584831 to be within 0.001`.
- **After (passing with this change, macOS-26 runner):** https://github.com/HyukjinKwon/spark-agent6/actions/runs/28773420633/job/85311928908 — `GaussianMixtureSuite: Tests: succeeded 13, failed 0`, `All tests passed.`

Also passes on Linux.

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

This pull request and its description were written by Isaac.

Closes #57035 from HyukjinKwon/ci-fix/agent5-gmm-macos-wellposed.

Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
(cherry picked from commit 0a6bbee)
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
@HyukjinKwon

Copy link
Copy Markdown
Member Author

Merge Summary:

Posted by merge_spark_pr.py

@dongjoon-hyun dongjoon-hyun 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.

+1, LGTM. Thank you!

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.

3 participants