Skip to content

Improved performance 4x-5x, also added sqlite output support v2 - #12

Open
choosehappy wants to merge 37 commits into
mainfrom
dev-aj
Open

Improved performance 4x-5x, also added sqlite output support v2#12
choosehappy wants to merge 37 commits into
mainfrom
dev-aj

Conversation

@choosehappy

Copy link
Copy Markdown
Owner

added tests, typing, and other llm generated things

JulienMassonnet and others added 30 commits February 4, 2026 21:07
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).
choosehappy and others added 5 commits July 30, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants