MNT Don't ship RecordingCallback.record to the workers - #34811
Merged
jeremiedbb merged 1 commit intoAug 25, 2026
Conversation
Member
|
Thanks for the PR, this seems to fix the problem, even if I am not going to claim I understand why 😅. I double-check that the following command does not fail in this PR: On I am going to approve this PR, since this is only used in testing and let @FrancoisPgm do a more thorough review on the actual fix. @jeremiedbb feel free to merge once you have converged with @FrancoisPgm. |
lesteve
approved these changes
Aug 25, 2026
FrancoisPgm
approved these changes
Aug 25, 2026
FrancoisPgm
left a comment
Contributor
There was a problem hiding this comment.
Thanks @jeremiedbb for catching that circular referencing. I'm ok with the fix, we'll just have to keep it in mind if we ever have to deep copy a RecordingCallback for some reason.
prady0t
pushed a commit
to prady0t/scikit-learn
that referenced
this pull request
Sep 2, 2026
jeremiedbb
added a commit
to jeremiedbb/scikit-learn
that referenced
this pull request
Sep 8, 2026
jeremiedbb
added a commit
to jeremiedbb/scikit-learn
that referenced
this pull request
Sep 9, 2026
jeremiedbb
added a commit
to jeremiedbb/scikit-learn
that referenced
this pull request
Sep 9, 2026
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
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.
For public callbacks we make sure to only store plain data on the callback instances. But
RecordingCallbackis there for testing purpose, to check the context tree or the passed estimator for instance so we want to store whole objects.The thing is that the context holds a reference to the callback which itself holds a reference to the record. So we end up nesting the record into the record which makes it grow exponentially.
We assumed that since it would only be used it tests it would be fine but as we grow and strengthen the tests, it looks like it's not fine anymore.
The solution is to not ship the record when the callback is serialized and sent to the workers, because we never need to read the full record from a worker, only from the callback instance in the main process.
This should fix the issue from #34806, #34804
It should also fix #34792
(It already makes the callback test suite twice as fast so worth merging anyway)
ping @lesteve @FrancoisPgm