Reduce memory usage and load time by skipping costly fingerprint generation#296
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes DashAIDataset initialization by manually generating lightweight fingerprints to avoid expensive computation performed by HuggingFace's Dataset constructor. This reduces memory usage and improves load time during dataset uploads.
- Manual fingerprint generation using table metadata and UUID to bypass costly default computation
- Addition of uuid import to support fingerprint creation
- Optimization targets the initialization bottleneck without affecting functionality
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Comment on lines
+61
to
+63
| fingerprint = ( | ||
| f"manual-{hash((table.num_rows, str(table.schema)))}-{str(uuid.uuid4())}" | ||
| ) |
There was a problem hiding this comment.
The fingerprint generation combines a deterministic hash with a random UUID, which could create inconsistency. If the goal is to bypass expensive computation while maintaining some determinism for caching, consider using only the hash of table metadata without the random UUID component.
Suggested change
| fingerprint = ( | |
| f"manual-{hash((table.num_rows, str(table.schema)))}-{str(uuid.uuid4())}" | |
| ) | |
| fingerprint = f"manual-{hash((table.num_rows, str(table.schema)))}" |
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.
Summary
This PR addresses excessive RAM usage and delays when uploading datasets by optimizing the initialization of
DashAIDataset.Problem
DashAIDatasetinherits from HuggingFace’sDatasetclass, whose constructor performs an expensive fingerprint generation step (computing a unique identifier for the dataset).This step significantly increases both initialization time and memory usage, even though the fingerprint is not required for our custom dataset saving/loading workflow.
Fix
The solution is to manually generate a lightweight fingerprint and pass it to the
super()call inDashAIDataset.This bypasses the costly default computation, reducing memory usage and improving dataset loading speed.
Notes
The fingerprint is only used for faster reloads when using HuggingFace’s
save_dataset/load_datasetAPIs, which we do not use.Therefore, this change does not affect functionality or reproducibility within our system.