-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-51880][ML][PYTHON][CONNECT] Avoid eager model removal in meta algorithms when collectSubModel is true #50682
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88b79b2
to
2fab991
Compare
I suggest to use reference count in client side to make a thorough fix, pseudo code:
|
python/pyspark/ml/tuning.py
Outdated
Comment on lines
117
to
121
if collectSubModel and is_remote(): | ||
# In remote mode, we need to explicitly disable the __del__ which | ||
# seems to be triggered inside this thread. | ||
tl = train._session.client.thread_local # type: ignore[union-attr, operator] | ||
tl.disable_ml_del = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only a fix for CrossValidator.
If user uses model.copy
, it also triggers the error .
2fab991
to
f561d8b
Compare
I filed #50707 |
close in favor of #50707 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Avoid eager model removal in meta algorithms when collectSubModel is true
No matter on classic mode or connect mode, no matter collectSubModel is true or false,
__del__
of models and estimators are always invoked in_parallelFitTasks
.There seems to be an internal copy, I add log in
__del__
to print the address of objectsid(self)/id(self._java_obj)
to be deleted and find that the ids are different from these from finalmodel.subModels
.That is to say, internal copying and removal of model/estimator happen in
_parallelFitTasks
.trigger
spark/python/pyspark/ml/base.py
Lines 256 to 260 in eb48553
so in this
evaluate
:1, copy the model (shares the same ref_id)
2, transform and compute the metric;
3, delete the copied model
Why are the changes needed?
for feature parity
Does this PR introduce any user-facing change?
yes, bug-fix
How was this patch tested?
enabled tests
Was this patch authored or co-authored using generative AI tooling?
no