\documentclass{midl} % Include author names

% The following packages will be automatically loaded:
% jmlr, amsmath, amssymb, natbib, graphicx, url, algorithm2e
% ifoddpage, relsize and probably more
% make sure they are installed with your latex distribution


% \usepackage{subfig}
\usepackage{multirow}%
\usepackage{amsmath,amssymb,amsfonts}%
% \usepackage{amsthm}%
\usepackage{mathrsfs}%
\usepackage[title]{appendix}%
\usepackage{xcolor}%
\usepackage{textcomp}%
\usepackage{manyfoot}%
\usepackage{booktabs}%
\usepackage{algorithm}%
\usepackage{algorithmicx}%
\usepackage{algpseudocode}%
\usepackage{listings}%

\usepackage{caption}
\usepackage{wrapfig}
% \usepackage{subfig} 

\usepackage{soul}

\newcommand{\sref}[1]{Section~\ref{#1}}
\newcommand{\cref}[1]{Chapter~\ref{#1}}
\newcommand{\srefs}[2]{Sections~\ref{#1} and \ref{#2}}
\newcommand{\aref}[1]{Algorithm~\ref{#1}}
\newcommand{\appref}[1]{Appendix~\ref{#1}}
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\newcommand{\nsd}[2]{#1 {\scz $\pm$ #2}}


\usepackage{mwe} % to get dummy images


\jmlryear{2026}\jmlrworkshop{Full Paper -- MIDL 2026}\jmlrvolume{-- nnn}\editors{Accepted for publication at MIDL 2026}

\title[eWSI: Efficient Whole Slide Image Analysis]{Domain Adaptation Without the Compute Burden for Efficient Whole Slide Image Analysis}


% More complicate cases, e.g. with dual affiliations and joint authorship
\midlauthor{\Name{Umar Marikkar\nametag{$^{1}$}} 
% \orcid{1111-2222-3333-4444} 
\Email{u.marikkar@surrey.ac.uk}\\
\Name{Muhammad Awais\nametag{$^{1,2}$}} \Email{muhammad.awais@surrey.ac.uk}\\
\Name{Sara Atito\nametag{$^{1,2}$}} \Email{sara.atito@surrey.ac.uk}\\
\addr $^{1}$ Institute for People-Centered AI, University of Surrey\\
\addr $^{2}$ Centre of Vision, Speech and Signal Processing, University of Surrey
}

\begin{document}

\maketitle

\begin{abstract}
Computational methods on analyzing Whole Slide Images (WSIs) enable early diagnosis and treatments by supporting pathologists in detection and classification of tumors. However, the extremely high resolution of WSIs makes end-to-end training impractical compared to typical image analysis tasks. To address this, most approaches use pre-trained feature extractors to obtain fixed representations of whole slides, which are then combined with Multiple Instance Learning (MIL) for downstream tasks. These feature extractors are typically pre-trained on natural image datasets such as ImageNet, which fail to capture domain-specific characteristics. Although domain-specific pre-training on histopathology data yields more relevant feature representations, it remains computationally expensive and fail to capture task-specific characteristics within the domain. To address the computational cost and lack of task-specificity in domain-specific pre-training, we propose EfficientWSI (eWSI), a careful integration of Parameter-Efficient-Fine-Tuning (PEFT) and Multiple Instance Learning (MIL) that enables end-to-end training on WSI tasks.  We evaluate eWSI on seven WSI-level tasks over Camelyon16, TCGA and BRACS datasets. Our results show that eWSI when applied with ImageNet feature extractors yields strong classification performance, matching or outperforming MILs with in-domain feature extractors, alleviating the need for extensive in-domain pre-training. Furthermore, when eWSI is applied with in-domain feature extractors, it further improves classification performance in most cases, demonstrating its ability to capture task-specific information where beneficial. Our findings suggest that eWSI provides a task-targeted, computationally efficient path for WSI tasks, offering a promising direction for task-specific learning in computational pathology.
\end{abstract}

\begin{keywords}
Histopathology, Multiple Instance Learning, Domain adaptation, Parameter-efficient fine-tuning
\end{keywords}

\begin{figure}[htb]
    \centering
    \includegraphics[width=0.5\columnwidth]{figures/abstract.pdf}
    \caption{Moving from ImageNet to domain specific encoders, an easy path through eWSI (radial axis is \%AUC).}
    \label{fig:abstract}
\end{figure}


\section{Introduction}\label{sec1}


Computational pathology has gained prominence in assisting pathologists by automating routine observational and analytical tasks in histopathology, thereby facilitating early diagnosis, prognosis assessment, and clinical decision-making. In particular, computational methods using deep learning for Whole Slide Image (WSI) analysis have been developed to automatically detect malignant tumor regions, classify cancer subtypes, and identify molecular properties of tissue, augmenting traditional pathology workflows that rely on manual examination. 

However, traditional deep learning methods for image processing cannot directly be applied on WSIs due to memory constraints. WSIs are extremely large, and high-magnification WSIs can reach sizes on the order of gigapixels \cite{chen2022scaling}. Therefore, the common approach is to tile WSIs into a large collection of smaller patches (e.g.: \(\approx 10\mathrm{k}\) at a tiling resolution of \(224 \times 224\) pixels),  pre-compute patch representations through image encoders ahead of time, and perform learning on these fixed patch representations. The latter process of learning from frozen patch representations is typically carried out using Multiple Instance Learning (MIL) methods. In the context of WSI analysis, MIL methods are designed to learn a global slide-level WSI representation by aggregating the collection of individual patch representations using lightweight architectures. 


Since MIL methods rely on fixed patch representations, downstream task performance is heavily dependent on the quality of those representations. In spite of that, MIL studies \cite{ilse2018attention, zhang2023attention, deng2024crossscalemultiinstancelearningpathological, shao2021transmil} typically rely on features obtained from image encoder models pre-trained on ImageNet \citep{deng2009imagenet}, hence their performance on WSI tasks is bottlenecked. While applying MIL methods with in-domain pretrained image encoders \citep{WANG2022102559, Kang_2023_CVPR, filiot2023scaling, lu2024visual, shao2025mil} improves downstream performance, such pretraining is computationally expensive. Moreover, even with the use of publicly available in-domain pre-trained encoders, the reliance on fixed patch representations prevents the model from learning task-specific characteristics directly from raw WSI data.

This motivates the exploration of learning protocols that are not bottle-necked by patch representations, while remaining computationally efficient to train. We first build on the observation that existing ImageNet pre-trained encoders already capture low-level features such as intensity levels and texture patterns, which are also relevant in WSI data. Based on this, we investigate an end-to-end framework that reduces reliance on extensive pretraining while allowing task-specific characteristics to be learned directly from raw data. We refer to this framework as \textbf{EfficientWSI} \textbf{(eWSI)}. eWSI combines parameter-efficient fine-tuning (PEFT) with a tailored MIL architecture. In eWSI, the PEFT component adapts encoder weights minimally yet effectively to capture task-specific information at the patch-level. In turn, the MIL architecture is able to leverage the enriched patch-level information to construct a stronger task-specific slide-level representation.

We evaluate eWSI on seven downstream tasks over Camelyon16 \cite{bejnordi2017diagnostic}, TCGA \cite{tomczak2015review}, and BRACS \cite{brancati2022bracs} datasets. When applied with ImageNet encoders, eWSI outperforms standard MIL-only methods that rely on frozen patch representations extracted from ImageNet encoders, and achieves performance comparable to MIL methods using in-domain patch representations (see \figureref{fig:abstract}). Moreover, applying eWSI with in-domain encoders yields further gains on most tasks, indicating that the framework effectively leverages task information from low-level data where beneficial. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% BIG SKIP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\section{Prior Works}

We review existing studies on Multiple Instance Learning, the predominant paradigm for solving WSI tasks; end-to-end learning for WSIs, which is the primary aim of this work; and the emergence of PEFT methods based on low-rank adaptation, which we leverage to enable end-to-end learning.

\paragraph{Multiple Instance Learning.}

A significant body of research exists on MIL methods, particularly for histopathology and standard MIL benchmarks. \citet{ilse2018attention} introduce attention-based MIL (ABMIL), using a learned weight vector to aggregate input features. TransMIL \citep{shao2021transmil} replaces ABMIL's attention-pooling with a Vision Transformer (ViT) \citep{dosovitskiy2020image} variant and Nyström based self attention approximation. Recent advancements include ACMIL \citep{zhang2023attention}, which mitigates overfitting in ABMIL, and AEM \citep{zhang2024aem}, which incorporates a loss for attention values itself. IBMIL \citep{lin2023interventional} addresses contextual bias using backdoor adjustment, while Snuffy \citep{jafarinia2024snuffy} combines patch prediction with multi-headed attention. Multi-magnification methods \citep{li2021dual, deng2024crossscalemultiinstancelearningpathological, mirabadi2024grasp, thandiackal2022differentiable} show slight improvements but are excluded here. This study focuses on single magnification encoder training, leaving multi-magnification approaches for future work. 

\paragraph{End-to-end processing for WSIs.}

End-to-end WSI training research is limited due to the computational constraints caused by WSI size. Early works by \citet{chikontwe2020multiple} propose Convolutional Neural Networks (CNNs) for joint patch and slide-level classification, selecting top-k patches per epoch for end-to-end training, which is reliant on the pre-computation of all patches at the start of an epoch. Similarly, EPL \citep{pmlr-v121-xie20a} and C2C \citep{sharma2021cluster} both leverage patch clustering and use cluster centroid patches to perform end-to-end training. However, they rely on expensive pre-computation—either by clustering all features or per epoch, which incurs significant computational overhead. In contrast, we implement data-efficient patch sampling during training. GIGA-SSL \citep{lazard2023giga} pre-trains WSIs using self-supervised using contrastive learning but freezes slide representations during fine-tuning, limiting task-specific adaptation capabilities. Snuffy \citep{jafarinia2024snuffy} applies PEFT as pre-training step, but similarly lacks end-to-end learning. Streaming-CLAM \citep{DOOPER2023102881} combines streaming with CLAM \citep{lu2021data} for end-to-end training, achieving high AUC on Camelyon16 but with significant computational overhead (165 seconds per forward pass and 1 hour per epoch on Camelyon16). In contrast, pre-training image encoders on histopathology datasets already achieves comparable performance with less time than StreamingCLAM.


\paragraph{Parameter Efficient Fine-tuning using low-rank matrices.}

DCD \citep{li2021revisiting} is one of the initial studies to introduce the idea of low-rank matrices for deep neural networks through dynamic convolutions via matrix decompositions. LoRA \citep{hu2021lora} extend this by freezing pre-trained weights and fine-tuning attention projection matrices in LLMs. Subsequent works \citep{zhang2023adalora, liu2024dora, koohpayeganinola} improve efficiency through adaptive rank allocation, separating magnitude and direction changes, or using random basis functions with learnable scalars. In this study, we implement LoRA as the chosen PEFT method, however eWSI can be applied with other PEFT strategies. On integrating PEFT during fine-tuning for WSIs, \citet{LEE2025110031} perform a thorough benchmark on pathology foundation models, and show that PEFT often outperforms full fine-tuning on WSI downstream tasks. However, their experiments are carried out on large-scale workstations (4$\times$ A6000 GPUs) and do not investigate the use of PEFT as a domain adaptation, but rather as a task-adaptation. In contrast, eWSI allows end-to-end training from ImageNet checkpoints on small-scale GPUs, enabled by stochastic sampling, PEFT and the carefully designed MIL aggregator. 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% BIG SKIP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Methods}\label{sec:meth}

We first describe the preliminaries, including the WSI processing pipeline and the standard multiple-instance learning (MIL) formulation. We then detail the workings of eWSI.

\subsection{Preliminaries}

\paragraph{WSI processing pipeline.}

We use the terms \textbf{WSI} and \textbf{patches} to refer to the whole slide image and the local image tiles within the WSI, respectively. For simplicity, we assume that the tiled WSI patches are in a single magnification. Thus, a WSI is represented as,
\begin{align}
    \mathbf{X} &= \{ x_{n} \mid n \in N \} \in \mathbb{R}^{N \times 3 \times H \times W}
\end{align}

where \( x_{n} \) is a patch at location \( n \), \( N \) is the number of patches, and \( (H,W) \) are the dimensions of the patches within the WSI. Typically, the tiling resolution is set to \(224 \times 224\) pixels, consistent with the common practice in computer vision tasks. The goal is to solve the task \( P(y \mid \mathbf{X}, \phi) \), where \( y = \phi (\mathbf{X}) \) is the outcome of the WSI given input \(\mathbf{X}\) and model \(\phi\). The outcome \(y\) is binary in most WSI classification tasks. 

We define the overall model \(\phi\) as a sequence comprising an image encoder \( f(.) \), an aggregator \( g(.) \), and a classifier \( c(.) \). Given the set of patches \(\mathbf{X} = \{ x_{n} \mid n \in N \}\), the image encoder converts the \( N \) patches into \( N \) local patch representations \eqref{eq:pm}, aggregates the patch representations using \(g(\cdot)\), and classifies the aggregated WSI representation using \(c(\cdot)\) as,
\begin{align}
    \mathbf{p} &= \{ f(x_{n}) \mid n \in N \} \in \mathbb{R}^{N \times D}, \label{eq:pm} \\
    z &= g(\mathbf{p}) \in \mathbb{R}^{1 \times D}, \quad y = c(z) \in \mathbb{R}, \label{eq:agg} 
\end{align}

where \(D\) is the feature dimensionality of \(f(\cdot)\), and \( y \) is the predicted WSI outcome. The MIL model generally contains both \( g(.) \) and \( c(.) \).

\paragraph{The MIL assumption and its relevance to WSI tasks.}

The MIL assumption is that, given a `bag' of `instances' with unknown instance labels but a known bag-level overall label, a positive bag must contain at least one positive instance, while a negative bag contains only negative instances. Formally, let a bag of instances be denoted as $B = \{x_1, x_2, \dots, x_n\}$ with label $Y \in \{0,1\}$, where $Y=1$ indicates a positive bag and $Y=0$ a negative bag. The MIL assumption can be expressed as,
\begin{align}
Y = 1 \;\text{if}\; \exists\, i \in \{1,\dots,N\} \text{ s.t. } y_i = 1,\; \text{else } 0.
\end{align}

where $y_i \in \{0,1\}$ is the (unknown) label of instance $x_i$. Thus, a positive bag ($Y=1$) contains at least one positive instance, while a negative bag ($Y=0$) contains none. In the context of WSI analysis, the MIL assumption translates naturally where each WSI can be regarded as a bag $B$, consisting of a set of patches $\mathbf{X}=\{x_1, x_2, \dots, x_N\}$ that serve as the instances. The WSI is assigned a slide-level label $Y \in \{0,1\}$ (e.g., tumor present or absent), while individual patch labels $\{y_i\}$ remain unknown. In this setting, a WSI is labelled positive ($Y=1$) if at least one patch in the WSI contains tumor tissue ($y_i=1$ for some $i$), and negative ($Y=0$) otherwise. Since only bag-level (slide-level) labels are available during training and patch-level annotations are rarely accessible, MIL has emerged as the default paradigm for solving task-specific problems using WSIs.

\subsection{The eWSI Framework}

We implement EfficientWSI (eWSI) to learn task-level WSI representations, without relying on heavy compute resources. eWSI enables on-site training for various downstream tasks on general purpose GPUs. The core components of eWSI are: \textbf{(1) Patch sampling:} A strategy for extracting $M$ patches from each WSI at every training iteration, allowing efficient computations and diverse coverage of the WSI’s tissue regions across training, \textbf{(2) PEFT adaptation:} An encoder with selectively trainable components for effective domain adaptation, and
\textbf{(3) MIL aggregation:} A gated linear pooling mechanism designed for robust feature aggregation under variable sampling rates, while integrating well with the PEFT encoder. Through this framework, we achieve a balance between efficiency and effective learning, enabling a practical solution for adapting general-purpose models to the task-specific characteristics of WSI data. Below, we elaborate on each component of eWSI. 

\paragraph{Patch sampling and PEFT adaptation.} To reduce computational overhead while keeping the patch encoder $f(\cdot)$ learnable to obtain task-specific patch representations, we perform random patch sampling. To enable effective adaptation of pre-trained encoder weights, we adopt parameter-efficient fine-tuning (PEFT). Specifically, we replace a frozen patch encoder $f(\cdot)$  with a Low-Rank Adaptation (LoRA) encoder \cite{hu2021lora} to fine-tune a frozen backbone on a sparse set of patches sampled from a WSI. The LoRA encoder selectively fine-tunes only the query (\(\mathtt{q}\)) and feed-forward (\(\mathtt{mlp}\)) parameters within the network. This targeted adaptation focuses on updating the components of the encoder that acts as the latent signal (\(\mathtt{q}\)) and the overall knowledge base (\(\mathtt{mlp}\)). 

Formally, given the input $\mathbf{X}=\{x_1, x_2, \dots, x_N\}$, we perform random patch sampling without replacement to obtain a sparse set of patches \(\mathbf{X_M}\), 
\begin{align}
    \mathbf{X_M} &= \mathtt{sample}(\mathbf{X}, M) \in \mathbb{R}^{M \times 3 \times h \times w}, 
\end{align}
where  \(M\) is the sampled count of patches. For each sampled patch \(\mathrm{x}_{m}\), we pass it through a \(\mathtt{LoRA_{q,mlp}}\) encoder to obtain the collection of patch representations \(\mathbf{p}\).
\begin{align}
    \mathbf{p} &= \{ \mathrm{p}_m\mid m \in M \} \in \mathbb{R}^{M \times D} \quad \text{~where~} \quad \mathrm{p}_m = \mathtt{LoRA_{q,mlp}}(\mathrm{x}_{m}) .
\end{align}

 As mentioned above, we adapt only the \(\mathtt{q}\) and \(\mathtt{mlp}\) weights of the encoder. We validate the setting of these learnable layers in \sref{sec:analysis}.

    
\paragraph{MIL aggregation.} Given the patch-level representations \(\mathbf{p}\), we design a simple yet effective MIL aggregator that integrates well with PEFT and conforms with the core MIL assumption. Traditional attention-based MIL methods, such as ABMIL and ACMIL \citep{ilse2018attention, zhang2023attention}, tend to under perform when the number of sampled patches \(M\) is small, which we show later in \sref{sec:analysis}. In contrast, we introduce a simple MIL aggregator \(\mathtt{LinMax}\), which is a stack of \(L\) fully connected layers with \(\tanh(\cdot)\) activations, followed by a max-pooling operation over the patch/instance dimension. This architecture retains the robustness of max-pooling (while also conforming to the MIL assumption) while increasing representational capacity through increased layer depth as opposed to simple max-pooling. Given the encoded patch representations \(\mathbf{p} \in \mathbb{R}^{M \times D}\), we compute the global WSI representation \(\mathbf{z}\) as,
\begin{align}
    \mathbf{h}^{(l)} &= \tanh(\mathbf{h}^{(l-1)} \mathbf{W}^{(l)} + \mathbf{b}^{(l)}) \quad \text{for } l = 1, \ldots, L \quad\text{and}\quad \mathbf{h}^{(0)} = \mathbf{p}  \\
    \mathbf{z} &= \max_{m \in \{1,\ldots,M\}} \mathbf{h}^{(L)}_m \in \mathbb{R}^{1 \times d}.
\end{align}

Here, $\mathbf{W}^{(1)} \in \mathbb{R}^{D \times d}$ is the projection matrix of the first layer that reduces embedding dimensionality. The subsequent projection matrices $\mathbf{W}^{(2)} \dots \mathbf{W}^{(L)}$ are isotropic (i.e.: $\mathbb{R}^{d \times d}$). Similarly, dimensionality of the biases follow the same rule with $\mathbf{b}^{(l)} \in \mathbb{R}^{D}$ and $\mathbf{b}^{(2)} \dots \mathbf{b}^{(L)} \in \mathbb{R}^{d}$. After the stacked linear layers, max-pooling is applied element-wise across the \(M\) samples. Finally, the obtained global representation \(\mathbf{z}\) is passed through a task-specific classifier \(c(\cdot)\) to yield the overall WSI outcome. Typically, \(c(\cdot)\) is a linear classifier.  


The reduced dimension $d$ is chosen such that the overall number of parameters across $\mathbf{W}^{(1)},\mathbf{b}^{(1)} \dots \mathbf{W}^{(L)},\mathbf{b}^{(L)}$ matches a single linear layer with dimension $D$. 
% 
% 
% For example, if $D=384$ and $L=3$, this will yield $d=166$ when rounded off to the nearest even integer. We perform this reduction to explicitly measure the effect of stacking layers without increasing the model capacity via parameter count.}
% 
Formally, given a desired depth of $L$, we solve $Ld^2  + (L+D+1)d+(-D^2-D) = 0$ for $d$, where $d$ is then rounded off to the nearest even integer. For example, if $D=384$ and $L=3$, this will yield $d=166$ when rounded off to the nearest even integer. We perform this reduction to explicitly measure the effect of stacking layers without increasing the model capacity via parameter count.




\subsection{Experimental details} 
\label{exp:details}

\paragraph{Datasets, tasks and baselines.} We run experiments on Camelyon16 for tumor metastasis detection, TCGA for cancer subtype classification (IDC vs. ILC in BRCA, LUAD vs. LUSC in NSCLC) and molecular property prediction (mHRD, tHRD, TNBC in BRCA), and BRACS for 3-way classification (benign, atypical, malignant). We use the published train-test splits for each dataset \citep{wang2016deep, chen2022scaling, lazard2023giga, brancati2022bracs}. For MIL baselines, we reproduce Max-pooling, Max-Pooling followed by an FC layer (FC-Max),  ABMIL \citep{ilse2018attention}, TransMIL \citep{shao2021transmil}, and the recent SoTA ACMIL \citep{zhang2023attention}. We also compare against reported results from DSMIL \citep{li2021dual}, IBMIL \citep{lin2023interventional}, Snuffy \citep{jafarinia2024snuffy}, and AEM \citep{zhang2024aem}. We perform experiments using 5 random seeds for Camelyon and BRACS on a single train-test split, and for 5 pre-defined folds for TCGA.

\paragraph{Model training and evaluation.} We perform our experiments using Vision Transformers (ViT-S/16) \citep{dosovitskiy2020image}. We use three encoder initializations: \textbf{iNet-Sup} which is an image encoder pre-trained on ImageNet using supervised learning, \textbf{iNet-SSL} which is an image encoder pre-trained on ImageNet using iBOT SSL \cite{zhou2021ibot}, and \textbf{Hist-SSL}, an in-house image encoder pre-trained on 4 million patches from 20 TCGA cancer datasets using iBOT. We release Hist-SSL in our repository.

We train MIL baselines with 8192 patches per WSI per iteration for Camelyon16, 2048 patches per iteration for BRACS, and 1024 patches per iteration for TCGA. At high sampling rates ($>$ 1000), we observe no negative effect on downstream performance, while enabling simpler implementation i.e.: batched inputs. We extract patches at a single objective magnification of 20x, using the OpenSlide library \footnote{\url{https://pypi.org/project/openslide-python/}}. For eWSI, per single iteration, we sample 64, 384 and 512 patches per WSI on Camelyon16, and 64 patches on TCGA and BRACS. \textbf{During inference, we use all available patches}. We perform experiments on RTX 2080Ti (MIL baselines and eWSI$_{64}$) and A100/RTX3090 GPUs (eWSI$_{384, 512}$). We further sample 50\% of data tokens per patch during the forward pass during training to minimize redundancy. We use a LoRA rank of $r=4$ and $\alpha=1$. For $\mathtt{LinMax}$, we set $L=3$. 

We use a batch size of 8 for all experiments. We employ AdamW with $\beta=(0.9,0.999)$ and a weight decay of $5e^{-2}$ for heavy regularization. We tune only the learning rate using k-fold cross-validation on the training sets. We set $lr=1e^{-3}$ for iNet-SSL and Hist-SSL, and to $lr=5e^{-4}$ for iNet-Sup, where the lower learning rate ensures stable convergence from a weaker pre-trained checkpoint. A cosine schedule is applied, decaying from $lr$ to $1e^{-6}$, with a linear warm-up from $1e^{-7}$ to $lr$ over the first 5 epochs. We train all models for 100 epochs and perform model ensembling from the final 5 epochs during inference. In practice, convergence typically occurs within 40-50 epochs; however, we observe stable loss throughout training. For consistency, we therefore report all results at 100 epochs, although fewer epochs are sufficient. We release pre-trained models, fine-tuned checkpoints and all code in  \url{https://github.com/umarikkar/eWSI}.




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% BIG SKIP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\begin{table}[htb]

    \caption{Performance Comparison (\% AUC) on Camelyon16 test split. (*: values reported in literature, $\star$: our standardized implementation. {\scriptsize $\pm$ 0.0}: std not reported.)}
    \label{tab:camelyon}
    \centering
    \renewcommand{\arraystretch}{0.85}
    % \small{
    \begin{tabular}{llccc}
        \toprule
        \multirow{2}{*}{\textbf{Encoder state}} & \multirow{2}{*}{\textbf{Method}} & \multicolumn{3}{c}{\textbf{Encoder initialization}} \\
        \cmidrule(l){3-5}
        & & iNet-sup & iNet-SSL & Hist-SSL \\
        \midrule

        \multirow{8}{*}{Frozen:*} 
         & ABMIL       &  79.0  {\scriptsize $\pm$ 4.9} & - & 94.5 {\scriptsize $\pm$ 2.7} \\
         & CLAM-SB     & 76.3  {\scriptsize $\pm$ 4.9} & - & 96.9 {\scriptsize $\pm$ 2.4} \\
         & TransMIL    &  70.6  {\scriptsize $\pm$ 7.6} & - & 94.3 {\scriptsize $\pm$ 0.9} \\
         & DSMIL       &  77.3  {\scriptsize $\pm$ 3.4} & - & 91.7 {\scriptsize $\pm$ 0.0}\\
         & IBMIL       &  79.9  {\scriptsize $\pm$ 5.0} & - & 95.4 {\scriptsize $\pm$ 2.2}\\
         & ACMIL       & \textbf{84.1} {\scriptsize $\pm$ 3.0} & -  & 97.4 {\scriptsize $\pm$ 1.2}  \\
         & Snuffy      & - & - & \textbf{98.7} \scriptsize $\pm$ 0.0 \\
         & AEM         & 80.4 {\scriptsize $\pm$ 2.7} & - & 96.7 {\scriptsize $\pm$ 0.8} \\
        \midrule

        \multirow{6}{*}{Frozen:$\star$} 
         & MaxPool     & 52.2 {\scriptsize $\pm$ 1.8} & 59.2 {\scriptsize $\pm$ 4.7} & 63.3  {\scriptsize $\pm$ 3.2} \\
         & ABMIL       & 71.5 {\scriptsize $\pm$ 1.3} & 87.9 {\scriptsize $\pm$ 1.6} & 96.4 {\scriptsize $\pm$ 0.8} \\
         & TransMIL    & 72.8 {\scriptsize $\pm$ 2.9} & 82.5 {\scriptsize $\pm$ 1.9} & 90.7 {\scriptsize $\pm$ 2.9} \\
         & ACMIL       & \textbf{77.2} {\scriptsize $\pm$ 2.1} & 87.6 {\scriptsize $\pm$ 0.8} & 96.3 {\scriptsize $\pm$ 0.4} \\
         & FC-Max      & 67.8 {\scriptsize $\pm$ 1.3} & 81.8 {\scriptsize $\pm$ 1.8} & \textbf{97.7} {\scriptsize $\pm$ 0.6} \\
         & LinMax       & 73.9 {\scriptsize $\pm$ 2.1} & \textbf{88.0} {\scriptsize $\pm$ 1.8} & 96.7 {\scriptsize $\pm$ 0.4} \\
        \midrule

         & C2C$^{*}$    & - & 91.1 \scriptsize $\pm$ 0.0 & - \\
         & Snuffy-MAE$^{*}$ & - & 91.0 \scriptsize $\pm$ 0.0 & - \\
         Adapter /& Snuffy-DINO$^{*}$ & - & 93.6 \scriptsize $\pm$ 0.0 & - \\
         End-to-End& eWSI$_{64}$  & 90.6 {\scriptsize $\pm$ 0.8} & 94.1 {\scriptsize $\pm$ 1.1} & 97.7 {\scriptsize $\pm$ 1.2} \\
          & eWSI$_{384}$  & 93.3 {\scriptsize $\pm$ 0.6} & \textbf{95.1} {\scriptsize $\pm$ 1.7} & 95.8 {\scriptsize $\pm$ 1.2} \\
         & eWSI$_{512}$  & \textbf{93.4} \scriptsize $\pm$ 0.9 & 94.1 \scriptsize $\pm$ 1.4 & \textbf{98.5} \scriptsize $\pm$ 0.7 \\
        \bottomrule
    \end{tabular}
    % }

\end{table}




\section{Results}

\subsection{Performance of eWSI on downstream tasks}

\paragraph{Tumor metastasis detection on Camelyon16.} We evaluate eWSI and LinMax against state-of-the-art MIL and end-to-end methods on the Camelyon16 test set. As shown in \tableref{tab:camelyon}, LinMax performs similar to other MIL architectures. However, it improves on weaker initializations (i.e.: iNet-Sup) compared to FC-Max, TransMIL and ABMIL. More importantly, LinMax integrates well into PEFT due to its robustness, which we outline in \sref{sec:analysis}. Moreover, eWSI outperforms all MIL methods, achieving a considerable performance gain with iNet-Sup and 512 patches. This improvement remains significant even with only 64 patches, demonstrating robustness to patch sampling.  
With an iNet-SSL encoder, eWSI still surpasses the best MIL method. However, using a Hist-SSL encoder (column 3) improves performance slightly, suggesting its frozen features are already well-suited and require little adaptation via PEFT for Camelyon16.



\paragraph{Cancer subtype classification on TCGA and tumor classification on BRACS.} 

We evaluate our method on BRACS and TCGA datasets (\tableref{tab:bracs_tcga}), where eWSI consistently outperforms MIL methods across tasks and encoders. We observe improvements using eWSI on the in-domain pre-trained encoder Hist-SSL, indicating that eWSI leverages task-specific learning capacity when available. On BRACS, performance improves with iNet-Sup but drops for iNet-SSL and Hist-SSL, possibly due to a learning plateau, as MIL methods show no gains with Hist-SSL.

\newcommand{\pmstd}[1]{{\scriptsize$\pm$#1}}
\newcommand{\rot}[1]{\rotatebox[origin=c]{90}{#1}}

\begin{table}[t]
\centering
\caption{Performance Comparison (\% AUC) on TCGA and BRACS datasets.}
\label{tab:bracs_tcga}
\renewcommand{\arraystretch}{0.85}
\begin{tabular}{l l c c c c c c}
\toprule
& \multirow{2}{*}{\textbf{Method}} & \multicolumn{5}{c}{\textbf{TCGA}} & \multirow{2}{*}{\textbf{BRACS}} \\
\cmidrule(lr){3-7}
&& \textbf{BRCA} & \textbf{NSCLC} & \textbf{mHRD} & \textbf{tHRD} & \textbf{TNBC} & \\
\midrule

\multirow{5}{*}{\rot{\textbf{Inet-sup}}} &
ABMIL       & 83.7 \pmstd{6.4} & 92.8 \pmstd{2.1} & 67.0 \pmstd{6.2} & 72.7 \pmstd{4.2} & 85.7 \pmstd{4.3} & 76.4 \pmstd{2.5} \\
&TransMIL    & 86.4 \pmstd{4.9} & 90.3 \pmstd{3.3} & 61.1 \pmstd{3.9} & 72.9 \pmstd{4.7} & 84.5 \pmstd{7.2} & 73.9 \pmstd{3.3} \\
&FC-Max      & 85.7 \pmstd{3.0} & 94.7 \pmstd{0.9} & 67.4 \pmstd{5.6} & 77.6 \pmstd{4.3} & 82.9 \pmstd{6.6} & 76.5 \pmstd{1.4} \\
&ACMIL       & 86.2 \pmstd{6.3} & 93.6 \pmstd{1.4} & 68.8 \pmstd{2.4} & 78.6 \pmstd{3.2} & 83.4 \pmstd{7.6} & 75.8 \pmstd{1.4} \\
&eWSI$_{64}$ & \textbf{90.9} \pmstd{3.9} & \textbf{95.7} \pmstd{1.3} & \textbf{73.0} \pmstd{5.6} & \textbf{82.1} \pmstd{3.4} & \textbf{90.4} \pmstd{5.2} & \textbf{80.7} \pmstd{0.6} \\
\midrule


\multirow{5}{*}{\rot{\textbf{Inet-SSL}}}
&ABMIL       & 87.6 \pmstd{3.7} & 92.1 \pmstd{1.3} & 67.7 \pmstd{3.6} & 71.5 \pmstd{4.5} & 82.8 \pmstd{4.3} & 77.8 \pmstd{4.6} \\
&TransMIL    & 90.2 \pmstd{5.1} & 93.6 \pmstd{1.2} & 63.7 \pmstd{5.2} & 75.1 \pmstd{4.5} & 76.2 \pmstd{10.3} & \textbf{82.2} \pmstd{1.3} \\
&FC-Max      & 91.6 \pmstd{3.6} & 95.4 \pmstd{1.6} & 69.3 \pmstd{2.8} & 78.7 \pmstd{4.5} & 89.5 \pmstd{3.1} & 80.6 \pmstd{2.1} \\
&ACMIL       & 89.9 \pmstd{4.1} & 94.6 \pmstd{0.6} & 68.2 \pmstd{4.6} & 71.6 \pmstd{3.9} & 86.2 \pmstd{9.0} & 81.3 \pmstd{0.8} \\
&eWSI$_{64}$ & \textbf{93.4} \pmstd{4.3} & \textbf{96.5} \pmstd{1.5} & \textbf{72.6} \pmstd{1.9} & \textbf{81.9} \pmstd{4.6} & \textbf{92.9} \pmstd{4.7} & 81.5 \pmstd{1.3} \\
\midrule

\multirow{5}{*}{\rot{\textbf{Hist-SSL}}}
&ABMIL       & 88.9 \pmstd{5.0} & 94.7 \pmstd{1.5} & 72.0 \pmstd{4.1} & 74.9 \pmstd{4.9} & 88.9 \pmstd{5.7} & 77.9 \pmstd{0.5} \\
&TransMIL    & 88.3 \pmstd{5.9} & 97.1 \pmstd{0.8} & 71.2 \pmstd{3.3} & 74.9 \pmstd{8.7} & 91.3 \pmstd{5.4} & 79.2 \pmstd{0.3} \\
&FC-Max      & 91.7 \pmstd{4.1} & 97.2 \pmstd{1.3} & 74.6 \pmstd{3.6} & 80.8 \pmstd{4.8} & 93.6 \pmstd{2.9} & 80.7 \pmstd{1.7} \\
&ACMIL       & 90.1 \pmstd{4.0} & 96.5 \pmstd{2.1} & 74.1 \pmstd{4.3} & 77.5 \pmstd{5.6} & 89.7 \pmstd{6.3} & \textbf{81.5} \pmstd{1.9} \\
&eWSI$_{64}$ & \textbf{92.4} \pmstd{3.8} & \textbf{97.8} \pmstd{0.8} & \textbf{76.3} \pmstd{3.4} & \textbf{83.7} \pmstd{4.9} & \textbf{93.7} \pmstd{5.3} & 80.7 \pmstd{1.0} \\

\bottomrule
\end{tabular}%
% }
\end{table}


\begin{figure}[t]
\centering
        \includegraphics[width=0.9\columnwidth]{figures/subimgs_each_2.pdf}
    \caption{Robustness of MILs to patch sampling for each initialization under frozen encoder settings. $\bigstar$ denotes the PEFT+Lin-Max$_3$ performance under that setting. Experiments are conducted on Camelyon16, which is particularly sensitive to sampling rate due to smaller regions of interest.}
    \label{fig:maxpoolN}
\end{figure}


\subsection{Analysis}
\label{sec:analysis}

\begin{table}[htb]
\centering
% \small
\begin{minipage}{0.50\textwidth}
    \centering
    \caption{Camelyon16 performance vs. $M$ for different MILs with PEFT (seed=0).}
    \label{tab:lora_mil_patches}
    \begingroup
    \setlength{\tabcolsep}{4pt}% narrower columns if you like
    \renewcommand{\arraystretch}{0.8}% < 1.0 makes it more compact
    \begin{tabular}{l c c c c}
        \toprule
        \textbf{MIL} & \textbf{\#M} & \textbf{i-sup} & \textbf{i-SSL} & \textbf{H-SSL} \\
        \midrule
        \multirow{2}{*}{ABMIL} & 64  & 77.2 & 82.1 & 85.6 \\
                               & 512 & 72.4 & 90.8 & 94.0 \\
         \cmidrule(lr){1-5}
        ACMIL & 64  & 86.9 & 83.6 & 83.2 \\
         \cmidrule(lr){1-5}
        \multirow{2}{*}{FC-Max}  & 64  & 85.5 & 90.8 & 95.9 \\
                                 & 512 & 88.2 & 93.8 & 96.4 \\
        \cmidrule(lr){1-5}
        \multirow{3}{*}{Lin-Max$_{3}$} & 64  & 90.6 & 95.8 & \textbf{97.7} \\
                                       & 384 & 91.4 & \textbf{97.1} & 97.2 \\
                                       & 512 & 93.5 & 96.4 & 97.6 \\
        \bottomrule
    \end{tabular}
    \endgroup
\end{minipage}\hfill
\begin{minipage}{0.46\textwidth}
    \centering
    \caption{Camelyon16 performance vs. different trainable layers. Using $M=64$ and Lin-Max$_{3}$ (seed=0).}
    \label{tab:trainable_layers_ablation}
    \begin{tabular}{l c c c}
        \toprule
        \multirow{2}{*}{Layers} & \multicolumn{3}{c}{\textbf{\% AUC}} \\
        \cmidrule(l){2-4}
         & i-sup & i-SSL & H-SSL \\
        \midrule
        $q$     & 84.8 & 92.0 & 96.0 \\
        $v$     & 85.4 & 93.4 & 97.0 \\
        $q, v$  & 86.7 & 93.6 & \textbf{97.8} \\
        $mlp$   & 89.5 & 94.3 & 95.9 \\
        $q, mlp$& \textbf{90.6} & \textbf{95.8} & 97.7 \\
        \bottomrule
    \end{tabular}
\end{minipage}
\end{table}


\paragraph{The integration of MIL with PEFT.} \tableref{tab:camelyon} shows that stronger encoders consistently yield better performances regardless of MIL. However, unlike in TCGA, where the tumor region covers approximately 70\% of the WSI, the tumor covers approximately only 5\% of the whole WSI in Camelyon16 \citep{li2021dual}. This poses a difficulty in the attempt to integrate PEFT to the WSI training pipeline, as the compute constraints dictate lesser patches (generally \(<\) 500 in a practical setting), as opposed to 8192 patches used for MILs with fixed patch representations. This motivates the need to find MIL architectures that are robust to low patch sampling rates to integrate PEFT into training. 

We first investigate existing MIL architectures and their robustness to sampling rates, as shown in \figureref{fig:maxpoolN}. We find that with fixed patch representation,s attention-based MILs (ABMIL, ACMIL) yield weaker downstream performance with lower sampling rates as opposed to Max-Pooling followed by a linear layer (FC-Max). However, we observe that the overall representation capability of FC-Max is limited as with higher \(M\), it fails to outperform attention-based pooling methods. Assuming layer depth is the limitation, we redesign FC-Max to obtain \(\mathtt{LinMax}\), by distributing the parameters along stacked linear layers with smaller dimensionality. To increase the feature selecting capability of the network, we introduce \(\tanh\) activations between the stacked layers. From \figureref{fig:maxpoolN}, we find that \(\mathtt{LinMax_L}\) (where \textbf{L} is the number of stacked layers) is not only robust but outperforms FC-Max, ABMIL and ACMIL for small $M$, indicating possible integration with PEFT. The trends observed in \figureref{fig:maxpoolN} persist when applying PEFT (see \tableref{tab:lora_mil_patches}), where using FC-Max and \(\mathtt{LinMax}\) results in much higher performance overall as opposed to attention-based methods. This highlights the importance of max-pooling to maintain robustness to patch sampling frequency and stacked layers with activations to improve the selective choosing capability. The effect of activation layers is shown in \appref{app:seq_act} in supplementary material. 

% \paragraph{The choice of layers to adapt using PEFT.} Given that Hist-SSL is pre-trained with iBOT using Inet-SSL initialization, we analyze cross-domain weight transformations, and find that later-layer $\mathtt{mlp}$ components showed the highest magnitude and direction changes, while $\mathtt{q}$ and $\mathtt{k}$ maintained a high degree of change throughout all layers. We provide visualizations for the change of weights in \appref{sec:analysis_layers}. This observation in  terms of $\mathtt{q}$ and $\mathtt{k}$ change is in line with \citet{touvron2022three}, where they suggest that fine-tuning the attention layers ($\mathtt{q,k,v}$) is sufficient for transfer-learning.  However, the study is performed on natural images and does not take into account domain adaptation. We suspect that the change in $\mathtt{mlp}$ weights can be attributed to the domain shift itself. This led us to adopt ($\mathtt{q},\mathtt{mlp}$) as opposed to ($\mathtt{q},\mathtt{v}$) in the original study, showing improved performance especially with ImageNet checkpoints (\tableref{tab:trainable_layers_ablation}). However, for Hist-SSL, learning only $\mathtt{mlp}$ reduced accuracy, suggesting that adapting $\mathtt{q}$ is enough if the overall knowledge base of the ViT ($\mathtt{mlp}$) is sufficient i.e.: domain-specific pre-trained.

\paragraph{Layer and rank assignment for PEFT.} Given that Hist-SSL is pre-trained with iBOT using Inet-SSL initialization, we analyze cross-domain weight transformations, and find that later-layer $\mathtt{mlp}$ components showed the highest magnitude and direction changes, while $\mathtt{q}$ and $\mathtt{k}$ maintained a high degree of change throughout all layers. We provide visualizations for the change of weights in \appref{sec:analysis_layers}. This observation in terms of $\mathtt{q}$ and $\mathtt{k}$ change is in line with \citet{touvron2022three}, where they suggest that fine-tuning $\mathtt{q,k,v}$ is sufficient for transfer-learning.  However, the study is performed on natural images and does not take into account domain adaptation. We suspect that the change in $\mathtt{mlp}$ weights can be attributed to the domain shift itself. This led us to adopt $\mathtt{q},\mathtt{mlp}$ as opposed to $\mathtt{q},\mathtt{v}$ in the original study, showing improved performance especially with ImageNet checkpoints (\tableref{tab:trainable_layers_ablation}). However, for Hist-SSL, learning only $\mathtt{mlp}$ reduced accuracy, suggesting that adapting $\mathtt{q}$ is enough if the overall knowledge base of the ViT ($\mathtt{mlp}$) is sufficient i.e.: domain-specific pre-trained.

\begin{figure*}[htb]
\centering

% -------- LEFT: FIGURE (caption bottom) --------
\begin{minipage}[t]{0.44\linewidth}
\centering
\vspace{0.5ex} % aligns plot top with table body

\includegraphics[width=\linewidth]{figures/ablation_r.pdf}

\captionof{figure}{Camelyon16 performance vs. varying LoRA rank $r$. (seed=0).}
\label{fig:lora_r}
\end{minipage}
\hfill
% -------- RIGHT: TABLE (caption top) --------
\begin{minipage}[t]{0.55\linewidth}
\centering
\captionof{table}{Computational cost for $bs=1$ on an RTX 3090 GPU. \textbf{M}:patch sampling rate. \textbf{p}:trainable parameters. \textbf{V\textsubscript{gpu}}:max VRAM in GB. \textbf{t}:time per epoch in mm:ss. \textbf{T}(h): total time for 100 epochs in hours.}
\label{tab:compute}

\vspace{0.5ex}

\begingroup
\renewcommand{\arraystretch}{0.8}
\begin{tabular}{lccccc}
\toprule
\textbf{Meth.} & \textbf{p$\times10^9$} & \textbf{M} & \textbf{V}\textsubscript{gpu} & \textbf{t}\scriptsize{mm:ss} & \textbf{T}(h)\\
\midrule
Frozen & 0.05 & 8192 & 0.03 & 00:02 & 0.48 \\
\cmidrule(lr){1-6}
\multirow{3}{*}{eWSI} & \multirow{3}{*}{0.27}
  & 64  & 1.10 & 00:15 & 0.42 \\
  && 384 & 6.58 & 01:12 & 2.00 \\
  && 512 & 8.82 & 01:31 & 2.53 \\
\cmidrule(lr){1-6}
% S-CLAM* & 21.50 & all & 40.0 & 742:30 & - \\
C2C     & 21.67 & 64  & 1.10 & 25:04 & 40.8 \\
\bottomrule
\end{tabular}
\endgroup
\end{minipage}


\end{figure*}



We further evaluate the effect of LoRA rank $r$, which governs the size of the reduced space and thereby the overall training capacity of the model. \figureref{fig:lora_r} shows that the highest performance is achieved when $r=4$, and a downward trend is observed with increasing $r$. Further, we find in our experiments that for $r=384$, which is the equivalent of full fine-tuning for ViTs, the model fails to learn from the weaker iNet-sup checkpoint. 

These results indicate that the advantage of LoRA (or PEFT) does not stem from improved training efficiency, as we find that full fine-tuning at $M=64$ is only slightly slower than PEFT fine-tuning, and still much faster than other end-to-end methods described later in \tableref{tab:compute}. Instead, LoRA provides an implicit regularization through its low-rank constraint, which stabilizes the domain shift and yields a better overall encoder state. 



\paragraph{Computational complexity of eWSI.} 

We analyze the computational cost of eWSI and compare it against frozen-encoder fine-tuning and runtimes of existing end-to-end WSI methods, in \tableref{tab:compute}. Within eWSI, both per-epoch runtime and GPU VRAM scale approximately linearly with the number of sampled patches $M$. As most WSI-level downstream tasks involve relatively small datasets, even a setting of $M=512$ is practical, as on Camelyon16, training for 100 epochs takes approximately 2.5 hours. A more efficient configuration with $M=64$ reduces this to 25 minutes. Although the above runtimes exceed those of frozen-encoder fine-tuning, which requires only 3-4 minutes for training, the latter incurs an 26-minute offline feature extraction cost for the training set. When feature extraction is performed online, we observe an  epoch time of 8s at $M=64$, corresponding to $\approx$13 minutes total training time. 

Despite the increased runtime of eWSI, the accuracy gains achieved by eWSI justify this overhead, especially given that the absolute training times remain practical. Compared to existing end-to-end methods, eWSI is substantially more efficient. StreamingCLAM\cite{DOOPER2023102881} reports 165 seconds per forward pass (batch size 1) on Camelyon16 while performing their experiments on a 40GB V100 GPU. For C2C\cite{sharma2021cluster}, we calculate the expected training time per epoch with ViT-S, which contains a full feature-extraction step at each epoch for pre-clustering that requires approximately 26 minutes, resulting in an expected total time of 45 hours for 100 epochs.

% \paragraph{Effect of sparse random sampling given small regions of interest.} Given that Camelyon16 contains smaller ROIs compared to other datasets, we run the risk of sparse sampling not being able to catch the desired tumor region during training, resulting in a false positive sample. Surprisingly, the primary performance metric which is the AUC remains high even in this case. It seems like the model is still able to rank the test samples according to their probability of tumor present. However, with pure thresholding at 0.5 when calculating the acc, we found the performance to be really low, indicating that there's an inherent bias learnt during the sparse sampling when training. For example, with the iNet-SSL encoder, when eWSI is applied with  this in $M=64$, AUC is 95.8\% but with a probability threshold of 0.5, the absolute accuracy is 45.0\%. However, this can be easily rectified by changing the probability threshold. For example, using a threshold of 0.98 will result in an accuracy metric of 88.4\%, which is greater than the accuracy metric observed without eWSI and frozen encoder training with dense sampling during training (79.8\%, see  \tableref{tab:acc_thresholding}). However, this is a manual `hacking' that requires us to know the tumor region statistics beforehand. A more elegant method without manually changing the threshold, is to perform another training run (approx 20 minutes total including feature extraction time) under a frozen encoder setting with the now-trained eWSI encoder, but with dense sampling, resulting in a threshold-free higher absolute accuracy as shown in \tableref{tab:acc_thresholding}. 

\paragraph{Effect of sparse random sampling on downstream inference.}
Given that Camelyon16 contains relatively small regions of interest (ROIs), sparse random sampling runs the risk of failing to capture tumor regions during training, producing false positive supervision at the bag level. Interestingly, even in this setting, the primary evaluation metric (AUC) remains high, suggesting that the model is still able to rank test samples according to their likelihood of tumor presence.

However, when applying a fixed probability threshold of 0.5 to compute accuracy, performance drops substantially, as shown in \tableref{tab:acc_thresholding} for eWSI$_{64}$. For example, when applying eWSI with the iNet-SSL encoder at a sampling rate of $M=64$, the model achieves an AUC of 95.8\%, yet the absolute accuracy at a 0.5 threshold is only 45.0\%. This can be easily rectified by manually adjusting the decision threshold. Using a threshold of 0.98 increases accuracy to 88.4\%, outperforming the accuracy obtained without eWSI under frozen-encoder training with dense sampling (79.8\%; see \tableref{tab:acc_thresholding}). This indicates that there is a bias induced by sparse sampling, where predicted probabilities are systematically shifted toward higher values and biased toward the positive class, rather than a failure to discriminate between tumor and non-tumor samples. 

This form of manual threshold `hacking' however requires prior knowledge of dataset-specific statistics. A more elegant solution that avoids manual threshold selection is to perform an additional training run under a frozen-encoder setting using dense sampling with the now-trained eWSI encoder. This incurs a modest computational overhead (the same time required for frozen encoder fine-tuning) and as shown in \tableref{tab:acc_thresholding}, results in higher absolute accuracy without threshold tuning. We provide more insight into the effect of sparse sampling, and observed failure cases in \appref{app:sparse_sampling}.



\begin{table}[t]
    \centering
    \caption{Camelyon16 performance with bias correction. $p_t$: Probability threshold, BC: Manual bias correction, FE: Frozen encoder fine-tuning with dense sampling starting from eWSI encoder features. ACMIL: frozen encoder with $M=8192$.}
    \begingroup
    \renewcommand{\arraystretch}{0.85}
    \begin{tabular}{lccccccccc}
    \toprule
    \multirow{2}{*}{\textbf{Method}} & \multirow{2}{*}{$p_{t}$} & \multicolumn{2}{c}{{iNet-Sup}} & \multicolumn{2}{c}{{iNet-SSL}} & \multicolumn{2}{c}{{Hist-SSL}} \\
    \cmidrule(lr){3-4}    \cmidrule(lr){5-6}    \cmidrule(lr){7-8}
    &&AUC&Acc.&AUC&Acc.&AUC&Acc.
    \\
    \midrule
     ACMIL     & 0.50  & 78.3 & 72.7   & 90.4 & 79.8   & 96.7 & 90.7  \\
     \cmidrule(lr){1-8}
    \multirow{2}{*}{eWSI$_{64}$}     & 0.50  & 90.6 & 46.5   & 95.8 & 45.0   & \textbf{97.7} & 48.1 \\
      & 0.98  & 90.6 & 82.9   & 95.8 & 88.4   & 97.7 & 92.2       \\
      \cmidrule(lr){1-8}
    eWSI$_{64}$+FE  & 0.50  & \textbf{91.3} & \textbf{83.7}   & \textbf{96.9} & \textbf{94.6}   & 96.9 & \textbf{93.8}   \\
    \bottomrule
    \end{tabular}
    \endgroup
    \label{tab:acc_thresholding}
\end{table}





\section{Conclusion}


We propose eWSI, a practical alternative to compute-heavy pre-training to solve Whole Slide Image classification tasks, using a carefully chosen integration of Parameter-Efficient-Fine-Tuning (PEFT) and Multiple Instance Learning (MIL) that supports efficient and effective end-to-end training on WSIs. We first identify the key limitations of existing MIL methods, particularly when sampling a limited number of patches, and address these issues step-by-step, resulting in a robust MIL framework that integrates well with PEFT. For domain adaptation, we study the transformation of pre-trained weights from ImageNet to the Histopathology domain when pre-training, and explore ways to emulate this transfer effectively while preserving source encoder characteristics. We highlight the effectiveness of our approach on Camelyon16, TCGA and BRACS datasets, where we observe significant improvements over ImageNet pre-trained models. Our results demonstrate that eWSI offers a promising and practical alternative for WSI pre-training using a single general purpose GPU, eliminating the need to rely on pre-trained models. 

\clearpage  % Acknowledgements, references, and appendix do not count toward the page limit (if any)
% Acknowledgments---Will not appear in anonymized version
% \midlacknowledgments{We thank a bunch of people.}


\bibliography{midl26_103}

\newpage

% % \iffalse
\appendix


\section{Schematic diagram for eWSI}

\begin{figure}[htb]
    \begin{center}
    \includegraphics[width=0.85\linewidth]{figures/arch.pdf}
    \end{center}
    \caption{An outline of eWSI. The input patches are randomly sampled and fed into the \(\mathtt{LoRA}\) encoder. The encoded patches are then passed through the LinMax aggregator to yield the global WSI representation \(\mathbf{z}\).} 
    \label{fig:method}
\end{figure}

\section{Further analyses}

\subsection{Sparse patch sampling and its effect on small regions of interest.}
\label{app:sparse_sampling}

We investigate how sparse sampling during training affects small ROIs in test WSIs. We perform patch-wise classification prior to max-pooling, to obtain patch-wise tumor predictions. The threshold to classify a slide as positive or negative is computed via Youden's thresholding \cite{youden1950index}. Using the thresholding, we observed 4 false negative slides with eWSI iNet-SSL encoder, shown in \figureref{fig:sparse_negative}. We observe that even in the samples wrongly classified as negatives, there exists a high probability of tumor prediction at the true location of the tumor. 

\begin{figure}[htb]
    \begin{center}
    \includegraphics[width=0.85\linewidth]{figures/FNs.png}
    \end{center}
    \caption{Patch-predictions versus tumor locations for the 4 observed false negatives using eWSI iNet-SSL and $M=64$. Yellow dots in the heatmaps indicate locations with high probability. The slide IDs are top left:$\mathtt{test\_038}$, top right:$\mathtt{test\_011}$, bottom left:$\mathtt{test\_013}$, and bottom right:$\mathtt{test\_099}$.} 
    \label{fig:sparse_negative}
\end{figure}

We further investigate the relationship between tumor burden and prediction confidence. As the raw prediction probabilities are systematically biased, we focus on the association between the two entities. Specifically, we first compute the tumor percentage as the proportion of annotated tumor area relative to the total tissue area, where tissue is segmented using Otsu’s thresholding method~\cite{otsu1975threshold}. We then measure the association between tumor percentage and slide-level prediction probability using Spearman’s rank correlation~\cite{schober2018correlation}. We observe a strong positive correlation (\(\rho = 0.78\)), indicating a significant monotonic relationship between tumor burden and prediction confidence.




\subsection{Sparse patch sampling and its effects on model convergence.}
\label{app:convergence}

We show the loss curves with sparse and dense sampling in \figureref{fig:convergence}. We find that sparse sampling (with or without eWSI) results in a highly volatile training loss, possibly due to the large number of false positives observed during model training. However, this volatility does not translate to volatility in downstream performance, as we observe an acceptable standard deviation under different random seeds, as shown in \tableref{tab:camelyon}. 




\begin{figure}[t]
\centering
\subfigure[]{
  \includegraphics[width=0.3\linewidth]{figures/convergence_MIL.pdf}
  \label{fig:conv:a}
}
\hfill
\subfigure[]{
  \includegraphics[width=0.3\linewidth]{figures/convergence_MIL64.pdf}
  \label{fig:conv:b}
}
\hfill
\subfigure[]{
  \includegraphics[width=0.3\linewidth]{figures/convergence_eWSI.pdf}
  \label{fig:conv:c}
}
\caption{Training convergence under sparse and dense sampling.  
     (a) MIL with $M{=}8192$, (b) MIL with $M{=}64$, and (c) eWSI with $M{=}64$.}
\label{fig:convergence}
\end{figure}


\subsection{Experiments with larger encoder backbones.}
\label{app:encoders}

We run experiments with a larger iBOT ViT-B checkpoint pre-trained on ImageNet \cite{zhou2021ibot}, and Phikon, a larger histopathology pre-trained checkpoint pre-trained on 40 million TCGA patches  \cite{filiot2023scaling}. \tableref{tab:base_results} shows the Camelyon16 results with the aforementioned encoders, comparing between ACMIL under a frozen encoder setting, and eWSI with $M=64$. 

\begin{table}[htbp]
    \centering
    \caption{Camelyon16 results under different encoder settings. `Patch' denotes the time taken (under inference mode) to pre-compute patches of the training samples of the downstream dataset.}
    \begin{tabular}{lccccc}
        \toprule
         \multirow{2}{*}{\textbf{Method}} & \multicolumn{2}{c}{AUC \%} & \multicolumn{3}{c}{Wall time (min)} \\
         \cmidrule(lr){2-3} \cmidrule(lr){4-6} 
         & iBOT-B & Phikon & Patch & Training & Total \\
         \midrule
         
         ACMIL (Frozen) & 88.08 $\pm$\scriptsize{0.7} & 99.4 $\pm$\scriptsize{0.3} & 48.5 & 6.7 & 55.2 \\
         eWSI$_{64}$ & 91.61 $\pm$\scriptsize{2.2} & 99.0 $\pm$\scriptsize{0.3} & - & 45.8 & 45.8 \\

         \bottomrule
    \end{tabular}
    
    \label{tab:base_results}
\end{table}



\subsection{The effect of sequential layers and activations for LinMax}
\label{app:seq_act}

When analyzing the effect of sequencing the layers and activations in LinMax, we find that LinMax iteratively attenuates and amplifies certain regions of the WSI. This can be seen in \figureref{fig:vis_iter}.

\begin{figure}[htb]
    \centering
    \includegraphics[width=0.7\linewidth]{figures/act_sequence.png}
    \caption{Iterative amplification and attenuation of features in the WSI using LinMax.}
    \label{fig:vis_iter}
\end{figure}

To analyze the effect of different activations, we experiment with Tanh, ReLU and Softsign activations, and no activation functions, where we find out that using no activations still achieves better results than FC-Max, perhaps due to the bottle-necking effect caused by lower dimensionality (see \figureref{fig:activations}). Tanh and Softsign being slightly more effective than ReLU indicates the usefulness of a 'gating' mechanism with upper and lower bounds, where the feature values are cut-off at a lower and upper limit as opposed to gating at 0. 

\begin{figure}[htb]
    \centering
    \includegraphics[width=0.4\linewidth]{figures/activations_2.pdf}
    \caption{Effect of gate-like activation functions}
    \label{fig:activations}
\end{figure}

\begin{figure}[htb]
    \centering
    \includegraphics[width=0.5\columnwidth]{figures/inet_to_hist.pdf}
    \caption{Change of weights in magnitude (top) and direction (bottom) from iNet-SSL to Hist-SSL.}
    \label{fig:inet_to_hist}
\end{figure}

\subsection{The domain transfer from ImageNet to Histopathology}
\label{sec:analysis_layers}

As our histopathology pre-trained encoder (Hist-SSL) is pre-trained using iBOT with the initialization being the same iBOT ImageNet encoder (Inet-SSL), we analyze the transformation in weights from the ImageNet to histopathology domain, by plotting the normalized weight magnitude and direction change for each sub-module in each layer, as shown in \figureref{fig:inet_to_hist}. 

We observed that the highest change in magnitude and direction in the latter layers were for the multi-layer perceptron ($mlp$) components in the ViT block. The query and key vectors ($q$ and $k$),  maintained a high degree of change throughout all layers. This observation is in line with \citep{touvron2022three}, where the authors suggest that fine-tuning the attention layers is sufficient for transfer-learning. However, the study is performed on natural images and does not take into account domain adaptation. We suspect that the change in $mlp$ weights can be attributed to the domain shift itself. 






\section{Additional visualizations}

\subsection{Effect of magnification vs. sampling rate on Camelyon16 performance.}

\begin{figure}[htb]
    \centering
    \includegraphics[width=\linewidth]{figures/mag_vs_subimg.png}
    \caption{Effect of magnification vs. sampling rate $M$ on Camelyon16 performance. Experiments performing with a frozen encoder setting and ACMIL. horizontal axis is the sampling rate and vertical axis is the magnification}
    \label{fig:placeholder}
\end{figure}

\subsection{Patch representations and pre-pooling activation maps}

\figureref{fig:visualization_supp1} shows the sub-image representations and the pre-pooling activation maps for iNet-sup, iNet-sup+eWSI and Hist-SSL, respectively. Upon observing the feature maps, we see a higher similarity between the features of iNet-sup+eWSI with the Hist-SSL reference than to the iNet-sup reference, for both encoder features and pre-pooling features. Both the iNet-sup+eWSI and Hist-SSL pre-pooling features show a sparser map in comparison to iNet-sup, and the higher activations tend to be in the samel location. 

\begin{figure}[htb]
    \centering
    \includegraphics[width=0.5\textwidth]{figures/vis.png}
    \caption{Sub-image representations and the pre-pooling activation maps for iNet-sup, iNet-sup+eWSI and Hist-SSL.}
    \label{fig:visualization_supp1}
\end{figure}

% % \fi

\end{document}
