feat: add a pluggable RNG seam for native embedders#423
Draft
feat: add a pluggable RNG seam for native embedders#423
Conversation
Member
Author
|
@szhorvat please take a look! |
|
@antoneri I will! We're running oral exams here so it's a bit busy, I might only get to it on the weekend. Thanks so much for making these improvements! |
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.
Closes #411
Summary
This PR adds a native RNG injection seam for embedders while keeping Infomap's default behavior unchanged.
Randomtype-erased and copyable so it can wrap a seedable standard-engine-compatible RNGsetRandomEngine(...)API onInfomapConfigsetConfig(...),reseed(...), and subnetwork/non-main Infomap creationWhy
igraph currently carries a downstream patch to replace Infomap's internal RNG with its own RNG. The existing implementation hardcodes
std::mt19937into core runtime code, which makes that integration awkward and requires patching algorithm-adjacent code.This change introduces a narrow upstream-supported seam so downstream consumers can adapt their own RNG implementation without patching the optimizer logic.
Embedder example
Impact
std::mt19937Validation
make build-nativemake test-native CTEST_ARGS='-R "infomap_cpp_lifecycle_tests"'make test-native CTEST_ARGS='-R "infomap_cpp_config_tests|infomap_cpp_lifecycle_tests"'