Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-25793][ML]call SaveLoadV2_0.load for classNameV2_0 #22790

Closed
wants to merge 4 commits into from

Conversation

huaxingao
Copy link
Contributor

What changes were proposed in this pull request?

The following code in BisectingKMeansModel.load calls the wrong version of load.

      case (SaveLoadV2_0.thisClassName, SaveLoadV2_0.thisFormatVersion) =>
        val model = SaveLoadV1_0.load(sc, path)

@SparkQA
Copy link

SparkQA commented Oct 22, 2018

Test build #97756 has finished for PR 22790 at commit d599f83.

  • This patch passes all tests.
  • This patch does not merge cleanly.
  • This patch adds no public classes.

@@ -126,7 +126,7 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
val model = SaveLoadV1_0.load(sc, path)
model
case (SaveLoadV2_0.thisClassName, SaveLoadV2_0.thisFormatVersion) =>
val model = SaveLoadV1_0.load(sc, path)
val model = SaveLoadV2_0.load(sc, path)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, nice catch!

Copy link
Member

@dongjoon-hyun dongjoon-hyun Oct 22, 2018

Choose a reason for hiding this comment

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

This is not a regression, but it looks like a correctness or data loss issue at Spark 2.4.0 new feature.
Do you know why https://issues.apache.org/jira/browse/SPARK-25793 is created as a Minor and Documentation issue?

Copy link
Member

Choose a reason for hiding this comment

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

@@ -126,7 +126,7 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
val model = SaveLoadV1_0.load(sc, path)
model
case (SaveLoadV2_0.thisClassName, SaveLoadV2_0.thisFormatVersion) =>
val model = SaveLoadV1_0.load(sc, path)
val model = SaveLoadV2_0.load(sc, path)
Copy link
Member

Choose a reason for hiding this comment

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

Is there no test to verify calling correct load method?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can improve the write/load model tests in order to include also a different distance measure from the default one. In this way we should catch this error. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

Do we have ever use SaveLoadV2_0 to save model for now? Looks BisectingKMeansModel.save simply calls SaveLoadV1_0.save to save models.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@viirya @mgaido91
I will change the BisectingKMeansModel.save to

BisectingKMeansModel.SaveLoadV2_0.save(sc, this, path)

@SparkQA
Copy link

SparkQA commented Oct 22, 2018

Test build #97794 has finished for PR 22790 at commit d599f83.

  • This patch fails PySpark unit tests.
  • This patch does not merge cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 22, 2018

Test build #97824 has finished for PR 22790 at commit d599f83.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member

Retest this please.

@SparkQA
Copy link

SparkQA commented Oct 23, 2018

Test build #97882 has finished for PR 22790 at commit d599f83.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

cc @mengxr @WeichenXu123 how serious is it? shall we treat it as a blocker?

@SparkQA
Copy link

SparkQA commented Oct 23, 2018

Test build #97904 has finished for PR 22790 at commit 77902bc.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@huaxingao
Copy link
Contributor Author

retest this please

@mengxr
Copy link
Contributor

mengxr commented Oct 23, 2018

This shouldn't block 2.4.0 release. Based on the code, it doesn't introduce regression to existing features (just using V1 format and ignore trainingCost and distanceMeasure). Correctness issue occurs only when someone uses a non-default distanceMeasure and then save/load. Could someone help confirm?

If current vote passes, we can list it as an known issue in the release notes and fix it in 2.4.1. If other blockers show up, we fix it before RC5. Btw, this PR needs a regression test in order to merge.

@SparkQA
Copy link

SparkQA commented Oct 23, 2018

Test build #97928 has finished for PR 22790 at commit 77902bc.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@huaxingao
Copy link
Contributor Author

I added a regression test in org.apache.spark.mllib.clustering.BisectingKMeansSuite
I could add the following test in ml package.

  test("SPARK-25793") {
    val bisectingKMeans = new BisectingKMeans()
    bisectingKMeans.setDistanceMeasure(DistanceMeasure.COSINE)
    val readBisectingKMeans = testDefaultReadWrite(bisectingKMeans)
    assert(bisectingKMeans.distanceMeasure === readBisectingKMeans.distanceMeasure)
  }

But the bug doesn't really affect the above test. With the bug, even though mllib BisectingKMeansModel.load will call V1_0 load and gives a model with default value of distanceMeasure, in ml package, BisectingKMeansModelReader.load will call metadata.getAndSetParams(model) which will set the distanceMeasure to the correct value (DistanceMeasure.COSINE).

    override def load(path: String): BisectingKMeansModel = {
      val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
      val dataPath = new Path(path, "data").toString
      val mllibModel = MLlibBisectingKMeansModel.load(sc, dataPath)
      val model = new BisectingKMeansModel(metadata.uid, mllibModel)
      metadata.getAndSetParams(model)
      model
    }

@SparkQA
Copy link

SparkQA commented Oct 23, 2018

Test build #97942 has finished for PR 22790 at commit 29c9ca0.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mgaido91
Copy link
Contributor

Agree with @mengxr about this not being a blocker. Please notice this is a problem only for the mllib API, for which we can also avoid supporting new features AFAIK.

@cloud-fan
Copy link
Contributor

Is this ready to go? We are going to have another RC, and would be good to include it.

@WeichenXu123
Copy link
Contributor

LGTM.

@@ -109,7 +109,7 @@ class BisectingKMeansModel private[clustering] (

@Since("2.0.0")
override def save(sc: SparkContext, path: String): Unit = {
BisectingKMeansModel.SaveLoadV1_0.save(sc, this, path)
BisectingKMeansModel.SaveLoadV2_0.save(sc, this, path)
}

override protected def formatVersion: String = "1.0"
Copy link
Member

Choose a reason for hiding this comment

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

Is this formatVersion needed to change too?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say yes, but actually this is never used. I think we can actually remove this from the trait.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, good catch! need change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the formatVersion to 2.0. There are quite a few files that implement trait Saveable and have formatVersion. I don't feel comfortable to change other files for this PR. Maybe I will open a separate jira to remove formatVersion from trait Saveable?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree on that, I already have a patch for removing it (moreover this PR can target 2.4, while removal should be done only on master I think). I am submitting it. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

I created #22830 for that, thanks.

@mgaido91
Copy link
Contributor

LGTM

@SparkQA
Copy link

SparkQA commented Oct 25, 2018

Test build #98036 has finished for PR 22790 at commit 0decb23.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

thanks, merging to master/2.4!

asfgit pushed a commit that referenced this pull request Oct 26, 2018
## What changes were proposed in this pull request?
The following code in BisectingKMeansModel.load calls the wrong version of load.
```
      case (SaveLoadV2_0.thisClassName, SaveLoadV2_0.thisFormatVersion) =>
        val model = SaveLoadV1_0.load(sc, path)
```

Closes #22790 from huaxingao/spark-25793.

Authored-by: Huaxin Gao <huaxing@us.ibm.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit dc9b320)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@asfgit asfgit closed this in dc9b320 Oct 26, 2018
jackylee-ch pushed a commit to jackylee-ch/spark that referenced this pull request Feb 18, 2019
## What changes were proposed in this pull request?
The following code in BisectingKMeansModel.load calls the wrong version of load.
```
      case (SaveLoadV2_0.thisClassName, SaveLoadV2_0.thisFormatVersion) =>
        val model = SaveLoadV1_0.load(sc, path)
```

Closes apache#22790 from huaxingao/spark-25793.

Authored-by: Huaxin Gao <huaxing@us.ibm.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
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.

8 participants