Paper deep dive
TAP-Path: Task-Adaptive Structural and Token Pruning for Efficient and Trustworthy Pathology Foundation Models
Mehedi Hasan, Ashfak Yeafi, Md Khairul Islam
Intelligence
Status: succeeded | Model: Gemma-4-26B-A4B | Prompt: intel-v1 | Confidence: 93%
Last extracted: 9/5/2026, 1:55:33 AM
Summary
The paper introduces TAP-Path, a task-adaptive compression framework that restructures the pretrained Virchow2 pathology foundation model by physically removing redundant transformer blocks and pruning patch tokens. This approach reduces encoder parameters by 24.96% and compute by 35.20% while maintaining or slightly improving accuracy, calibration, and failure detection capabilities compared to the full model and other baselines like UNI2-h.
Entities (8)
Relation Signals (8)
TAP-Path â restructures â Virchow2
confidence 98% · TAP-Path combines validation-driven transformer-block selection, physical removal of redundant blocks... directly restructures a pretrained Virchow2 encoder
TAP-Path â reducesflopsby â 35.20%
confidence 96% · analytical encoder compute by 35.20% (340.13G to 220.40G FLOPs)
TAP-Path â reducesparametersby â 24.96%
confidence 96% · reducing encoder parameters by 24.96% (631.24M to 473.70M)
TAP-Path â achievesaccuracy â 87.98%
confidence 95% · TAP-Path achieved 87.98±0.067% test accuracy
TAP-Path â evaluatedon â CPTAC
confidence 95% · Frozen external evaluation on 433 CPTAC samples yielded 91.22±0.83% accuracy
Virchow2 â hasaccuracy â 86.89%
confidence 94% · compared with 86.89% for full Virchow2
UNI2-h â hasaccuracy â 87.67%
confidence 94% · 87.67% for UNI2-h
TAP-Path â uses â Hibou-B
confidence 85% · The probabilities used by this selector are generated by a reproducible patch probe... Hibou-B patch embeddings
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
Abstract:Pathology foundation models improve transferable representation learning for histopathology, but recent gains often rely on encoders with hundreds of millions of parameters and high inference cost. We propose TAP-Path, a task-adaptive compression framework that directly restructures a pretrained Virchow2 encoder rather than distilling it into a separate student. TAP-Path combines validation-driven transformer-block selection, physical removal of redundant blocks, input-adaptive patch-token pruning, multi-depth feature recovery, and a lightweight gated task head. The final model retains 24 of 32 transformer blocks and 70% of patch tokens after pruning, reducing encoder parameters by 24.96% (631.24M to 473.70M) and analytical encoder compute by 35.20% (340.13G to 220.40G FLOPs). Across three task-head optimization seeds, TAP-Path achieved $87.98 \pm 0.067%$ test accuracy, $81.26 \pm 0.49%$ balanced accuracy, and $82.38 \pm 0.48%$ macro-F1 on a 32-class histopathology benchmark, compared with 86.89% for full Virchow2 and 87.67% for UNI2-h. TAP-Path achieved a Brier score of $0.1800 \pm 0.0005$ and failure-detection AUROC of $0.9047 \pm 0.0060$. A validation-only rare-aware objective improved rare-class balanced accuracy in a secondary operating analysis. Frozen external evaluation on 433 CPTAC samples yielded $91.22 \pm 0.83%$ accuracy and $91.10 \pm 0.81%$ balanced accuracy. These results show that task-adaptive structural and token sparsification can improve the accuracy-efficiency trade-off of large pathology foundation models while preserving reliability under internal and external evaluation.
Tags
Links
- Source: https://arxiv.org/abs/2609.04071v1
- Canonical: https://arxiv.org/abs/2609.04071v1
Trouble viewing inline? Open PDF directly â
Full Text
89,720 characters extracted from source content.
Expand or collapse full text
TAP-Path: Task-Adaptive Structural and Token Pruning for Efficient and Trustworthy Pathology Foundation Models Mehedi Hasan 1 Ashfak Yeafi 2 Md Khairul Islam 3 1 Department of Computer Science and Engineering, Brac University, Dhaka, Bangladesh 2 E, Khulna University of Engineering & Technology, Khulna, Bangladesh 3 Mathematics and Computer Science, Hobart and William Smith Colleges, Geneva, NY, USA mehedi.hasan1@g.bracu.ac.bd yeafiashfak@gmail.com khairul.robotics@gmail.com Abstract Pathology foundation models have substantially improved transferable representation learning for histopathology, but recent gains increasingly rely on encoders with hundreds of millions of parameters and high inference cost. This cre- ates a practical mismatch between representational scale and task-specific deployment, especially when a downstream ap- plication requires only a subset of the pretrained hierarchy. We propose TAP-Path, a task-adaptive compression frame- work that directly restructures a pretrained Virchow2 encoder rather than distilling it into a separate student. TAP-Path com- bines validation-driven transformer-block selection, physical removal of redundant blocks, input-adaptive patch-token prun- ing, multi-depth feature recovery, and a lightweight gated task head. The final model retains 24 of 32 transformer blocks and 70% of patch tokens after the pruning point, reducing encoder parameters by 24.96% (631.24M to 473.70M) and analytical encoder compute by 35.20% (340.13G to 220.40G FLOPs). Across three task-head optimization seeds, TAP-Path achieved 87.98±0.067% test accuracy, 81.26±0.49% balanced accu- racy, and 82.38±0.48% macro-F1 on a 32-class histopathology benchmark, slightly exceeding full Virchow2 (86.89% accu- racy) and UNI2-h (87.67%) while using fewer deployed pa- rameters and substantially less analytical compute. Beyond predictive performance, we evaluate calibration, probabilistic quality, failure detection, rare-class behavior, and selective pre- diction. TAP-Path obtained a Brier score of 0.1800±0.0005 and failure-detection AUROC of 0.9047±0.0060. A validation- only rare-aware objective increased rare-class balanced accu- racy in a secondary operating analysis, providing a complemen- tary operating point that characterizes the trade-off between overall accuracy and minority-class sensitivity. Frozen exter- nal evaluation on 433 CPTAC samples yielded 91.22±0.83% accuracy and 91.10±0.81% balanced accuracy. These results indicate that task-adaptive structural and token sparsification can move large pathology foundation models toward a more favorable accuracyâefficiency operating point while preserv- ing measurable reliability characteristics under internal and external evaluation. Keywords: Computational pathology; pathology foundation models; structural pruning; token pruning; trustworthy AI; model efficiency. 1 Introduction Digital pathology has moved rapidly from task-specific convolutional pipelines toward large pretrained vision and visionâlanguage foundation models. Models such as UNI, CONCH, Virchow, Prov-GigaPath, CHIEF, Hibou, GPFM, and PathOrchestra have demonstrated that large-scale self- supervised, weakly supervised, or multimodal pretraining can produce reusable histopathology representations across cancer classification, biomarker prediction, retrieval, prognosis, and other downstream tasks [1, 2, 3, 4, 5, 6, 7, 8]. The emerging consensus, however, is not that a single foundation model is uniformly superior. Independent benchmarking has shown substantial task dependence, cohort dependence, sensitivity to adaptation strategy, and variation under external evaluation [9, 10, 11, 12]. This makes deployment efficiency and reliability increasingly important alongside raw predictive performance. The computational cost of contemporary pathology foun- dation models is particularly relevant. From a systems per- spective, this mismatch is amplified at whole-slide scale. A tissue-rich WSI may generate thousands to tens of thousands of candidate tiles at diagnostic magnification, and the encoder is invoked repeatedly before slide-level aggregation or down- stream decision logic. A reduction of one third in per-patch transformer compute therefore compounds across the entire WSI rather than saving only a single forward pass. This ob- servation motivates task-specific restructuring of the patch encoder itself, rather than limiting efficiency analysis to the number of trainable downstream parameters. Virchow2 uses a ViT-H/14-scale encoder with approximately 632M parameters [3], while other leading models are similarly large. Whole- slide applications amplify this burden because a single slide may generate hundreds or thousands of patches. Even when a large encoder is frozen, its stored parameters and forward-pass operations remain present at inference. Parameter-efficient fine-tuning therefore reduces optimization cost but does not necessarily reduce the resident encoder or patch-level inference burden. Recent medical-image studies have increasingly recog- nized lightweight design as a distinct problem from parameter- 1 arXiv:2609.04071v1 [cs.CV] 3 Sep 2026 efficient adaptation [13, 14, 15]. In computational pathology, SUDA explicitly targets this problem by distilling heavy foun- dation models into lightweight students [16]. Distillation can be highly effective, but it changes the model family, requires a teacherâstudent transfer procedure, and may need to be re- peated for new tasks or domains. This leaves an important complementary question: how much of an already pretrained large pathology encoder is actually necessary for a specific downstream task? Generic vision research suggests that substantial redundancy can exist both along transformer depth and within the token sequence. Structured sparsification and token-pruning ap- proaches reduce computation by removing blocks, tokens, or interactions that contribute little to a target task [17, 18, 19, 20, 21]. Nevertheless, pathology foundation models are not ordinary ImageNet classifiers. Histopathological discrimina- tive evidence may occupy small tissue regions, vary across magnification and morphology, and be especially sparse for low-prevalence classes. Aggressive pruning that looks attrac- tive from a FLOP perspective can therefore erase diagnosti- cally useful evidence. The desired objective is not maximum compression alone, but a validated Pareto operating point that preserves task utility while reducing genuine encoder cost. The design philosophy is similar to recent efficiency-oriented vision architectures that explicitly optimize accuracy against param- eters and compute [22], but here the problem is addressed by restructuring a pretrained pathology foundation model rather than designing a new backbone from scratch. A second limitation of efficiency-only evaluation is that a compressed medical model can retain accuracy while becom- ing less trustworthy in ways that aggregate accuracy does not reveal. Calibration error, negative log-likelihood, Brier score, confidence-based failure detection, and selective risk quantify different aspects of whether predicted probabilities are useful for decision support [23, 24, 25]. Recent pathology work has likewise emphasized domain robustness, fairness, and vulner- ability to non-biological scanner or laboratory variation [26, 27, 28]. Thus, a credible compression study in computational pathology should establish not only accuracy and compute reduction but also whether uncertainty remains informative, minority classes are characterized explicitly, and the locked model generalizes to an independent cohort. This study addresses these gaps with TAP-Path, short for TAP-Path, a task-adaptive structural and token pruning frame- work for pathology foundation models. TAP-Path begins from the pretrained Virchow2 encoder and performs validation-only structural analysis to identify a task-relevant subset of trans- former blocks. Unlike freezing or masking, selected blocks are physically retained in the deployed encoder while unselected blocks are removed. The structurally compressed model is then paired with input-adaptive token pruning that preserves the pre- fix token and retains the most task-relevant patch tokens using a combined class-token similarity and feature-magnitude score. To compensate for information loss from shortening both depth and token sequence, TAP-Path collects multi-depth features from four locations in the retained hierarchy and fuses them through a learned soft gate before classification. The model is selected entirely on training and validation data; the internal test set and CPTAC external cohort are evaluated only after con- figuration locking. The final single-head model is confirmed with three random seeds and evaluated with accuracy, balanced accuracy, macro-F1, rare-class balanced accuracy, calibration, probabilistic losses, failure-detection AUROC, runtime, param- eters, analytical FLOPs, and frozen external performance. In this paper, we propose TAP-Path, a task-adaptive com- pression framework that restructures a pretrained pathology foundation model for efficient and reliable downstream deploy- ment. The main contributions of this study are summarized as follows: âą We propose TAP-Path, a task-adaptive compression frame- work that identifies task-relevant transformer depth and phys- ically reconstructs a compact, non-contiguous subnetwork from the pretrained Virchow2 hierarchy. This enables direct compression of the foundation model without training or distilling a separate student network. âąWe develop an adaptive token-pruning and multi-depth recovery strategy that reduces redundant patch-token com- putation while preserving complementary representations from multiple stages of the compressed hierarchy. A learned gating mechanism integrates these representations for down- stream prediction. âąWe systematically investigate the computational efficiency of pathology foundation models through deployed param- eter count and analytical FLOPs, together with predictive performance. The proposed design reduces Virchow2 en- coder parameters by 24.96% and FLOPs by 35.20%, demon- strating that substantial computational redundancy can be removed while preserving competitive performance on the 32-class pathology task. âą We conduct a reliability-oriented evaluation relevant to trustworthy medical AI by examining calibration, failure awareness, selective prediction, rare-class behavior, and sta- tistical uncertainty. We further evaluate the locked model on two independent CPTAC cohorts without external adapta- tion or threshold tuning to assess generalization beyond the development data. Together, these results show that task-specific structural and token redundancy can be removed from a large pathology foundation model while retaining competitive discrimination and informative uncertainty. 2 Related Work 2.1 Pathology foundation models The current generation of computational-pathology founda- tion models has been driven by scale, data diversity, and self-supervised learning. UNI established a general-purpose pathology representation benchmark using large-scale self- supervision [1]; CONCH extended the paradigm to paired pathology imageâtext learning [2]; Virchow showed the value 2 of million-slide-scale pretraining and a ViT-H backbone for common and rare cancers [3]; Prov-GigaPath introduced a whole-slide hierarchy trained on 1.3 billion tiles [4]; CHIEF combined tile-level and slide-level pretraining across multi- ple institutions [5]; and Hibou provided open DINOv2-based pathology encoders trained on more than one million WSIs [6]. Subsequent models have broadened clinical task cover- age and pretraining strategies, including BEPH, GPFM, and PathOrchestra [29, 7, 8]. As the number of foundation models has grown, independent evaluation has become as important as model creation. Cam- panella et al. benchmarked public self-supervised pathology foundation models on clinical tasks [9]. Lee et al. systemati- cally examined adaptation strategies and data-limited scenar- ios, finding that the preferred adaptation procedure depends on the downstream setting [10]. Neidlinger et al. evaluated 19 foundation models across external clinical cohorts and found that relative model ranking changes with the task and data regime [11]. A broader 2026 benchmark further compared general and pathology-specific vision and visionâlanguage foundation models across multiple cohorts and task categories [12]. These studies motivate controlled same-task compar- isons rather than relying on headline performance reported on unrelated benchmarks. Table 1 summarizes the most directly relevant foundation-model, adaptation, and pruning studies and highlights the methodological gap addressed by TAP-Path. The literature also increasingly separates representation qual- ity from domain robustness. Knowledge-guided adaptation has been proposed to improve cross-domain generalization and fair- ness [26], while recent work demonstrates that pathology foun- dation models may encode scanner and laboratory signatures that can compromise robustness [27]. Domain-generalization surveys similarly emphasize explicit external evaluation and transparent reporting of data sources [28]. Our work follows this direction by locking the compressed architecture before independent CPTAC evaluation and by reporting probability- quality and failure-detection measures in addition to class pre- diction. 2.2 Efficient adaptation and compression Several strategies can make foundation models easier to use downstream. Prompt tuning, adapters, and related parameter- efficient methods update only a small portion of the model, reducing optimization memory and the number of trainable weights. For example, prompt-guided adaptive model transfor- mation has been proposed for pathology classification using representative patch sampling, visual prompts, and adapters [30]; broader medical-image work has also demonstrated few- shot parameter-efficient tuning [14]. These approaches are useful when fine-tuning cost is the main bottleneck, but a frozen or adapter-tuned 600M-parameter encoder still executes most of the original forward pass. Knowledge distillation instead transfers knowledge to a smaller student. GPFM uses a unified expert/self-distillation framework during pretraining [7], and SUDA directly targets efficient pathology analysis by combining unsupervised dis- tillation and domain adaptation; its student can approach the teacher with a small fraction of the parameters [16]. Distilla- tion is therefore a strong point of comparison, but it answers a different question from ours. TAP-Path asks whether a large pretrained encoder can be restructured in place for a target task without building a separate student, thereby preserving the original representation family while physically eliminating task-redundant computation. This distinction matters because resource efficiency has be- come a first-class objective in medical imaging. Lightweight hybrid architectures have reduced model size in segmentation and histopathology-specific applications [13, 15]. One study by [15], explicitly evaluated model size, FLOPs, and MACs alongside predictive performance, illustrating the importance of quantitative efficiency assessment in histopathology mod- els. Similarly, recent efficiency-oriented vision work such as AdaptViG evaluates a Pareto frontier between accuracy, pa- rameters, and compute [22]. We adopt the same scientific principleâefficiency must be demonstrated quantitativelyâ but apply it to the task-specific compression of a pathology foundation model. 2.3 Transformer sparsification The transformer architecture offers at least two complementary axes of redundancy: depth and tokens. Structured methods remove layers, heads, or channels, while token-pruning meth- ods reduce the sequence length dynamically. Vision-specific token pruning has been revisited for dense prediction [17], graph-based propagation has been proposed to preserve token information under reduction [18], and Token Cropr demon- strated task-aware token removal across several vision prob- lems [19]. Sparse structure exploration and learned token- scoring networks further show that efficiency can be improved by searching for task-relevant computation rather than uni- formly shrinking the network [20, 21]. Recent pathology-specific pruning evidence further supports the premise that transformer redundancy can be removed selec- tively. Boudissa et al. analyzed attention-head similarity and confidence in histopathology ViTs and showed that pruning redundant heads can preserve or even improve classification performance while reducing computational burden [31]. This work is complementary to TAP-Path: their unit of sparsifica- tion is the attention head in a distilled ViT, whereas our method physically selects non-contiguous transformer blocks and sub- sequently prunes patch tokens inside a large pretrained pathol- ogy foundation model. The distinction strengthens the moti- vation for testing structural redundancy directly in pathology- specific transformers. Pathology introduces a special constraint: the discriminative region may be spatially sparse. Token removal therefore has to be conditioned on feature content, and the pruning ratio should be chosen on a locked validation protocol rather than assumed a priori. TAP-Path combines a block-level task relevance signal with an input-adaptive token score, then uses multi- depth feature recovery to preserve information from distinct stages of the compressed hierarchy. 3 2.4 Reliability and selective prediction Modern neural networks can be accurate yet poorly calibrated, motivating temperature scaling and expected calibration er- ror (ECE) [23]. Under dataset shift, uncertainty estimates can degrade even when in-distribution metrics appear strong [24]. Selective prediction addresses a complementary practical question: if the system abstains on its least-confident cases, how quickly does error risk decrease [25]? These concepts are particularly relevant to computational pathology, where externally acquired slides may differ in staining, preparation, scanner hardware, and population characteristics. Our opera- tional trustworthiness analysis covers calibration (ECE), proper scoring rules (NLL and Brier), failure-detection AUROC, rare- class behavior, and riskâcoverage. Together, these measures provide complementary evidence of probability quality, error awareness, selective-prediction behavior, and reliability un- der external evaluation. Their clinical interpretation requires prospective validation under the intended workflow. 3 Materials and Methods 3.1 Study design The study followed a sequential model-selection and locked- evaluation protocol.Architecture screening and token- retention selection were performed exclusively using the train- ing and validation partitions. The internal test set was not used for transformer-block selection, token-retention selection, loss- function selection, or calibration-hyperparameter optimization. After fixing the structural and token configuration, three inde- pendent task heads were trained using seeds 42, 123, and 2026. All external evaluations were subsequently performed using the locked configuration without external model adaptation or threshold optimization. This protocol maintains a strict separa- tion between model development, internal testing, and external evaluation. The internal benchmark comprised 25,495 image-level records representing 32 cancer classes derived from The Can- cer Genome Atlas (TCGA) [32]. The dataset was partitioned into 17,769 training, 3,867 validation, and 3,859 test images, with each image represented using the final 12-patch protocol. Table 2 summarizes the resulting data partitions. For independent external evaluation, we used 433 whole- slide images (WSIs) from the Clinical Proteomic Tumor Anal- ysis Consortium (CPTAC), comprising 209 clear cell renal cell carcinoma (CCRCC) images [33] and 224 uterine corpus endometrial carcinoma (UCEC) images [34]. External evalua- tion was conducted at the image level using the locked model without external fitting or threshold optimization. Because the external cohorts represent only two of the 32 cancer classes included in the internal benchmark, external balanced accuracy was computed over the classes represented in CPTAC; metrics requiring averaging across all 32 internal classes were not used as primary measures of class-balanced external performance. 3.2 Preprocessing and patch selection The internal representation is image-level but is deliberately constructed from multiple pathology regions. The final proto- col uses a fixed 12-patch bag for every record. Patch selection was completed before TAP-Path architecture search and there- fore does not use test-set model outcomes. Candidate regions were generated at multiple source crop sizes (224, 448, and 896 pixels) and subsequently resized to the encoder input reso- lution. To preserve scale coverage, the selector first reserves one high-confidence candidate from every available scale. Two additional high-entropy candidates are then forced into the bag so that difficult or ambiguous morphology is not systematically discarded. Remaining positions are filled by a combined utility criterion q i = 0.50c i + 0.30d i + 0.20h i ,(1) The probabilities used by this selector are generated by a re- producible patch probe, not by TAP-Path itself. Specifically, Hibou-B patch embeddings are L2-normalized and a multino- mial logistic-regression classifier is fitted on training patches only using the LBFGS solver, L2 penalty,C = 1.0, and the fixed screening seed. For candidate patchi, ifp (q) i â [0, 1] 32 denotes the probe posterior, confidence and normalized predic- tive entropy are c i = max k p (q) ik ,(2) h i =â 1 logC C X k=1 p (q) ik log p (q) ik + Δ , C = 32.(3) Thus, the probe is a linear probabilistic readout of frozen Hibou- B features; it is neither a ResNet nor a zero-shot classifier. It is trained exclusively on the training split and is used only to construct the deterministic patch manifest. In Eq.(1),c i is the probe confidence from Eq.(2),d i is the minimum cosine distance between candidateiand the already selected Hibou-B patch representations, andh i is the normalized entropy from Eq.(3). The selection procedure first reserves one highest-confidence patch from every available scale, then forces the two highest-entropy remaining patches, and finally fills the bag according to Eq.(1). The diversity term prevents collapse to near-duplicate tissue regions, whereas the entropy term deliberately preserves difficult regions. For source imageI, stored crop center(x i ,y i ), and source crop size s i , the selected region is P i = I h y i â s i 2 : y i + s i 2 ,x i â s i 2 : x i + s i 2 i .(4) Regions extending beyond the source boundary are padded with white background and resized to224Ă 224pixels using bicubic interpolation. The resulting 12 regions are determin- istic for a given manifest and are reused across compared encoders, preventing model-specific patch selection from con- taminating the benchmark. Representative selected regions are shown in Fig. 1, while Fig. 2 documents the long-tailed class distribution. 4 Table 1: Representative recent pathology foundation-model studies most relevant to TAP-Path. StudyYearMain strategyEfficiency / adaptationGap addressed by TAP-Path UNI [1]2024General pathology FMFrozen transferNo task-specific structural compression CONCH [2]2024Visionâlanguage FMCompact transferable encoderNo in-place block/token pruning Virchow [3]2024Large-scale pathology FMScale-driven pretrainingHigh inference footprint Prov-GigaPath [4]2024WSI foundation modelingHierarchical slide modelingFocuses context, not encoder compression Lee et al. [10]2025PFM adaptation benchmarkPEFT / few-shot adaptationTrainable-efficiency, not physical reduction SUDA [16]2026Efficient pathology adaptationTeacherâstudent distillationRequires a separate student Boudissa et al. [31]2025Histology ViT pruningAttention-head pruningHead-level, not PFM block+token pruning PAMT [30]2026Prompt-guided adaptationPrompts / adaptersFull backbone largely retained TAP-PathâTask-adaptive PFM compressionPhysical block + adaptive token pruningEfficiency + reliability + frozen external validation ACCBLCALGGBRCA CESCCHOLCOADESCA GBMHNSCKICHKIRC (a) Representative internal H&E patches. TCGA abbreviations identify the sampled cancer classes. OriginalH-flipV-flip 90° rotationContrastBrightness (b) Representative label-preserving transformations used during training. Figure 1: Representative data appearance and training-time augmentation. The pathology panel illustrates morphological heterogeneity across selected internal classes, while the augmentation panel shows the conservative geometric and photometric perturbations used to improve robustness. Validation, test, and external evaluations use deterministic unaugmented patches. Table 2: Dataset partitions used in the locked evaluation proto- col. PartitionImagesClasses Training17,76932 Validation3,86732 Internal test3,85932 Internal total25,49532 External CPTAC4332 present classes Data-integrity checks verify the canonical class mapping, finite feature values, feature/index row agreement, determinis- tic split membership, and absence of zero-vector embeddings. As visualized in Fig. 2, class imbalance is substantial, moti- vating balanced accuracy, macro-F1, rare-class analysis, and class-wise reliability rather than relying exclusively on top-1 accuracy. 3.3 Data augmentation Augmentation is restricted to transformations expected to pre- serve diagnostic class: horizontal/vertical reflection,90 ⊠rota- tion, mild contrast perturbation, and mild brightness perturba- tion. An augmented patch is Ì P =T Ξ (P ), T Ξ âF h ,F v ,R 90 ,C ÎŽ c ,B ÎŽ b .(5) Aggressive color remapping is avoided because stain- dependent appearance can carry diagnostic information. Vali- dation, internal test, and external CPTAC evaluation use deter- ministic, unaugmented patches. 3.4 Foundation-model baselines Four pathology foundation encoders were retained as inter- pretable reference points: Hibou-B, CONCH, Virchow2, and UNI2-h. Hibou-B and CONCH represent smaller pathology- specific encoders, while Virchow2 and UNI2-h represent the high-capacity regime. Comparisons use the same 32-class task and dataset partitions from the established benchmark. 5 02004006008001000120014001600 Training images Lymphoid Neoplasm Diffus Cholangiocarcinoma Pheochromocytoma and Par Uveal Melanoma Rectum adenocarcinoma Kidney Chromophobe Mesothelioma Uterine Carcinosarcoma Ovarian serous cystadeno Esophageal carcinoma Thymoma Pancreatic adenocarcinom Kidney renal papillary c Adrenocortical carcinoma Testicular Germ Cell Tum Cervical squamous cell c Colon adenocarcinoma Kidney renal clear cell Liver hepatocellular car Prostate adenocarcinoma Bladder Urothelial Carci Skin Cutaneous Melanoma Thyroid carcinoma Head and Neck squamous c Uterine Corpus Endometri Lung adenocarcinoma Sarcoma Lung squamous cell carci Brain Lower Grade Glioma Breast invasive carcinom Glioblastoma multiforme Stomach adenocarcinoma Cancer class Training-set class distribution Figure 2: Training-set distribution of the 32 internal cancer classes. The long-tailed class frequencies motivate balanced, macro-averaged, and rare-class evaluation. We report each baselineâs measured downstream predictive metrics together with the parameter count and a consistently defined analytical encoder-FLOP estimate. The proposed method is initialized from Virchow2 because it provided a strong large-model baseline while exposing sufficient depth for structural analysis. For additional context, the study evalu- ated high-compute fusion systems. Virchow2+StaticTriFusion reached 87.43% accuracy with 81.78% macro-F1, and UNI2- h+DenseTriGate reached 87.91% accuracy with 82.68% macro- F1, but both execute three foundation representations simulta- neously. Their approximate deployed backbone footprints are 808M/421.6G and 857M/532.4G (parameters/FLOPs), respec- tively, before small fusion-head overhead. These systems are therefore retained as high-compute context rather than direct deployment competitors. 3.5 TAP-Path overview Let the pretrained encoder containL = 32transformer blocks, F (X) = B L ⊠B Lâ1 âŠÂ·âŠ B 1 (E(X)),(6) whereE(·)denotes patch embedding plus prefix-token con- struction andB â is transformer blockâin Eq.(6). TAP-Path transformsFinto a task-specific sparse encoderF S,Ï param- eterized by a retained block setS â 1,...,Land token- retention ratioÏ. The final model uses|S| = 24andÏ = 0.70 after the pruning point. The design contains four coupled operations: (i) block novelty profiling and task-adaptive structural selection; (i) physical removal of unselected transformer blocks; (i) input- adaptive patch-token pruning; and (iv) gated recovery of fea- tures from four depths of the compressed hierarchy. The com- plete procedure is summarized in Algorithm 1 and illustrated in Fig. 3; Table 3 later contrasts the resulting system properties with the evaluated baselines. 3.6 Task-adaptive block selection Uniform truncation assumes that later blocks are always more expendable or that useful information is distributed monotoni- cally with depth. We instead estimate the normalized residual change induced by each block. For a profiling samplexand blockâ, letH ââ1 andH â denote the token tensors immediately before and after the block. We define block novelty as Μ â (x) = q 1 ND â„H â â H ââ1 â„ 2 F q 1 ND â„H ââ1 â„ 2 F + Δ ,(7) whereNis the token count,Dis the embedding dimension, andΔ = 10 â8 prevents numerical instability. Profiling is restricted to the development subset and excludes internal test and CPTAC records. The dataset-level score is ÌΜ â = 1 M M X m=1 Μ â (x m ).(8) To preserve low-level token formation and high-level se- mantic consolidation, the first four and final four blocks are anchored. For a target retained depthK, the remainingKâ 8 blocks are selected from the middle hierarchy according to ÌΜ â and then restored to their original order. Because transformer blocks preserve a constant hidden width, block excision does not create a dimensional mismatch. IfH â â R NĂD is the resid- ual stream after a retained block and blocksâ + 1,...,jâ 1 are removed, the next retained block receives H j = B j (H â ).(9) The pretrained weights inside retained modules are unchanged; only the computational graph is shortened. The selected 24- block configuration in the locked experiment retained original blocks S â =1,..., 5âȘ14,..., 32.(10) using one-based indexing for readability. The practical im- plementation physically replaces the original block list with the retained modules; consequently, omitted blocks no longer contribute stored encoder parameters or forward-pass compu- tation. Structural candidates were screened against contiguous- depth controls and task-sparse variants. Candidate selection was validation-only and explicitly constrained by compression. The objective can be written as max S A val (S)(11) s.t. R P (S)â„ r P , A val (S)â„ A â val â ÎŽ,(12) whereR P = 1â P S /P full is parameter reduction,r P is the required reduction, andÎŽis the allowed validation tolerance. This formulation avoids choosing the smallest network when its accuracy has already collapsed. 6 3.7 Adaptive token pruning After structural selection, token reduction is applied within the compressed encoder. Letc â R D denote the prefix/class token andp i â R D a patch token. We first normalize both and compute a class-token similarity, s sim i = p †i c â„p i â„ 2 â„câ„ 2 .(13) To avoid retaining only tokens aligned with the current class token, we add an activation-magnitude term. With per-image normalized magnitude s mag i = â„p i â„ 2 â ÎŒ â„pâ„ Ï â„pâ„ + Δ ,(14) the fixed development weighting prioritizes semantic alignment while retaining a secondary activation-magnitude cue; it is frozen before test evaluation. The combined token importance is s i = 0.75s sim i + 0.25s mag i .(15) The prefix token is always retained. AmongN p patch tokens, the model keeps K p =âÏN p â.(16) patches with the largests i according to Eqs.(15)â(16), where Ï â 1.00, 0.85, 0.70was evaluated after structural lock- ing. Token pruning begins at retained execution position max(1, round(24 Ă 0.55)) = 13, i.e., after the 13th block in the retained execution sequence. Ranking is recomputed for every patch and introduces no trainable token-router subnet- work. The analytical compute reduction arises from both fewer blocks and a smaller token sequence. IfΊ â (N )denotes the FLOPs of transformer blockâat token countN, the com- pressed encoder cost is approximated by Ί TAP = X ââS pre Ί â (N ) + X ââS post Ί â (K p + N prefix ),(17) whereS pre andS post denote retained blocks before and after the pruning point. 3.8 Multi-depth feature recovery Compression can remove intermediate transformations that a downstream classifier would otherwise exploit. We therefore do not classify from only the final compressed token state. Four approximately evenly spaced taps are collected from the retained hierarchy. Four taps balance hierarchical coverage against projection/gating overhead and cached feature dimen- sionality. The effective token countK t depends on tap loca- tion: taps before the pruning point observe the dense sequence, whereas later taps observe the retained 70% patch sequence. At tapt, the token sequence is normalized and summarized using the prefix token and mean patch token, u t = " LN(c t ) ; 1 K t K t X i=1 LN(p t,i ) # .(18) Each u t is projected to a 256-dimensional task space: z t = GELU(W t LN(u t ) + b t ).(19) Instead of concatenating the four taps and treating them equally, an adaptive gate estimates their sample-specific contri- bution. Let z cat = [z 1 ;z 2 ;z 3 ;z 4 ].(20) The gate is α = softmax (W g2 GELU (W g1 LN(z cat ))), 4 X t=1 α t = 1, (21) and the fused feature becomes z = 4 X t=1 α t z t .(22) The final classifier is a two-layer MLP with LayerNorm, a 512-unit hidden layer, GELU, dropout 0.18, and a 32-class output layer. This single task head contains 5.70M parameters; the deployed single-head model therefore contains 479.40M parameters in total. 3.9 Optimization objectives For the primary single-head model, class weights are mild rather than fully inverse-frequency weighted: w c = N C n c Îł 1 C P C j=1 N C n j Îł , Îł = 0.20,(23) wheren c is the number of training examples in classc. Weighted cross-entropy uses label smoothingΔ ls = 0.01. To discourage degenerate single-tap gating, we define gate entropy H(α) =â 4 X t=1 α t log(α t + Δ)(24) and optimize L primary =L CE â λ H H(α), λ H = 0.002.(25) Rare-class sensitivity was investigated after the main archi- tecture had been locked. Five validation-only objectives were compared: mild weighted cross-entropy, Balanced Softmax, logit adjustment withÏ = 0.5, logit adjustment withÏ = 1.0, and class-balanced focal loss. For logit adjustment, Ìo c = o c + Ï log(Ï c + Δ),(26) whereo c is class logitcandÏ c is the empirical training prior. This experiment is reported as an ablation of the same com- pressed architecture; it is not merged with the primary head to construct an artificial âbest of all metricsâ model. 7 TAP-Path: Task-Adaptive Pathology Foundation Model Compression and Reliable Inference 1. Multi-scale Patch Construction2. Task-Adaptive Structural Compression3. Token Pruning & Multi-depth Recovery 4. Reliable Prediction & Validation H&E tissue / WSI internal 32-class cohort Multi-scale candidate regions 224 / 448 / 896 px Lightweight frozen probe linear classifier on frozen embeddings Confidence cᔹ Representation diversity dᔹ Predictive entropy hᔹ Patch utility score qᔹ = 0.50cᔹ + 0.30dᔹ + 0.20hᔹ Deterministic H&E patch bag 12 selected regions fixed ordering for reproducibility F frozen/reference T trainable â retained Ă removed Virchow2 pretrained hierarchy 32 transformer blocks 631.24 M encoder parameters Task-specific block novelty profiling Μâ = RMS(Hâ â Hâââ) / (RMS(Hâââ)+Δ) Block retention map B1â2 â B3â4 â B5 â B6-7 Ă B8-9 Ă B10- 11 Ă B12- 13 Ă B14â 16 â B17â 18 â B19â 20 â B21â 22 â B23â 24 â B25â 26 â B27â 28 â B29â 30 â B31â 32 â Physical encoder reconstruction 32 â 24 retained blocks non-contiguous task-adaptive subnetwork Encoder parameters 631.24 M â 473.70 M â25% structural reduction Patch tokens entering retained hierarchy â â â â â â â â â â â â Adaptive token importance sᔹ = 0.75 sᔹ˹â±á” + 0.25 sᔹá”á”á” Late-hierarchy token pruning Ï = 0.70 retention â â Ă â â â â â Ă â â â Multi-depth representation recovery Tâ Tâ Tâ Tâ Four 256-D projections zâ = GELU(Wâ LN(uâ)+bâ) Learned soft gate α = softmax(g(zâ... zâ)) z = ÎŁ αâzâ Analytical encoder compute 340.13 G â 220.40 G FLOPs Single calibrated 32-class task head Classification Accuracy · BA · Macro-F1 · Rare BA Calibration Temperature scaling ECE · Brier · NLL Failure awareness 1 â max p(y|x) Failure AUROC · Riskâcoverage Frozen external validation CPTAC-CCRCC · CPTAC-UCEC no encoder adaptation Primary operating point 87.98% accuracy efficient + calibrated + externally evaluated Figure 3: Architecture of the proposed TAP-Path framework. Multi-scale H&E regions are ranked to construct a deterministic 12-patch bag, followed by task-adaptive structural compression of the Virchow2 encoder to the locked one-based block set 1,..., 5âȘ14,..., 32(24 of 32 blocks). Adaptive late-hierarchy token pruning retains 70% of informative tokens, while four intermediate feature representations are projected to 256 dimensions and adaptively combined through a learned soft gate before 32-class prediction. The resulting predictions are evaluated for classification performance, calibration, failure awareness, and frozen external generalization on CPTAC-CCRCC and CPTAC-UCEC. TAP-Path reduces the encoder from 631.24M to 473.70M parameters and the analytical encoder computation from 340.13 to 220.40 GFLOPs while achieving 87.98% internal test accuracy. 3.10 Training and model selection The optimization pipeline is separated into architecture selec- tion and task-head learning so that the expensive foundation backbone is not repeatedly fine-tuned for every candidate. Stage 1: reduced class-aware screening. Structural search uses 1,400 training and 700 validation records selected deter- ministically with class awareness. Only the first two ranked patches per selected image are processed during screening. This subset exists solely to rank compression candidates effi- ciently. Stage 2: structural search. Contiguous-depth controls and non-contiguous task-sparse candidates are constructed from the frozen Virchow2 parent. Each candidate is evaluated using screening features and a lightweight validation probe. The selection criterion jointly considers validation utility and com- pression; internal test data are not used to choose retained blocks. Stage 3: token-retention search. After the strongest com- pressed structures are identified,Ï â 1.00, 0.85, 0.70is evaluated on validation data. TaskSparse24 withÏ = 0.70is locked before final representation extraction. Stage 4: full 12-patch feature extraction. The physically reconstructed encoder is run over the complete deterministic 12-patch bags. CUDA automatic mixed precision is enabled where supported. Screening encoder batch size is 4, final feature-extraction batch size is 6, and the development GPU is an NVIDIA GeForce RTX 5060 Ti with approximately 16 GB VRAM. Stage 5: task-head optimization. The single gated multi- tap head is trained on cached image-level compressed features for at most 130 epochs using AdamW, learning rate7Ă 10 â4 , weight decay2Ă 10 â4 , batch size 384, gradient clipping at 5, dropout 0.18, and early-stopping patience 18. Three seeds (42, 123, 2026) quantify optimization variability. Stage 6: calibration and locked evaluation. Temperature scaling is fitted only to validation logits using LBFGS. The locked internal test set is then evaluated. CPTAC-CCRCC and CPTAC-UCEC are processed only after internal config- uration locking; no external label, threshold, temperature, or architecture decision modifies TAP-Path. Structural-screening performance and final test performance are not directly comparable because they correspond to distinct experimental protocols. Screening uses a reduced class-aware subset and two patches per image for efficient candidate rank- ing, whereas final evaluation uses the complete deterministic 8 Algorithm 1 TAP-Path: task-adaptive structural and token pruning with multi-depth recovery Require: Pretrained Virchow2 encoderB â 32 â=1 ; training setD tr ; validation setD va ; deterministic candidate-patch manifest Ensure: Compressed encoderF S â ,Ï â and calibrated 32-class task head 1: Extract frozen Hibou-B candidate-patch embeddings and L2-normalize them 2: Fit the multinomial logistic patch probe onD tr only 3: for each candidate patch i do 4:Compute probe confidence c i and entropy h i using Eqs. (2)â(3) 5: end for 6: for each image do 7:Reserve the highest-confidence patch at every available scale 8:Add the two highest-entropy remaining patches 9:while fewer than 12 patches are selected do 10:Compute confidenceâdiversityâentropy utility using Eq. (1) 11:Add the highest-utility remaining patch 12:end while 13: end for 14: Profile Virchow2 block novelty ÌΜ â on development data using Eq. (7) 15: Construct contiguous-depth controls and non-contiguous task-sparse block candidates 16: for each candidate block setS do 17:Physically instantiate only blocks inS 18:Extract reduced-protocol screening features and fit the fixed lightweight validation probe 19:Record validation accuracy, BA, macro-F1, encoder parameters, and analytical FLOPs 20: end for 21: Lock the validation-Pareto structural candidateS â (24 of 32 blocks) 22: for Ïâ1.00, 0.85, 0.70 do 23:Score tokens with Eq. (15); retain K p tokens using Eq. (16) 24:Evaluate validation performance and analytical compute 25: end for 26: Lock Ï â = 0.70 and rebuild the executable compressed encoder 27: for seedâ42, 123, 2026 do 28:Extract the full deterministic 12-patch representation 29:Recover four hierarchy taps and compute the adaptive gate using Eq. (21) 30:Fuse taps using Eq. (22) and optimize the single 32-class head 31:Fit temperature scaling on validation logits only 32:Evaluate the locked internal test set and frozen CPTAC cohorts 33: end for 34: Report predictive, efficiency, calibration, failure-detection, selective-risk, rare-class, and bootstrap metrics 12-patch representation and the trained multi-depth recovery head. 3.11 Common-probe diagnostic To assess representation quality independently of model- specific task heads, we additionally trained an identical lightweight probe on each frozen representation. Under this standardized readout, TAP-Path achieved approximately 85% accuracy, compared with approximately 88% using its pro- posed multi-depth gated head. The difference reflects the con- tribution of the task-specific multi-depth recovery mechanism to downstream prediction. Because the common-probe exper- iment evaluates representation quality under a standardized classifier rather than the complete TAP-Path inference archi- tecture, it is reported as a complementary diagnostic analysis. 3.12 Reliability metrics For each trained seed, post-hoc temperature scaling is fitted on validation logits only. Given logits o and temperature T > 0, p c = exp(o c /T ) P C j=1 exp(o j /T ) .(27) T is optimized by minimizing validation NLL. ECE is com- puted over 15 confidence bins, ECE = B X b=1 |I b | n |acc(I b )â conf(I b )|.(28) We additionally report multiclass Brier score Brier = 1 n n X i=1 C X c=1 (p ic â y ic ) 2 (29) 9 and NLL. These measures are complementary: ECE summa- rizes bin-level calibration, while NLL and Brier are proper scoring rules sensitive to the full predictive distribution. For failure detection, each example receives an uncertainty score u i = 1â max c p ic .(30) Ground-truth failures aree i = âź[arg max c p ic Ìž= y i ]. The AUROC betweenu i ande i measures whether errors tend to receive higher uncertainty. Riskâcoverage analysis sorts exam- ples by confidence and evaluates error rate among the retained fraction. This supports a selective-prediction interpretation but is not presented as proof of clinical safety. Rare classes are defined from the training distribution using the lower quartile of positive class counts. Rare-class balanced accuracy is the unweighted mean recall over those classes: RareBA = 1 |R| X câR TP c TP c + FN c .(31) 3.13 Statistical analysis Three independent seeds are reported as mean±SD. Stratified bootstrap confidence intervals are estimated from frozen test predictions using B = 2000 resamples: CI 95 (m) = Q 0.025 m b B b=1 ,Q 0.975 m b B b=1 .(32) Because aligned prediction vectors are not available for every baseline, marginal confidence intervals are not used as a sub- stitute for a paired superiority test. Small accuracy differences are therefore described as comparable/slightly higher perfor- mance, whereas parameter and FLOP reductions are reported as deterministic architectural differences. 3.14 Implementation details Experiments were implemented in Python 3.11 with PyTorch and thetimmmodel library. Foundation models were used as pretrained encoders; mixed-precision feature extraction was enabled on CUDA where supported. The reported development system used an NVIDIA GeForce RTX 5060 Ti GPU. Struc- tural screening used a reduced validation protocol to avoid re- peatedly executing all 12 patches for every candidate, whereas the locked winner was re-evaluated under the full 12-patch protocol. The final single-head task model used four taps, 256- dimensional tap projections, dropout 0.18, up to 130 training epochs, early stopping with patience 18, AdamW with learning rate7Ă 10 â4 and weight decay2Ă 10 â4 , gradient clipping at 5, and three seeds (42, 123, 2026). The task-head batch size was 384 on cached image-level representations. Temperature scaling used LBFGS on the validation logits. The final runtime profile of the compressed model was 31.85±1.21 ms per im- age on the development GPU, corresponding to 31.40 images/s under the measured profiling configuration. 350400450500550600 Encoder parameters (M) 58 60 62 64 66 68 70 72 Screening validation accuracy (%) TaskSparse22 Depth24 TaskSparse24 Depth32 Task-adaptive structural screening Figure 4: Validation-only structural screening of contiguous- depth and task-adaptive sparse candidates. 4 Results 4.1 Structural compression The first question was whether selecting blocks by task- dependent novelty provides a better compressed representation than simply truncating the model. Table 4 summarizes the validation-only screening. Full Depth32 achieved the highest absolute screening accuracy (72.96%) but retained the entire encoder. A contiguous Depth24 model reduced encoder param- eters by 24.96% but reached 68.28% screening accuracy. At the same parameter count, TaskSparse24 improved screening accuracy to 69.79%, supporting the use of non-contiguous task- adaptive block retention. More aggressive TaskSparse22 and TaskSparse20 configurations reduced parameters by 31.20% and 37.43%, respectively, but incurred additional validation loss. Figure 4 visualizes the screening frontier. Importantly, the screening accuracies are not directly compared with the final test accuracies because they were obtained with a reduced screening protocol. Their purpose was model selection under equal candidate conditions. 4.2 Token-pruning ablation Token-retention results are shown in Table 5, and the cor- responding validation trend is visualized in Fig. 5.For TaskSparse24, retaining 85% of patch tokens increased vali- dation accuracy from 69.79% to 70.39% while reducing ana- lytical FLOPs from 255.19G to 237.71G. Retaining 70% pro- duced the strongest validation score (71.60%) and further re- duced compute to 220.40G, a 35.20% reduction relative to full Virchow2. The same 70% ratio was less effective for TaskSparse22, indicating an interaction between structural depth and token sparsity rather than a universal benefit from dropping tokens. The validation results indicate that moderate adaptive token pruning can improve the accuracyâcompute operating point after stable early representations have formed. This behavior is 10 Table 3: Method-level comparison of the evaluated foundation-model strategies. A checkmark indicates that the property is explicitly present in the evaluated system. MethodPhysical compressionAdaptive token pruningMulti-depth recoveryReliability analysisFrozen external test Hibou-Bââ CONCHââ Virchow2ââ UNI2-hââ StaticTriFusion / DenseTriGateââpartialâ TAP-Pathâ Table 4: Structural validation screen. Values are used only for architecture selection and are not the final 12-patch test performance. CandidateAcc.BAParamsFLOPs (%)(%)(M)(G) Depth3272.9673.08631.24340.13 Depth2870.3970.31552.47297.66 Depth2468.2868.38473.70255.19 TaskSparse2469.7969.84473.70255.19 TaskSparse2269.1869.30434.32233.96 TaskSparse2066.4766.50394.94212.73 Table 5: Token-retention ablation for the locked structural candidates. StructureTokensAcc.BAFLOPs (%)(%)(%)(G) TaskSparse2410069.7969.84255.19 TaskSparse248570.3970.42237.71 TaskSparse247071.6071.64220.40 TaskSparse2210069.1869.30233.96 TaskSparse228568.7368.56218.07 TaskSparse227067.9867.97202.33 consistent with removal of redundant or weakly aligned token content and motivates joint selection of structural depth and token retention under the validation protocol. 4.3 Foundation-model comparison Table 6 presents the central same-task comparison. The pro- posed single-head TAP-Path configuration achieved87.98± 0.067% test accuracy across three seeds, compared with 86.89% for full Virchow2 and 87.67% for UNI2-h. The corre- sponding macro-F1 was82.38±0.48%, compared with 80.94% for Virchow2 and 81.75% for UNI2-h, while balanced accuracy reached81.26± 0.49%. These results place TAP-Path at the highest observed accuracy and macro-F1 among the evaluated single-backbone systems while substantially reducing the com- putational footprint of the large-model parent. Because paired baseline prediction files were unavailable, the comparison is re- ported as an observed performance difference without a paired significance test. The efficiency gains are substantial. Full Virchow2 con- 707580859095100 Retained patch tokens (%) 68.0 68.5 69.0 69.5 70.0 70.5 71.0 71.5 Screening validation accuracy (%) Token-retention ablation TaskSparse22 TaskSparse24 Figure 5: Token-retention ablation after structural selection. The 70% TaskSparse24 configuration provides the best valida- tion accuracy with the lowest compute among the displayed TaskSparse24 settings. tains approximately 631â632M encoder parameters, whereas the physically compressed encoder contains 473.70M, corre- sponding to a 24.96% reduction. Including the task head, the deployed TAP-Path configuration contains 479.40M param- eters, and analytical encoder FLOPs decrease from 340.13G to 220.40G (35.20%). Relative to UNI2-h, TAP-Path also operates with substantially fewer parameters and analytical FLOPs while achieving comparable or higher predictive per- formance. Hibou-B and CONCH occupy a lower-compute regime, whereas TAP-Path defines a favorable operating point within the high-performing large-foundation-model regime. Table 7 places the high-compute fusion experiments be- side the single-backbone systems. These experiments show that comparable discrimination can also be obtained through multi-foundation-model fusion, but at substantially greater deployment-scale parameter and compute requirements. In contrast, TAP-Path achieves its operating point with a single physically compressed backbone. The Pareto view is clearer in Figs. 6 and 7. The corrected high-compute fusion references are included in both plots: Virchow2+StaticTriFusion reaches 87.43% accuracy and UNI2- h+DenseTriGate reaches 87.91%, whereas TAP-Path reaches 87.98%. Including the high-compute fusion references further illustrates the resulting Pareto trade-off. TAP-Path achieves 11 Table 6: Direct same-task comparison on the 32-class internal test set. TAP-Path values are mean±SD over three independently trained single heads. Arrows indicate preferred direction. Analytical FLOPs refer to the encoder and are used for relative efficiency comparison. ModelParams (M)âFLOPs (G)âAccuracy (%)âBA (%)âMacro-F1 (%)âExternal Acc. (%)â Hibou-B85.746.3282.6775.1776.3391.53 CONCH90.035.1381.4376.3976.1185.76 Virchow2632.0340.1386.8980.5280.9490.76 UNI2-h681.0450.9787.6781.1281.7590.07 TAP-Path (ours)479.40220.4087.98±0.06781.26±0.4982.38±0.4891.22±0.83 External accuracy is reported alongside the internal metrics to characterize transfer behavior across model scales; Hibou-B attains the highest raw accuracy on the two-class CPTAC cohort, while TAP-Path provides the strongest joint internal accuracyâefficiency operating point among the high-capacity systems. Table 7: Broader experimental context including high-compute fusion references. Fusion parameter/FLOP values approximate the simultaneously deployed foundation encoders and therefore indicate deployment scale rather than trainable task-head size. SystemParams (M)FLOPs (G)Accuracy (%)Macro-F1 (%)Deployment regime Virchow2632.0340.186.8980.94Full single backbone UNI2-h681.0451.087.6781.75Full single backbone Virchow2+StaticTriFusion âŒ808 âŒ421.687.4381.78Three-FM fusion UNI2-h+DenseTriGateâŒ857 âŒ532.487.9182.68Three-FM fusion TAP-Path479.40220.487.9882.38Compressed single backbone 100200300400500600700800900 Deployed parameters (M) 81 82 83 84 85 86 87 88 Internal test accuracy (%) Accuracy-parameter trade-off Hibou-B CONCH Virchow2 UNI2-h V2-StaticTri UNI-DenseTri TAP-Path Figure 6: Accuracyâparameter trade-off. Each operating point is labeled directly with model name and test accuracy; light guide lines preserve pointâannotation correspondence. 87.98% accuracy using 479.40M deployed parameters and 220.40G analytical encoder FLOPs, while the fusion systems require substantially greater deployment-scale parameters and compute for similar predictive performance. 4.4 Reliability analysis Reliability is organized into three complementary questions. First, are predicted probabilities well behaved? This is as- sessed with ECE, NLL, and Brier score. Second, does confi- dence identify likely mistakes? This is assessed with failure- detection AUROC and selective riskâcoverage. Third, does performance remain acceptable for low-frequency classes? This is assessed with rare-class balanced accuracy and class- wise F1. Table 8 and Figs. 8â9 report these three views jointly.For the primary three-seed TAP-Path task head, ECE is0.0301 ± 0.0022, NLL is0.4694 ± 0.0015, Brier score is0.1800 ± 0.0005, and failure-detection AUROC is 0.9047± 0.0060. These measurements indicate that TAP-Path maintains informative confidence estimates despite structural and token pruning. In particular, its Brier score and failure- detection AUROC improve over the full Virchow2 baseline, whereas UNI2-h remains marginally better in ECE and NLL. The reliability claim is therefore based on the joint behavior of several metrics rather than on a single calibration statistic. Rare-class sensitivity is evaluated on the same compressed encoder using the validation-selected rare-aware objective. This operating point achieves rare-class balanced accuracy 0.6864± 0.0216and balanced accuracy0.8229± 0.0038. We report that value in the reliability comparison because it is the dedicated minority-sensitive operating point of TAP-Path; the remaining TAP-Path entries in Table 8 are the primary three- seed reliability results. This distinction avoids understating the modelâs validated rare-class capability while retaining the provenance of each metric. Figure 8 provides a direct visual comparison of the reliability profile, while Fig. 9 evaluates whether confidence can support selective prediction. At 60% internal coverage, TAP-Path re- 12 100200300400500 Analytical encoder FLOPs (G) 81 82 83 84 85 86 87 88 Internal test accuracy (%) Accuracy-compute trade-off Hibou-B CONCH Virchow2 UNI2-h V2-StaticTri UNI-DenseTri TAP-Path Figure 7: Accuracyâcompute trade-off. Direct annotations connect each model and test accuracy to its analytical encoder FLOP requirement. Table 8: Reliability comparison for the large-model baselines and TAP-Path. TAP-Path ECE, Brier, and failure AUROC and Rare BA are the primary three-seed values at the operating point on the same compressed encoder. ModelECEâBrierâFail-AUROCâRare BAâ Virchow20.03680.18820.89200.6996 UNI2-h0.02970.18250.89200.6931 TAP-Path0.0301±.00220.1800±.00050.9047±.00600.6864±.0216 tains approximately 99.2% selective accuracy, and risk rises gradually as progressively less-confident cases are accepted. This monotonic behavior is consistent with a useful absten- tion signal: the modelâs low-confidence subset is enriched for errors. 4.5 Rare-class analysis Following the reliability comparison in Table 8. Rare-class behavior was further examined under alternative optimization objectives while keeping the compressed TAP-Path encoder fixed. The primary calibrated configuration is denoted by P, whereas the validation-selected rare-aware configuration is denoted by R. This separation allows the effect of the task- head objective on minority-class sensitivity to be evaluated independently of structural compression. The rare-aware objectives are therefore reported within the unified ablation analysis in Table 9, preserving the distinction between the primary operating point and alternative minority- sensitive objectives. Instead, Table 9 integrates the rare-aware objectives into the full ablation narrative alongside structural and token choices. On validation data, Balanced Softmax produced the highest rare-class balanced accuracy (70.55%) but reduced overall accuracy. Logit adjustment withÏ = 1.0 ECE Brier Failure AUROC Rare BA 0.0 0.2 0.4 0.6 0.8 Metric value Reliability and rare-class profile Virchow2 UNI2-h TAP-Path Figure 8: Reliability and rare-class profile of TAP-Path relative to full Virchow2 and UNI2-h. Lower ECE/Brier and higher failure AUROC/Rare BA are preferred. 6065707580859095100 Coverage (%) 2 4 6 8 10 12 Selective risk (%) TAP-Path selective risk-coverage CPTAC Internal Figure 9: Selective riskâcoverage behavior for TAP-Path on the locked internal and external evaluations. achieved the highest validation accuracy (90.25%) among the tested objectives while raising rare-class BA from 67.39% for the mild-CE baseline to 69.68%. The validation trade-off is shown in Fig. 10, and class- level behavior is summarized in Fig. 11. When the selected logit-adjusted head was repeated across three seeds on the locked compressed encoder, test rare-class BA increased to 68.64± 2.16%, balanced accuracy to82.29± 0.38%, while accuracy decreased to87.13± 0.68%. The comparison demon- strates a controllable operating trade-off within the same com- pressed encoder: rare-aware optimization increases minority- class sensitivity while shifting the balance among aggregate accuracy, balanced accuracy, and macro-F1. Figure 11 further shows that the overall score is supported by strong discrimina- tion in several well-represented classes: prostate adenocarci- noma reaches F1=0.996, testicular germ-cell tumors F1=0.986, 13 67.568.068.569.069.570.070.5 Validation rare-class balanced accuracy (%) 87.5 88.0 88.5 89.0 89.5 90.0 Validation accuracy (%) MildCE BalancedSoftmax LA-tau0.5 LA-tau1.0 CBFocal_gamma1.5 Rare-aware objective trade-off Figure 10: Validation trade-off between overall accuracy and rare-class balanced accuracy for alternative task-head objec- tives on the fixed TAP-Path encoder. thyroid carcinoma F1=0.986, kidney renal clear-cell carci- noma F1=0.963, and lower-grade glioma F1=0.961. The most difficult classes include rectum adenocarcinoma (F1=0.174), mesothelioma (0.378), esophageal carcinoma (0.439), and cholangiocarcinoma (0.552). The normalized confusion matrix confirms that errors are concentrated in a limited subset of class pairs rather than being uniformly distributed across the 32-class taxonomy. This heterogeneity motivates reporting macro-F1 and rare-class BA alongside top-1 accuracy. The primary paper result therefore remains the single-head mild- CE configuration in Table 6, with the rare-aware result used to explain the robustness/imbalance behavior of the architecture. 4.6 External validation External validation is reported as two distinct disease co- horts. CPTAC-CCRCC contains 209 independent tumor cases mapped to the internal kidney renal clear-cell carcinoma class, and CPTAC-UCEC contains 224 independent tumor cases mapped to uterine corpus endometrial carcinoma. No CP- TAC image or label is used for architecture selection, head optimization, calibration, or threshold tuning. Across the three primary single-head seeds, TAP-Path achieves 87.40±0.28% accuracy on CCRCC and 94.79±1.44% on UCEC. Pooled over 433 cases, accuracy is 91.22±0.83% and present-class balanced accuracy is 91.10±0.81%. Because each cohort corresponds to one mapped target class, cohort- specific recalls/accuracies can be recovered exactly from each frozen seed using BA ext = a C + a U 2 ,(33) Acc ext = 209a C + 224a U 433 .(34) Table 10 reports the cohort-specific values and Fig. 12 con- trasts internal and external behavior. The cohort difference is meaningful: UCEC transfers more strongly than CCRCC un- der the locked model, demonstrating why external performance should not be collapsed into a single unqualified robustness claim. The result supports frozen transfer across these two morphologies, not universal 32-class external generalization. Frozen external evaluation was performed on 433 CPTAC images after the internal architecture and task protocol were locked. Across three single-head seeds, TAP-Path achieved 91.22± 0.83% accuracy and91.10± 0.81% balanced accu- racy. External ECE was0.0323± 0.0086and failure-detection AUROC was0.8974± 0.0089. These values indicate that the compressed representation remained useful outside the internal data source. The external task is simpler in class cardinality than the internal 32-class benchmark, so its higher raw accuracy should not be interpreted as evidence that CPTAC is âharderâ or that generalization improves with domain shift. Instead, the correct interpretation is that the locked model transferred successfully to the two externally represented classes. Among the retained baselines, Hibou-B obtained a slightly higher external accuracy (91.53%), while TAP-Path exceeded Virchow2 and UNI2-h. The external experiment therefore provides evidence of transfer robustness for the two represented classes. 4.7 Representation analysis As shown in Fig. 13, PCA is used as a descriptive visualization of the locked compressed representation, not as a training signal. For standardized image-level feature matrixZ, thekth component is w k = argmax â„wâ„ 2 =1, wâ„w <k Var(Zw).(35) The projection in Fig. 13 shows that broad class-dependent structure remains visible after depth and token reduction, al- though substantial overlap is expected for a 32-class pan-cancer task. 4.8 Deployment efficiency The final compressed encoder has 473.70M parameters and the single task head has 5.70M, giving 479.40M deployed pa- rameters. Analytical encoder compute is 220.40G FLOPs. An independent profiler supported approximately 213.98G FLOPs for the measured execution path. On the NVIDIA GeForce RTX 5060 Ti development system, mean inference latency was 31.85 ms with 1.21 ms standard deviation, corresponding to 31.40 images/s. These numbers are hardware-specific and should not be generalized to clinical scanners or server deploy- ments, but they confirm that the structural and token changes translate into an executable compressed model rather than only theoretical masking. 4.9 Bootstrap uncertainty Figure 14 summarizes the resulting uncertainty. The 2,000- resample stratified bootstrap gives approximate 95% intervals of 0.870â0.889 for accuracy, 0.793â0.831 for balanced accu- racy, 0.805â0.839 for macro-F1, 0.568â0.698 for rare-class bal- anced accuracy, and 0.018â0.032 for ECE. The wider rare-class 14 Table 9: Unified ablation study. The table intentionally combines structural, token, and rare-aware objective experiments rather than creating a separate headline table for the rare-aware operating point. Screening values are validation-only and should not be compared directly with final 12-patch test results. ComponentVariantAcc. (%)BA (%)Macro-F1 (%)Rare BA (%)FLOPs (G) Structure Depth3272.9673.0871.67â340.13 Depth2468.2868.3867.30â255.19 TaskSparse2269.1869.3068.01â233.96 TaskSparse2469.7969.8468.54â255.19 Token ratio 100%69.7969.8468.54â255.19 85%70.3970.4269.10â237.71 70%71.6071.6470.32â220.40 Loss (validation) Mild CE89.9982.8284.4767.39220.40 Balanced Softmax89.1983.1781.5170.55220.40 Logit adjustment Ï = .589.9483.0484.2467.74220.40 Logit adjustment Ï = 190.2583.8483.2269.68220.40 CB focal Îł = 1.587.3581.2781.7668.33220.40 Rare-aware 3-seed testselected Ï = 1 head87.13±.6882.29±.3880.74±.6568.64±2.16220.40 Table 10: Frozen TAP-Path validation on the two external CPTAC cohorts. Values are mean±SD across the three primary single-head seeds. CohortCasesAccuracy (%) CPTAC-CCRCC20987.40±0.28 CPTAC-UCEC22494.79±1.44 Pooled CPTAC43391.22±0.83 Present-class BA43391.10±0.81 interval reflects the smaller effective support of low-frequency classes. 5 Discussion 5.1 Whole-slide efficiency The reported FLOP reduction is measured per encoder invoca- tion, but digital pathology multiplies this saving across patch bags. Although the present experiments evaluate fixed image- level patch bags rather than end-to-end WSI inference, the per-patch analytical FLOP reduction can be extrapolated to il- lustrate potential whole-slide computational savings. If a WSI contributes N WSI encoded patches, Ί slide â N WSI Ί patch .(36) For 10,000 encoded patches, reducing analytical cost from 340.13G to 220.40G FLOPs corresponds to roughly1.20Ă10 15 fewer floating-point operations before downstream aggregation. This is a theoretical compute estimate rather than a latency guarantee, yet it illustrates why a 35.20% per-patch reduction is meaningful at WSI scale. 5.2 Structural compression rationale The structural compression results demonstrate that TAP-Path establishes a favorable accuracyâefficiency operating point derived directly from a high-capacity pathology foundation model. Relative to the full Virchow2 backbone, TAP-Path removes approximately one quarter of the encoder parame- ters and more than one third of the analytical encoder FLOPs while maintaining strong predictive performance. Importantly, this reduction is achieved through task-adaptive physical re- construction of the encoder rather than through masking or freezing redundant components. The resulting architecture therefore preserves the representational advantages of large- scale pathology pretraining while reducing the computational burden associated with downstream inference. The concurrent improvements in test accuracy and macro-F1 further indicate that the removed structural components are not essential for the target classification task and that task-adaptive compres- sion can produce a more efficient downstream representation without sacrificing predictive utility. This property distinguishes TAP-Path from parameter- efficient fine-tuning approaches. Adapter- and prompt-based methods can substantially reduce the number of parameters updated during task adaptation, and approaches such as PAMT demonstrate the effectiveness of this strategy in computational pathology [30]. However, these methods primarily reduce opti- mization cost while retaining most of the pretrained backbone for inference. In contrast, TAP-Path directly reconstructs a smaller executable encoder by removing task-redundant trans- former blocks, thereby reducing both deployed parameter count and analytical inference cost. This distinction is particularly relevant for pathology applications in which large numbers of image regions may need to be processed repeatedly and inference efficiency becomes an important deployment consid- eration. Knowledge-distillation approaches provide another comple- mentary route toward model compression. Methods such as 15 020406080100 F1 score (%) Rectum adenocarcinoma Mesothelioma Esophageal carcinoma Cholangiocarcinoma Colon adenocarcinoma Lymphoid Neoplasm Diffus Cervical squamous cell c Lung squamous cell carci Uterine Carcinosarcoma Kidney Chromophobe Stomach adenocarcinoma Skin Cutaneous Melanoma Uterine Corpus Endometri Bladder Urothelial Carci Head and Neck squamous c Adrenocortical carcinoma Lung adenocarcinoma Ovarian serous cystadeno Kidney renal papillary c Pancreatic adenocarcinom Uveal Melanoma Liver hepatocellular car Breast invasive carcinom Sarcoma Thymoma Pheochromocytoma and Par Glioblastoma multiforme Brain Lower Grade Glioma Kidney renal clear cell Thyroid carcinoma Testicular Germ Cell Tum Prostate adenocarcinoma Cancer class TAP-Path class-wise F1 (a) Per-class F1. Rare classes are highlighted with the contrasting bar color. (b) Row-normalized 32-class confusion matrix. Figure 11: Class-level evaluation of TAP-Path on the locked internal test set. The balanced panel layout combines class-wise F1 and normalized confusion behavior to expose performance heterogeneity that is not visible from aggregate accuracy alone. CPTAC-CCRCCCPTAC-UCECPooled CPTAC 82 84 86 88 90 92 94 96 Accuracy (%) 87.40% 94.79% 91.22% Frozen external validation Figure 12: Frozen external validation of TAP-Path on CPTAC- CCRCC and CPTAC-UCEC. SUDA transfer knowledge from a larger teacher into a compact student architecture [16], enabling substantial reductions in model size through an additional teacherâstudent optimization stage. TAP-Path addresses a different compression objec- tive: rather than replacing the pretrained foundation model with a separately trained student, it identifies and preserves the task-relevant structure within the pretrained model itself. Con- sequently, structural pruning, parameter-efficient adaptation, and knowledge distillation represent complementary strate- gies operating at different stages of the model lifecycle. Their combination provides a promising direction for future work, particularly through hybrid pruningâdistillation frameworks that first remove task-redundant structure and subsequently transfer the retained knowledge into an even smaller deploy- Figure 13: PCA of held-out TAP-Path image-level representa- tions. ment model. 5.3 Non-contiguous depth selection The structural screen provides evidence that depth alone is not an adequate proxy for task relevance. At equal 24-block param- eter count, TaskSparse24 outperformed contiguous Depth24 during validation screening. The result suggests that use- ful transformations are distributed non-uniformly through the pretrained hierarchy and that preserving selected late/middle blocks can recover information lost by naive truncation. This is consistent with the broad observation that pretrained trans- former representations change qualitatively across depth. We deliberately anchored early and final blocks. The early 16 020406080 Metric value (%) Accuracy Balanced accuracy Macro-F1 Rare BA ECE Stratified bootstrap 95% confidence intervals Figure 14: Stratified 95% bootstrap confidence intervals for the locked TAP-Path test evaluation. anchor protects low-level patch/token formation, while the late anchor preserves semantic consolidation close to the original pretrained output. The middle selection is then allowed to adapt. Although the novelty score in Eq.(7)is simple, its practical advantage is that it is model-internal, label-efficient for profiling, and compatible with physical block removal. A limitation is that normalized residual change is not a causal attribution score; a block can have a small residual magnitude yet still be important through subtle feature refinement. Fu- ture work could compare the current score with gradient- or Hessian-based block saliency. 5.4 Token-retention behavior The token ablation is particularly useful because the selected 70% ratio simultaneously improved screening validation accu- racy and reduced compute for TaskSparse24. One plausible interpretation is that class-token similarity plus magnitude sup- presses redundant or weakly aligned patches after sufficient hi- erarchical processing. Similar motivations underlie task-aware token pruning in generic vision transformers [17, 19]. How- ever, this effect was not universal: TaskSparse22 degraded as tokens were removed. Token sparsity therefore interacts with representational depth and should be selected jointly rather than treated as an independent compression knob. In pathology, this interaction deserves caution. Small dis- criminative regions can be clinically meaningful, so a high compression ratio could remove uncommon morphology. Our 70% setting was chosen by a validation Pareto rule and was not tuned on the test set. Moreover, rare-class behavior was evalu- ated explicitly. These safeguards reduce but do not eliminate the risk of token-pruning bias. 5.5 Reliability interpretation The reliability analysis shows that the compressed model pre- serves informative probabilistic behavior alongside its effi- ciency gains. The single-head TAP-Path achieved the best Brier score and failure-detection AUROC among the directly compared large-model configurations, while ECE and NLL remained close to UNI2-h. A failure-detection AUROC of approximately 0.90 indicates effective ranking of incorrect predictions toward lower confidence, supporting confidence- guided selective review. Clinical operating thresholds and safety characteristics require prospective, workflow-specific evaluation beyond these statistical reliability measures. Rare-class analysis further characterizes how the optimiza- tion objective changes model behavior. The primary objective favors aggregate predictive performance, whereas the rare- aware head increases rare-class balanced accuracy with a cor- responding shift in overall accuracy. Reporting the two oper- ating points separately provides a direct view of the accuracyâ minority-sensitivity trade-off and preserves the metric prove- nance of each configuration. 5.6 External transfer Independent evaluation is increasingly considered essential for pathology foundation models [9, 11, 27]. The CPTAC results show that TAP-Path maintains high accuracy and balanced accuracy after freezing the internal configuration. The differ- ence in class cardinality prevents direct comparison of internal 32-class macro-F1 with an external two-class macro-F1, which is why the manuscript emphasizes present-class balanced accu- racy externally. Across the independent CPTAC evaluation, TAP-Path main- tained strong transfer performance after the internal configura- tion was frozen. Hibou-B achieved slightly higher raw CPTAC accuracy, consistent with prior evidence that foundation-model rankings vary across domains and tasks [11, 12]. For the stud- ied 32-class task, the combined internal and external results position TAP-Path as an efficient high-capacity configuration with stable transfer behavior under the evaluated CPTAC co- horts. 5.7 Relation to efficient pathology methods Recent pathology-efficiency studies provide important con- text for this work. SUDA achieves aggressive compression by transferring knowledge from a large teacher to a com- pact student [16], whereas PAMT reduces downstream com- putational requirements through representative patch selec- tion and lightweight adaptation of frozen representations [30]. Other studies have explored resource-efficient architectures and accuracyâcomplexity trade-offs for histopathology analy- sis [15, 10]. Despite these advances, efficiency is commonly achieved through student-model distillation, input-level reduc- tion, lightweight adaptation, or architectures specifically de- signed for efficient inference. TAP-Path addresses a comple- mentary setting: task-adaptive compression of an already pre- trained pathology foundation model. Rather than pretraining a new foundation model, distilling a separate student, or retain- ing the complete parent architecture, TAP-Path restructures the pretrained parent for the downstream task by preserving task-relevant depth, reducing redundant token computation, and recovering complementary intermediate representations 17 within a single compressed inference pathway. Accordingly, TAP-Path is evaluated through a joint accuracyâefficiencyâreliability perspective that integrates pre- dictive performance with computational cost and probabilis- tic behavior. The proposed framework preserves competitive predictive performance relative to substantially larger pathol- ogy foundation models while reducing both model size and computational demand. This efficiency is evaluated together with three-seed reproducibility, probability calibration, failure- awareness analysis, and frozen external validation. Collec- tively, these evaluations examine whether a pretrained pathol- ogy foundation model can be structurally compressed for a specific downstream task while retaining predictive perfor- mance, computational efficiency, and informative confidence behavior. 6 Limitations Several directions remain for extending the present evaluation. First, TAP-Path contains 479.40M deployed parameters, plac- ing it between compact encoders such as Hibou-B/CONCH and larger Virchow2/UNI2-h systems. Further compression could target lower-resource deployment settings. Second, an- alytical FLOPs provide a reproducible architecture-level effi- ciency measure, while end-to-end deployment also depends on hardware, energy consumption, WSI throughput, slide load- ing, tissue detection, patch extraction, and storage I/O. The measured 31.85 ms image-level latency therefore characterizes the evaluated hardware configuration and motivates broader systems-level benchmarking. Third, the current external evaluation covers CCRCC and UCEC, providing an independent transfer assessment for two classes represented in the internal taxonomy. Extending this protocol to additional cancer types, scanners, and institutions would enable broader pan-cancer robustness analysis. Fourth, the primary objective prioritizes aggregate performance, while the rare-aware analysis demonstrates that minority-class sen- sitivity can be increased within the same compressed encoder. This motivates future structural-selection criteria that incor- porate class-frequency or minority-utility information directly during compression. Fifth, the block-novelty score quantifies normalized repre- sentational change and serves as a computationally efficient task-selection criterion. Future work can compare this crite- rion with gradient-, Hessian-, or attribution-based structural importance measures and examine how retained-block pat- terns transfer across endpoints. Finally, the present reliability analysis is statistical and model-centered; prospective clinical evaluation, reader studies, workflow-specific decision thresh- olds, and formal safety assessment are natural next steps for establishing clinical utility. 7 Conclusion We presented TAP-Path, a task-adaptive structural and token pruning framework for converting a large pretrained pathol- ogy foundation model into a more efficient task-specific en- coder without knowledge distillation. Starting from Virchow2, the method profiles task-relevant block novelty, physically re- tains 24 of 32 transformer blocks, adaptively preserves 70% of patch tokens after the pruning point, and recovers multi- depth information through a gated single task head. The re- sulting encoder reduces parameters by 24.96% and analytical FLOPs by 35.20%. Across three independent single-head runs, TAP-Path achieves 87.98±0.067% internal test accuracy and 82.38±0.48% macro-F1, matching or slightly exceeding much larger Virchow2 and UNI2-h baselines on the studied task. The compressed model also preserves useful probabilistic behav- ior, including a Brier score of 0.1800 and failure-detection AUROC of 0.9047, while frozen CPTAC evaluation reaches 91.22±0.83% accuracy. The results support a practical conclusion: scaling pathology foundation models and compressing them for deployment are not mutually exclusive. A large pretrained hierarchy can con- tain downstream-task redundancy that is removable through validation-constrained structural and token sparsification. At the same time, compression should be evaluated beyond top- line accuracy. Explicit reporting of calibration, error aware- ness, rare-class trade-offs, and independent external behavior is important for assessing whether the resulting efficiency gain remains suitable for trustworthy medical-AI research. Data Availability The histopathology data analyzed in this study were derived from publicly available resources from The Cancer Genome Atlas (TCGA) [32] and the Clinical Proteomic Tumor Anal- ysis Consortium (CPTAC) [33, 34]. TCGA data are acces- sible through the NCI Genomic Data Commons, while the corresponding CPTAC resources are available through NCI- supported data repositories. No external evaluation data were used for architecture selection or model optimization. A Reproducibility details A.1 Primary training configuration A.2 Experimental provenance The manuscript separates architecture screening, primary task evaluation, common-probe diagnostics, rare-aware operating- point analysis, and external validation.Metrics are not silently transferred between these protocols. This distinction is essential because the common-probe analysis answers a representation-quality question, whereas the original TAP-Path task head defines the proposed deployed system. References [1]R. J. Chen, T. Ding, M. Y. Lu, et al. âTowards a general- purpose foundation model for computational pathologyâ. 18 Table 11: Primary training configuration. SettingValue Parent foundation modelVirchow2 Retained blocks24/32 Patch-token retention70% Multi-depth taps4 Tap projection256 Dropout0.18 OptimizerAdamW Learning rate7Ă 10 â4 Weight decay2Ă 10 â4 Batch size384 Maximum epochs130 Early stopping18 epochs Gradient clip5 Label smoothing0.01 Seeds42, 123, 2026 Calibrationvalidation-only temperature scaling In: Nature Medicine 30 (2024), p. 850â862. DOI:10. 1038/s41591-024-02857-3. [2]M. Y. Lu, B. Chen, D. F. K. Williamson, et al. âA visual- language foundation model for computational pathol- ogyâ. In: Nature Medicine 30 (2024), p. 863â874. DOI: 10.1038/s41591-024-02856-4. [3]E. Vorontsov, A. Bozkurt, A. Casson, et al. âA founda- tion model for clinical-grade computational pathology and rare cancers detectionâ. In: Nature Medicine 30 (2024), p. 2924â2935. DOI:10.1038/s41591- 024-03141-0. [4] H. Xu, N. Usuyama, J. Bagga, et al. âA whole-slide foundation model for digital pathology from real-world dataâ. In: Nature 630 (2024), p. 181â188. DOI:10. 1038/s41586-024-07441-w. [5]X. Wang, J. Zhao, E. Marostica, et al. âA pathology foundation model for cancer diagnosis and prognosis predictionâ. In: Nature 634 (2024), p. 970â978. DOI: 10.1038/s41586-024-07894-z. [6] D. Nechaev, A. Pchelnikov, and E. Ivanova. âHibou: A Family of Foundational Vision Transformers for Pathol- ogyâ. In: arXiv preprint arXiv:2406.05074 (2024). [7]J. Ma, Z. Guo, F. Zhou, et al. âA generalizable pathology foundation model using a unified knowledge distillation pretraining frameworkâ. In: Nature Biomedical Engi- neering 10 (2026). Published online 2025, p. 545â564. DOI: 10.1038/s41551-025-01488-4. [8]F. Yan, J. Wu, J. Li, et al. âPathOrchestra: A Compre- hensive Foundation Model for Computational Pathology with Over 100 Diverse Clinical-Grade Tasksâ. In: arXiv preprint arXiv:2503.24345 (2025). [9]G. Campanella, S. Chen, M. Singh, et al. âA clinical benchmark of public self-supervised pathology founda- tion modelsâ. In: Nature Communications 16 (2025), p. 3640. DOI: 10.1038/s41467-025-58796-1. [10]J. Lee, J. Lim, K. Byeon, and J. T. Kwak. âBenchmark- ing pathology foundation models: Adaptation strate- gies and scenariosâ. In: Computers in Biology and Medicine 190 (2025), p. 110031. DOI:10.1016/j. compbiomed.2025.110031. [11] P. Neidlinger, O. S. M. El Nahhas, H. S. Muti, et al. âBenchmarking foundation models as feature extractors for weakly supervised computational pathologyâ. In: Na- ture Biomedical Engineering 10 (2026). Published on- line 2025, p. 1113â1123. DOI:10.1038/s41551- 025-01516-3. [12] R. Bareja et al. âA benchmark study of vision and pathol- ogy foundation models for computational pathologyâ. In: Nature Communications (2026). DOI:10.1038/ s41467-026-76004-6. [13] Kuang et al. âLW-CTrans: A lightweight hybrid net- work of CNN and Transformer for 3D medical im- age segmentationâ. In: Medical Image Analysis 102 (2025), p. 103545. DOI:10.1016/j.media.2025. 103545. [14]J. Silva-Rodriguez et al. âTowards Foundation Models and Few-Shot Parameter-Efficient Fine-Tuning for Vol- umetric Organ Segmentationâ. In: Medical Image Anal- ysis 103, 103596 (2025). DOI:10.1016/j.media. 2025.103596. [15] M. F. Islam, M. T. Reza, M. A. Manab, et al. âInvolution- based efficient autoencoder for denoising histopatholog- ical images with enhanced hybrid feature extractionâ. In: Computers in Biology and Medicine 192 (2025), p. 110174. DOI:10.1016/j.compbiomed.2025. 110174. [16]L. Zhong, K. Qian, W. Zhao, et al. âSUDA: Simulta- neous unsupervised knowledge distillation and adap- tation of foundation models for efficient pathologi- cal image analysisâ. In: Medical Image Analysis 113 (2026), p. 104177. DOI:10.1016/j.media.2026. 104177. [17]Liu et al. âRevisiting Token Pruning for Object Detec- tion and Instance Segmentationâ. In: Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision. 2024, p. 2658â2668. [18]Xu et al. âGTP-ViT: Efficient Vision Transformers via Graph-Based Token Propagationâ. In: Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision. 2024, p. 86â95. [19]Bergner et al. âToken Cropr: Faster ViTs for Quite a Few Tasksâ. In: Proceedings of the IEEE/CVF Confer- ence on Computer Vision and Pattern Recognition. 2025, p. 9740â9750. [20] An et al. âSparse Structure Exploration and Re- optimization for Vision Transformerâ. In: Proceedings of the 41st Conference on Uncertainty in Artificial Intel- ligence. Vol. 286. PMLR, 2025, p. 111â131. 19 [21]Marchetti et al. âEfficient token pruning in Vision Transformers using an attention-based Multilayer Net- workâ. In: Expert Systems with Applications 279 (2025), p. 127449. DOI:10 . 1016 / j . eswa . 2025 . 127449. [22] M. Munir, M. M. Rahman, and R. Marculescu. âAdaptViG: Adaptive Vision GNN with Exponential Decay Gatingâ. In: arXiv preprint arXiv:2511.09942 (2025). [23]C. Guo, G. Pleiss, Y. Sun, and K. Q. Weinberger. âOn Calibration of Modern Neural Networksâ. In: Proceed- ings of the 34th International Conference on Machine Learning. Vol. 70. PMLR, 2017, p. 1321â1330. [24] Y. Ovadia, E. Fertig, J. Ren, et al. âCan You Trust Your Modelâs Uncertainty? Evaluating Predictive Uncertainty Under Dataset Shiftâ. In: Advances in Neural Informa- tion Processing Systems. Vol. 32. 2019. [25] Y. Geifman and R. El-Yaniv. âSelectiveNet: A Deep Neural Network with an Integrated Reject Optionâ. In: Proceedings of the 36th International Conference on Machine Learning. Vol. 97. PMLR, 2019, p. 2151â 2159. [26] Y. Huang, W. Zhao, Z. Zhang, et al. âKnowledge-guided adaptation of pathology foundation models effectively improves cross-domain generalization and demographic fairnessâ. In: Nature Communications (2025). DOI:10. 1038/s41467-025-66300-y. [27]J. Komen, E. D. de Jong, J. Hense, et al. âTowards robust foundation models for digital pathologyâ. In: Nature Communications 17 (2026), p. 5218. DOI:10.1038/ s41467-026-73923-2. [28]M. Jahanifar, S. E. A. Raza, et al. âDomain General- ization in Computational Pathology: Survey and Guide- linesâ. In: ACM Computing Surveys 57.11 (2025). DOI: 10.1145/3729524. [29]Z. Yang, T. Wei, Y. Liang, et al. âA foundation model for generalizable cancer diagnosis and survival prediction from histopathological imagesâ. In: Nature Communi- cations 16, 2366 (2025). DOI:10.1038/s41467- 025-57587-y. [30]Y. Lin, Z. Zhu, K.-T. Cheng, and H. Chen. âPrompt- guided foundation model tuning for pathology image classificationâ. In: Medical Image Analysis 113 (2026), p. 104214. DOI:10 . 1016 / j . media . 2026 . 104214. [31]S. Boudissa, S. S. Debsarkar, H. Kawanaka, B. J. Aronow, and V. B. S. Prasath. âVision Transformers for Histopathological Image Classification with Efficient Head Pruningâ. In: Procedia Computer Science 270 (2025), p. 2274â2283. DOI:10.1016/j.procs. 2025.09.348. [32]The Cancer Genome Atlas Research Network et al. âThe Cancer Genome Atlas Pan-Cancer analysis projectâ. In: Nature Genetics 45.10 (2013), p. 1113â1120. DOI:10. 1038/ng.2764. [33] D. J. Clark et al. âIntegrated Proteogenomic Character- ization of Clear Cell Renal Cell Carcinomaâ. In: Cell 179.4 (2019), 964â983.e31. DOI:10.1016/j.cell. 2019.10.007. [34] Y. Dou et al. âProteogenomic Characterization of En- dometrial Carcinomaâ. In: Cell 180.4 (2020), 729â 748.e26. DOI: 10.1016/j.cell.2020.01.026. 20