Pruning Protein Language Models to Their Task Subspace for Edge Inference

Protein language models are transformers trained to fill in masked amino acids across millions of natural proteins. Their internal vectors, called embeddings, are now the standard input for predicting protein stability, binding, and function. Running them is expensive. The useful models have hundreds of millions of parameters, which puts them out of reach of the laptops, field sequencers, and point-of-care devices where privacy or a missing network connection makes local inference attractive. The obvious fix is to prune away most of the weights. That backfires on commodity and edge hardware: scattered zeros give irregular memory access, and the extra indexing costs more time than the skipped arithmetic saves. Measurements on GPUs show this clearly (Sparse GPU kernels for deep learning). The hardware pattern that does pay off, 2:4 sparsity, works only on recent NVIDIA GPUs that edge devices do not have.

This note proposes a different route. A recent analysis found that protein language model embeddings, though nominally 320 to 1280 dimensions wide, occupy only about 15–30 effective dimensions per residue and about 10 per protein (Probing the Embedding Space of Protein Foundation Models through Intrinsic Dimension Analysis). If downstream predictors only read a few dozen directions, the pruning objective should not be "reproduce every layer's output". It should be "reproduce the embedding inside that small subspace". A much looser target should let us delete whole attention heads and feed-forward neurons, which leaves smaller dense matrices that run faster on any CPU. The hypothesis is that this keeps the accuracy of a large model at the measured latency of a small one.

Core Claim

Structured pruning of a large protein language model, guided by two things, yields a better accuracy–latency trade-off on edge CPUs than either a small dense model of matched latency or unstructured and 2:4 sparsity. The two guides are, first, an objective that preserves only a low-dimensional task-relevant subspace of the final embedding, and second, latency costs measured on the target device. Concretely, we predict that a pruned ESM-2 650M that runs as fast as dense ESM-2 150M on an ARM CPU will beat it on supervised fitness and property prediction, including tasks never seen during pruning.

The calibration objective is

$$ \mathcal{L} = \mathbb{E}_x \left\| U^\top \big(h_\theta(x) - h_{\text{dense}}(x)\big) \right\|^2 + \lambda\, \mathbb{E}_x \left\| (I - UU^\top)\big(h_\theta(x) - h_{\text{dense}}(x)\big) \right\|^2 , $$

where $h_{\text{dense}}(x)$ is the dense model's final embedding of protein $x$ (per residue or mean-pooled), $h_\theta(x)$ is the pruned model's embedding, $U$ is a $d \times k$ orthonormal basis with $k$ near the measured intrinsic dimension, and $\lambda \ll 1$ weakly penalizes drift outside that subspace.

Which structures to remove is decided by a ratio of loss increase to measured milliseconds saved on the device. This borrows the efficiency-ratio idea of Constraint-Aware Importance Estimation for Global Filter Pruning under Multiple Resource Constraints, which scores convolutional filters by accuracy loss per unit of combined FLOP and parameter savings. We apply it to transformer heads and neurons and replace its linear FLOP proxy with lookup tables profiled on the device. That replacement addresses the mismatch with real cache and dispatch behavior that the method itself acknowledges.

Research Program

The intrinsic-dimension paper motivates the work but does no compression. It measures embedding geometry across ESM-2 sizes and shows that fine-tuning collapses the representation further, to an intrinsic dimension of 2.5. We turn that diagnosis into a pruning target. The work has three parts.

Choosing the subspace. We build the basis $U$ in three ways. The first takes the top-$k$ principal directions of dense embeddings on a broad calibration set of UniRef50 sequences. The second spans the weight vectors of linear probes trained on a few calibration tasks. The third combines both. The open question is which of these transfers to downstream tasks that played no role in building $U$. For multiple tasks, we test taking the union of per-task probe subspaces rather than one shared basis. This mirrors the per-task saliency of DiSparse: Disentangled Sparsification for Multitask Model Compression, which separates task importances in vision backbones. Working with subspaces instead of masks avoids its inability to hit an exact sparsity target, because we prune to a latency budget, not a mask overlap.

Pruning on the device. We profile each layer's attention heads and feed-forward widths on two targets: an ARM Cortex-A class board and an x86 laptop CPU, both running a standard dense runtime with no custom sparse kernels. Pruning is iterative. Each round removes the heads and neurons with the lowest loss-per-millisecond ratio, then runs a short calibration fine-tune on $\mathcal{L}$, until the latency budget is met. Removed heads and neurons leave smaller dense matrices, so no custom kernel is needed. INT8 quantization is then applied on top, because it is orthogonal and cheap.

Diagnosing the result. We re-measure the intrinsic dimension of the pruned embeddings and check whether the pruned model preserves the long-range structure behind its usefulness. Specifically, we test whether attention maps still predict residue contacts. This is the property PGraphDTA: Improving Drug Target Interaction Prediction using Protein Language Models and Contact Maps relies on when it replaces local convolutional networks with language model embeddings.

The scope is deliberately limited to embedding-based supervised prediction. Zero-shot mutation scoring reads the full 20-way amino acid distribution from the masked-prediction output layer (Language models enable zero-shot prediction of the effects of mutations on protein function). That distribution is not obviously confined to a low-dimensional subspace, so we report zero-shot as a stress test where the method may lose.

Baselines

Naive reference points. The do-nothing reference is the dense ESM-2 650M itself, run on the same CPUs; it sets the accuracy ceiling and the latency we must cut. The naive cheap reference is a ridge regression on one-hot sequences. On FLIP it reaches Spearman 0.59 on GB1 single and double mutants but only 0.15 on the human thermostability split, against 0.77 for ESM-1v (FLIP: Benchmark tasks in fitness landscape inference for proteins). Any edge method must sit well above ridge on thermostability to justify a transformer at all.

Dense small models (the strongest competitor). The strongest competitor is the dense smaller model of matched measured latency: ESM-2 150M, and ESM-2 8M for the tightest budgets. It needs no engineering and already runs at full dense speed. We run it with the same downstream heads, the same training splits, and the same head-tuning budget, on the same device and runtime with INT8 applied. Beating it means higher Spearman on the held-out FLIP and ProteinGym tasks at equal or lower measured latency and peak memory, with the gap exceeding the seed-to-seed spread. No reported result was found on Lacuna for structured-pruned ESM-2 on FLIP or ProteinGym, so the dense-small numbers we measure become the reference.

Ternary quantization. For extreme compression, the existing method is the ternary ESM-2 8M of 2Bits of Protein: Efficient Protein Language Models at the Scale of 2-bits. It restricts encoder weights to −1, 0, and 1. It reports an average zero-shot Spearman of 0.181 over 217 ProteinGym substitution assays, statistically below full-precision ESM-2 8M. It reports no wall-clock or edge measurements. We rerun it on our devices.

Unstructured and 2:4 sparsity. For sparsity, we compare against unstructured magnitude pruning to 70–90%, run on the best available CPU sparse kernel. We also compare against a 2:4-pruned model with block-diagonal correction following ARMOR: High-Performance Semi-Structured Pruning via Adaptive Matrix Factorization. ARMOR closes up to half of the perplexity gap of rigid 2:4 masks on Llama-2 and Qwen. It reaches 1.57× layer speedup on Qwen 2.5-14B, but only on Ampere-class GPUs. We report its CPU latency and also its GPU latency, to show what it costs to lose sparse tensor cores.

Ablation of the key ingredient. Our method is run twice with identical latency targets and compute. One run uses the full-reconstruction objective ($U = I$); the other uses the subspace objective. A second ablation replaces measured latency with FLOP counts in the importance ratio.

Why not just…?

Why not just use ESM-2 150M or 8M dense? This is the real threat, and the experiment is built around it. The supporting evidence is indirect. Rigging the Lottery: Making All Tickets Winners found that a sparse MobileNet-v1 at 90% sparsity reaches 67.0% on ImageNet, beating dense networks of equal parameter count. That suggests pruned large models can outperform small ones at the same budget, but the evidence comes from vision and unstructured masks. If the latency-matched dense model ties our pruned model on held-out tasks, the honest conclusion is that size-family selection is enough for edge protein work, and we will report it as such.

Why not just apply unstructured pruning with a good sparse library? On GPUs, the custom Sputnik kernels beat dense matrix multiplication only above roughly 71% sparsity. Vendor libraries need about 98% (Sparse GPU kernels for deep learning). Their memory-alignment tricks are GPU-specific, and no result in the file shows comparable gains on edge CPUs. Rather than argue the point, we measure it: the unstructured baseline is run on-device, and we report where its latency curve crosses the dense model's.

Why not just distill into a small model, or project embeddings with principal component analysis (PCA)? PCA on the output shrinks the downstream head but not the forward pass, which is where the cost lies, so it cannot meet the latency budget. Distillation into a fresh small model is a genuine alternative. It also costs pretraining-scale compute; FLIP reports up to 50 A6000 GPU-days just for baselines. We include a distilled 150M-sized student trained with the same total GPU-hours as our pruning-plus-calibration run. If it matches us at that budget, structured pruning offers no advantage beyond convenience.

Why not just quantize to INT8 and stop? INT8 reduces memory traffic but keeps every layer, so its latency floor is fixed by model depth and width. We apply INT8 to every method, including ours, so its gain cancels out of the comparison. The question is whether removing structure buys anything beyond quantization.

Proposed Experiments

The main evaluation pairs the device-measured latency–accuracy curve against downstream performance. Downstream tasks are the FLIP splits for GB1, AAV, and Meltome thermostability, scored by Spearman correlation, plus supervised probes on ProteinGym substitution assays (ProteinGym: Large-Scale Benchmarks for Protein Fitness Prediction and Design). Two reference numbers anchor ProteinGym. The supervised ProteinNPT reports 0.613, as an upper reference for what embeddings plus heads can reach. ESM-1v reports 0.509 on the 41 deep mutational scanning (DMS) assays of the zero-shot study, as a reference for the zero-shot stress test.

The calibration subspace $U$ is built from GB1 and a subset of ProteinGym assays only. Thermostability, AAV, and the remaining assays are strictly held out. Latency targets are set at the measured speeds of dense 150M and dense 8M on each device. At each target we report Spearman, median and tail latency, peak RAM, and energy per protein measured by power meter.

The decisive check. The decisive check is the held-out comparison at the 150M-matched latency. The subspace-pruned 650M must beat dense 150M on held-out tasks. It must also beat the full-reconstruction ablation, which shows the subspace objective, not pruning per se, does the work.

Secondary checks. A secondary check asks whether the advantage tracks the measured intrinsic dimension. Choosing $k$ well below about 10 should hurt held-out transfer, while $k$ in the 15–30 range should not. The AAV low-vs-high extrapolation split, where FLIP reports Spearman below 0.35 for most models, tests whether pruning destroys the out-of-distribution behavior that justifies pretrained models. Finally, the zero-shot ProteinGym evaluation will tell us whether the subspace argument fails, as we expect it may, when predictions read the full output distribution rather than a probe.