Abstract
Pathological diagnosis is essential for cancer diagnosis, with whole slide images (WSIs) providing critical histopathological and cellular information. However, the "gigapixel" nature of WSIs presents a significant computational challenge. Current Transformer-based models, while accurate, suffer from quadratic complexity and memory bottlenecks. We introduce PathRWKV, a novel State Space Model (SSM) designed for slide-level feature modeling. PathRWKV employs an asymmetric design that samples tiles during training for efficiency but iterates over all tiles during inference via a recurrent module. This approach enables comprehensive slide-level perception without the memory constraints of traditional attention mechanisms. Evaluated on 11 datasets with over 17,000 WSIs, PathRWKV outperforms nine state-of-the-art methods across 10 downstream tasks, offering a scalable and efficient solution for digital pathology.
Introduction
In digital pathology, analyzing Whole Slide Images is a massive undertaking. A single slide can contain hundreds of thousands of individual image tiles. Existing workflows typically use Multiple Instance Learning (MIL), which extracts features from tiles and aggregates them for a slide-level diagnosis. However, researchers face a "trilemma" between memory usage, global context, and computational efficiency. While Transformers capture global context well, their $O(N^2)$ complexity makes it impossible to process an entire slide at once. Conversely, simpler pooling methods are efficient but fail to capture complex spatial relationships. PathRWKV bridges this gap by combining the parallelizable training of Transformers with the constant-memory inference of Recurrent Neural Networks (RNNs).
The PathRWKV Architecture
PathRWKV is built upon the RWKV (Receptance Weighted Key Value) architecture, specifically adapted for the unique demands of pathology. The core of the model is the Slide-level Encoder, which utilizes two specialized modules: Time Mix and Channel Mix. These modules allow the model to dynamically weigh the importance of different tiles and their feature interactions, effectively handling variable tissue sizes across different slides.
To further enhance robustness, PathRWKV incorporates a Multi-Task Learning (MTL) module. Instead of training separate models for individual clinical indicators—such as Gleason scores, tumor staging, or survival prediction—the MTL head allows the model to learn from multiple tasks simultaneously. This shared learning process improves feature representation and training efficiency by leveraging correlations between different clinical indicators.
Asymmetric Training and Inference
The primary innovation of PathRWKV is its asymmetric processing strategy. This design addresses the conflict between the need for high-throughput training and the requirement for comprehensive, low-variance inference.
- Training (Sampling-based): During training, the model processes a random subset of tiles in parallel. The authors provide a mathematical proof (the "Unbiased Gradient" proof) showing that training on these random subsets provides an unbiased estimate of the full-slide gradient, ensuring efficient convergence.
- Inference (Recurrence-based): During inference, the model switches to a Recurrent Module. It iterates through every single tile on the slide, maintaining a "running state" of information. This allows the model to scale up to the entire slide—processing thousands of tiles—without ever exceeding GPU memory limits. This full-slide processing significantly reduces prediction variance compared to sampling-only methods.
Experimental Results
PathRWKV was validated on a massive scale using 11 datasets totaling 17,292 WSIs, covering tasks from cancer grading to survival analysis. Key results include:
- Superior Performance: PathRWKV outperformed nine recent state-of-the-art methods (including CLAM, TransMIL, and MambaMIL) in 9 out of 11 datasets.
- Classification Accuracy: It achieved top-tier performance on the PANDA dataset (79.3% accuracy for prostate cancer grading) and CAMELYON16 (94.6% for metastasis detection).
- Regression and Survival: On the TCGA-Lung dataset, it reached a correlation of 0.610 for FEV1 prediction, a significant leap over previous SSM-based approaches like S4MIL.
- Generalization: Unlike Transformers, which often show a large "generalization gap" (overfitting) on small clinical datasets, PathRWKV's recurrent state acts as a natural regularizer, maintaining a better balance between training and validation performance.
Conclusion
PathRWKV represents a significant step forward in scaling whole slide image analysis. By utilizing a linear-complexity SSM architecture and an asymmetric training/inference paradigm, it overcomes the memory and efficiency barriers that have limited previous deep learning models in pathology. Its ability to process entire gigapixel slides efficiently paves the way for more reliable and comprehensive automated clinical diagnostics.
Summary updated