Open
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
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.
I really like your hierarchical feature setup via the
Treeclass, but found it ran a bit slow due to using Python loops and lists. This PR vectorizes more of theTree.sample()function so it runs a lot faster. On my laptop, the original implementation takes 7 hours to go through 100 Million samples in batches of 10k, but this vectorized implementation runs 100 Million samples in 6 minutes (70x speedup). It's likely possible to get this to go faster with more effort, but figured this is already a good starting place.This also changes the implementation so
Tree.sample()always requires a batch_size param, and always returns a tensor, but I figure this is probably what's wanted in practice anyway. I also added some test coverage for the changes in Pytest, asserting that this implementation matches what's specified in the JSON file.No worries if this doesn't fit into your vision of the project, but just figured I'd share this implementation in case it's helpful to others!