Make UMAP callback pickleable#6402
Merged
rapids-bot[bot] merged 1 commit intorapidsai:branch-25.04from Mar 6, 2025
Merged
Conversation
The structure of this callback object should really be cleaned up (by moving the callback to the stack before the call to UMAP we can avoid having an object with pointers to itself _and_ better manage the lifetime of the callback instance). This would also let us avoid implementing this callback in cython, which mucks up the default pickling implementation. As is though this is the easiest way to get things pickleable. Users will still need to define `__reduce__` themselves if they add any state to an instance, but given that this code was added for an internal use case and hasn't seen any changes or expansion in 6 years I don't suspect there are many external users of this API. Can always clean this up later if a user asks about it.
jcrist
commented
Mar 6, 2025
| pass | ||
|
|
||
| def on_train_end(self, embeddings): | ||
| pass |
Member
Author
There was a problem hiding this comment.
Added default implementations of the callbacks.
| if self.native_callback.pyCallbackClass == NULL: | ||
| raise ValueError( | ||
| "You need to call `super().__init__` in your callback." | ||
| ) |
Member
Author
There was a problem hiding this comment.
No need for this - __cinit__ is always called
| assert cuml_trust > 0.9 | ||
|
|
||
|
|
||
| def test_callback(): |
Member
Author
There was a problem hiding this comment.
Moved this test to test_umap.py since it's more a test that UMAP calls the callback properly, not a test of the callback itself.
Member
Author
|
/merge |
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.
The structure of this callback object should really be cleaned up (by moving the callback to the stack before the call to UMAP we can avoid having an object with pointers to itself and better manage the lifetime of the callback instance). This would also let us avoid implementing this callback in cython, which mucks up the default pickling implementation. As is though this is the easiest way to get things pickleable. Users will still need to define
__reduce__themselves if they add any state to an instance, but given that this code was added for an internal use case and hasn't seen any changes or expansion in 6 years I don't suspect there are many external users of this API. Can always clean this up later if a user asks about it.Fixes #5282.