DistillPath: An Efficient 22M Distilled Pathology Encoder Approaching Large Foundation Model Performance
Organizations: Department of Computer Science, ETH Zürich, Switzerland
Abstract
Many high-performing pathology tile encoders are now foundation models with hundreds of millions to over a billion parameters. Encoding and storing the thousands of tiles in each whole-slide image with such models is costly on commodity hardware, so compact encoders that retain useful downstream performance are a valuable alternative. We present DistillPath-KS16, which starts from the existing 22M kaiko ViT-S/16 encoder and improves it by distilling from released pathology encoders used as frozen teachers. The recipe reads only the teachers' final class and patch tokens and trains on 6,000 public slides, needing neither their DINO nor iBOT pretraining heads nor a billion-tile corpus, so it applies to any released encoder that exposes backbone tokens. We distill four teachers spanning 86M to 1.1B parameters into the same student. Every variant improves the kaiko baseline on all three benchmarks we use, EVA, HEST, and PLISM, and the strongest teacher is task-dependent. On the seven-task EVA mean, DistillPath-KS16-Virchow2 reaches , within points of Virchow2, the top-scoring model in our evaluation, at about fewer parameters; it also scores above H0-mini and GPFM on this aggregate metric, though that advantage is task-concentrated rather than uniform. Because it remains a 22M ViT-S/16 with 384-dimensional features, DistillPath-KS16 runs more than faster than Virchow2. Code is available at https://github.com/RamonKaspar/DistillPath, and released model weights are available at https://huggingface.co/collections/RamonK/distillpath.
Figures & tables
| Teacher | RKD / CLS | Patch / total | ||
|---|---|---|---|---|
| H0-mini | 24 | 0.16 | 25.2% | 28.3% |
| UNI2-h | 32 | 0.31 | 24.4% | 24.0% |
| H-optimus-0 | 84 | 0.28 | 25.4% | 24.6% |
| Virchow2 | 56 | 0.30 | 24.5% | 24.5% |
| EVA classification | EVA segmentation | ||||||||
| Model | BACH | PCam | CRC | MHIST | BrHis | Gleas. | CoNSeP | MoNu. | EVA |
| Teachers, reference encoders, and baseline | |||||||||
| Virchow2 (632M) | 0.879 | 0.939 | 0.966 | 0.861 | 0.821 | 0.778 | 0.640 | 0.667 | 0.810 |
| UNI2-h (681M) | 0.917 | 0.951 | 0.966 | 0.821 | 0.859 | 0.772 | 0.630 | 0.643 | 0.806 |
| H-optimus-0 (1.1B) | 0.756 | 0.942 | 0.956 | 0.843 | 0.806 | 0.752 | 0.642 | 0.681 | 0.803 |
| Midnight-12k (1.1B) | 0.900 | 0.929 | 0.966 | 0.799 | 0.816 | 0.799 | 0.624 | 0.658 | 0.799 |
| Model | IDC | PRAD | PAAD | SKCM | COAD | READ | ccRCC | LUNG | LYMPH-IDC | HEST |
|---|---|---|---|---|---|---|---|---|---|---|
| Teachers, reference encoders, and baseline | ||||||||||
| Virchow2 (632M) | 0.592 | 0.348 | 0.472 | 0.619 | 0.259 | 0.209 | 0.274 | 0.553 | 0.256 | 0.398 |
| UNI2-h (681M) | 0.590 | 0.357 | 0.500 | 0.659 | 0.301 | 0.223 | 0.264 | 0.558 | 0.272 | 0.414 |
| H-optimus-0 (1.1B) | 0.598 | 0.385 | 0.491 | 0.645 | 0.309 | 0.222 | 0.268 | 0.559 | 0.259 | 0.415 |
| Midnight-12k (1.1B) | 0.582 | 0.337 | 0.490 | 0.636 | 0.291 | 0.185 | 0.213 | 0.558 | 0.264 | 0.395 |
| GPFM (303M) | 0.566 | 0.342 | 0.460 | 0.589 | 0.248 | 0.165 | 0.259 | 0.547 | 0.237 | 0.379 |
| Model | PLISM score | All pairs cosine | All pairs top-5 | Scanner top-5 | Stain top-5 | Scanner+stain top-5 |
|---|---|---|---|---|---|---|
| Teachers, reference encoders, and baseline | ||||||
| Virchow2 (632M) | 0.447 | 0.744 | 0.094 | 0.516 | 0.203 | 0.076 |
| UNI2-h (681M) | 0.333 | 0.592 | 0.033 | 0.421 | 0.123 | 0.023 |
| H-optimus-0 (1.1B) | 0.480 | 0.686 | 0.124 | 0.668 | 0.240 | 0.103 |
| Midnight-12k (1.1B) | 0.337 | 0.743 | 0.060 | 0.276 | 0.111 | 0.051 |
| GPFM (303M) | 0.264 | 0.594 | 0.009 | 0.253 | 0.049 | 0.006 |
| Model | Params | Dim | EVA | GFLOPs/tile | RTX 4090 | M4 Pro | CUDA peak | MPS alloc. | Storage | ||
|---|---|---|---|---|---|---|---|---|---|---|---|
| tiles/s | slowdown | tiles/s | slowdown | (MiB) | (MiB) | (GiB/1M) | |||||
| DistillPath-KS16-Virchow2 | 21.7M | 384 | 0.795 | 9.2 | 7994 | 396.1 | 374 | 138 | 1.43 | ||
| H0-mini | 85.7M | 768 | 0.784 | 47.1 | 1807 | 80.7 | 1082 | 592 | 2.86 | ||
| GPFM | 303.2M | 1024 | 0.789 | 162.0 | 602 | 26.6 | 2388 | 1666 | 3.81 | ||
| Virchow2 | 631.2M | 1280 | 0.810 | 340.1 | 300 | 12.8 | 4551 | 2662 | 4.77 | ||
| H-optimus-0 | 1134.8M | 1536 | 0.803 | 608.3 | 181 | 7.4 | 7618 | 5146 | 5.72 | ||
| EVA classification | EVA segmentation | ||||||||||
| Model | BACH | PCam | CRC | MHIST | BrHis | Gleas. | CoNSeP | MoNu. | EVA | HEST | PLISM |
| kaiko ViT-S/16 baseline | 0.832 | 0.901 | 0.939 | 0.830 | 0.720 | 0.723 | 0.600 | 0.633 | 0.764 | 0.349 | 0.307 |
| ViT-S/16 IN21K baseline | 0.612 | 0.856 | 0.904 | 0.815 | 0.723 | 0.709 | 0.515 | 0.581 | 0.729 | 0.311 | 0.383 |
| DistillPath-IS16-Virchow2 | 0.828 | 0.919 | 0.959 | 0.773 | 0.754 | 0.762 | 0.586 | 0.587 | 0.763 | 0.358 | 0.490 |
| DistillPath-IS16-HOpt0 | 0.705 | 0.917 | 0.951 | 0.796 | 0.765 | 0.736 | 0.599 | 0.611 | 0.768 | 0.363 | 0.526 |
| DistillPath-IS16-H0mini | 0.764 | 0.920 | 0.952 | 0.784 | 0.688 | 0.735 | 0.605 | 0.597 | 0.754 | 0.377 | 0.543 |
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
| Setting | Value |
|---|---|
| Slide reader | TiffSlide |
| Tissue mask | CLAM detector with Otsu thresholding on a thumbnail bounded to px |
| CLAM contour filtering | median-blur kernel , closing kernel , , , at most 8 holes per contour, reference patch size 512 |
| Magnification sampling | , , , or microns per pixel, selected uniformly |
| Pyramid-level selection | nearest available level to the target scale; level 0 when slide-scale metadata are unavailable |
| Spatial sampling | random coordinates sampled with replacement; at least tissue within the candidate tile |
| Role | Model | Dim | Patch | Registers | Normalization preset |
|---|---|---|---|---|---|
| Student | kaiko ViT-S/16 | 384 | 16 | 0 | kaiko |
| Student | ViT-S/16 IN21K | 384 | 16 | 0 | ImageNet |
| Teacher | H0-mini | 768 | 14 | 4 | H-optimus |
| Teacher | Virchow2 | 1280 | 14 | 4 | ImageNet |
| Teacher | UNI2-h | 1536 | 14 | 8 | ImageNet |
| Teacher | H-optimus-0 | 1536 | 14 | 4 | H-optimus |
| Setting | Value |
|---|---|
| Class-token loss | cosine RKD |
| Class-token cosine coefficient | |
| RKD coefficient | run-specific (Table 10 ) |
| RKD distance term weight | |
| RKD angle term weight | |
| RKD penalty | Huber (smooth ), |
| Student initialization | Teacher | ||
|---|---|---|---|
| kaiko ViT-S/16 | H0-mini | 24 | 0.16 |
| Virchow2 | 56 | 0.30 | |
| UNI2-h | 32 | 0.31 | |
| H-optimus-0 | 84 | 0.28 | |
| ViT-S/16 IN21K | H0-mini | 24 | 0.16 |
| Virchow2 | 28 | 0.39 |
| Setting | Value |
|---|---|
| Optimizer | AdamW |
| (PyTorch default) | |
| (PyTorch default) | |
| Peak learning rate | |
| Final learning rate | |
| Weight decay |
| Model | Step | BACH | PCam | CRC | MHIST | BrHis | Gleas. | CoNSeP | MoNu. | EVA |
|---|---|---|---|---|---|---|---|---|---|---|
| Reference encoders and baselines | ||||||||||
| Virchow2 (632M) | – | 0.879 | 0.939 | 0.966 | 0.861 | 0.821 | 0.778 | 0.640 | 0.667 | 0.810 |
| UNI2-h (681M) | – | 0.917 | 0.951 | 0.966 | 0.821 | 0.859 | 0.772 | 0.630 | 0.643 | 0.806 |
| H-optimus-0 (1.1B) | – | 0.756 | 0.942 | 0.956 | 0.843 | 0.806 | 0.752 | 0.642 | 0.681 | 0.803 |
| Midnight-12k (1.1B) | – | 0.900 | 0.929 | 0.966 | 0.799 | 0.816 | 0.799 | 0.624 | 0.658 | 0.799 |
| GPFM (303M) | – | 0.829 | 0.945 | 0.953 | 0.813 | 0.764 | 0.763 | 0.637 | 0.650 | 0.789 |
| Model | Step | IDC | PRAD | PAAD | SKCM | COAD | READ | ccRCC | LUNG | LYMPH-IDC | HEST |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Reference encoders and baselines | |||||||||||
| Virchow2 (632M) | – | 0.592 | 0.348 | 0.472 | 0.619 | 0.259 | 0.209 | 0.274 | 0.553 | 0.256 | 0.398 |
| UNI2-h (681M) | – | 0.590 | 0.357 | 0.500 | 0.659 | 0.301 | 0.223 | 0.264 | 0.558 | 0.272 | 0.414 |
| H-optimus-0 (1.1B) | – | 0.598 | 0.385 | 0.491 | 0.645 | 0.309 | 0.222 | 0.268 | 0.559 | 0.259 | 0.415 |
| Midnight-12k (1.1B) | – | 0.582 | 0.337 | 0.490 | 0.636 | 0.291 | 0.185 | 0.213 | 0.558 | 0.264 | 0.395 |
| GPFM (303M) | – | 0.566 | 0.342 | 0.460 | 0.589 | 0.248 | 0.165 | 0.259 | 0.547 | 0.237 | 0.379 |
| Model | Step | PLISM | Cosine | Top-5 | Scanner | Stain | Scan+stain |
|---|---|---|---|---|---|---|---|
| Reference encoders and baselines | |||||||
| Virchow2 (632M) | – | 0.447 | 0.744 | 0.094 | 0.516 | 0.203 | 0.076 |
| UNI2-h (681M) | – | 0.333 | 0.592 | 0.033 | 0.421 | 0.123 | 0.023 |
| H-optimus-0 (1.1B) | – | 0.480 | 0.686 | 0.124 | 0.668 | 0.240 | 0.103 |
| Midnight-12k (1.1B) | – | 0.337 | 0.743 | 0.060 | 0.276 | 0.111 | 0.051 |
| GPFM (303M) | – | 0.264 | 0.594 | 0.009 | 0.253 | 0.049 | 0.006 |