Improved performance 4x-5x, also added sqlite output support v2 - #12
Open
choosehappy wants to merge 37 commits into
Open
Improved performance 4x-5x, also added sqlite output support v2#12choosehappy wants to merge 37 commits into
choosehappy wants to merge 37 commits into
Conversation
Merge pull request #6 from choosehappy/dev
Description:
This update optimizes the WSI inference pipeline by replacing the manual batching and memory management logic with a standard PyTorch Dataset and DataLoader implementation.
Key Changes:
Implemented WSIPatchDataset: Handles lazy loading of slide regions. OpenSlide objects are now initialized per-worker to ensure thread safety and avoid pickling issues.
Integrated DataLoader: Replaced manual batch splitting with PyTorch's loader, enabling efficient multi-process data loading, memory pinning, and prefetching.
Streaming Architecture: The pipeline now operates as a true producer-consumer stream. The GPU consumes batches from the loader while a separate multiprocessing pool handles post-processing (watershed/polygonization) asynchronously.
Cleanup: Removed obsolete helper functions (divide_batch, preload_batch, processing, infer_on_batches) that were previously used for manual memory management.
Performance Impact:
This refactor improves GPU utilization by ensuring data is constantly available (prefetching) and reduces the complexity of memory management for large slides.
batch_mem is no longer needed with new implementation
Since the function is no longer needed for slide inference, it was added to the roi inference code directly
I fixed the number of workers used. Since everything works in parallel, it had to be split in two (pre- and post-processing).
…e output is correc and speed hasn't been negatively impacted (a lot of LLM developed code here)
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.
added tests, typing, and other llm generated things