Block-Sparse Evolutionary Prompts for Indel-Aware Fitness Scoring

Protein language models that score mutations have a structural blind spot: nearly all of them assume the protein is a fixed-length string, so a single deleted residue shifts every downstream position and the model reads the whole tail of the sequence as corrupted, even when the 3D structure is untouched. A second, quieter problem compounds the first. The models that do handle insertions and deletions — by treating a protein family as an unordered pile of variable-length homolog sequences given as a prompt — get better as you feed them more homologs, but they pay dense quadratic attention over the entire prompt. PoET shows accuracy keeps improving as the prompt grows from 8,000 to 61,000 tokens, and simultaneously reports that scoring large variant libraries at that depth is computationally bottlenecked. Meanwhile, the long-context text-modeling world has solved an isomorphic problem: Native Sparse Attention gets 11.6× decoding speedups at 64k tokens by selecting and compressing key/value blocks in hardware-aligned kernels, and PBS-Attn gets up to 2.75× prefilling speedups by permuting tokens so that important ones cluster into dense blocks.

This proposal ports the hardware alignment ideas but not the text assumptions. The core obstacle is that homologous sequences in a prompt form an unordered set — attention across them must be invariant to their order — whereas text sparse-attention methods assume a one-dimensional causal token order. Our claim is that homolog sets have exactly the structure blocked sparse kernels want: homologs are similar to each other, so the between-sequence attention mass concentrates on a few similarity clusters, and this structure is static per family while a screening campaign scores millions of variants against the same prompt. That makes the expensive preprocessing that SMaT flags as prohibitive for dynamic patterns here perfectly amortizable.

Core Claim

A two-tier, cluster-blocked set attention — full attention within offline-computed homolog similarity clusters, plus attention to one compressed representative per remaining cluster — can reproduce the scoring accuracy of a dense sequences-of-sequences model on insertion/deletion benchmarks while delivering multi-fold wall-clock speedups on the task that actually matters in protein engineering: exhaustively scoring a combinatorial variant library against a deep evolutionary prompt. The sharpening ingredient beyond existing sparse attention is mask stationarity: because every variant in a library differs from the wild type at only a few positions, the block-selection pattern computed once for the wild type should transfer to its variants, letting us route attention for an entire library with a single set of decisions.

Formally, for a query token $q_i$, set attention over a prompt of $N$ homologs partitioned into $C$ similarity clusters replaces the dense sum over all $T = N\bar{L}$ prompt tokens (average length $\bar{L}$) with

$$\text{Attn}(q_i) \;=\; \sum_{c \in \mathcal{S}(i)} \sum_{j \in c} a_{ij} v_j \;+\; \sum_{c \notin \mathcal{S}(i)} a_{i,\bar{c}}\, \bar{v}_c,$$

where $\mathcal{S}(i)$ is the small set of clusters selected for query $i$, $v_j$ are key/value vectors, and $(\bar{v}_c, a_{i,\bar{c}})$ are a compressed representative and its attention weight for unselected cluster $c$. The cost drops from $O(T^2)$ to roughly $O(T \cdot T/C \cdot \rho + T C)$ where $\rho$ is the selected fraction — the same compressed-plus-selected decomposition that makes Native Sparse Attention fast, but with clusters defined by sequence similarity rather than position, and with the selection $\mathcal{S}(\cdot)$ computed once per family and reused across variants.

This differs from every cited work in a specific way. PoET supplies the variable-length, indel-capable sequences-of-sequences formulation but computes all attention densely. Native Sparse Attention and PBS-Attn supply the hardware-aligned block-sparse machinery but assume 1D causal text order and recompute routing for every input; PBS-Attn's own analysis reports 5.2% of attention heads suffer from its segmented causal permutation, a failure mode we avoid by never imposing a false linear order on homologs. SMaT proves permutation-and-blocking pays off (up to 125× over cuSPARSE, beating dense cuBLAS at sparsity as low as 78%) but for static sparse matrices, not variable-length sequence prompts. TranceptEVE reaches strong indel accuracy by re-aligning every variant to a family alignment at test time, which is exactly the per-variant latency we eliminate. We deliberately do not pursue the other tempting intersection in the file — sparsifying the gap-token buffer of DPLM-Evo — because gap positions there can activate into residues during denoising, so any static block mask risks silently forbidding insertions; prompt-side sparsity has no such moving target.

Research Program

The build has four components. First, a cluster-canonical ordering: given a family's homolog set, we cluster sequences by pairwise similarity and store them so that cluster members are contiguous in memory, in the spirit of SMaT's Jaccard-based row permutation but applied to sequences, with the crucial difference that this ordering is computed once per family and amortized over an entire screening campaign rather than per matrix. Because the ordering is a deterministic function of sequence content, the resulting attention remains exactly invariant to the input order of the prompt set — we verify this directly.

Second, the two-tier set-attention kernel: within a cluster, full attention runs as dense tensor-core tiles over contiguous blocks (the "load as sparse, compute as dense" trick that lets Flash-LLM beat cuBLAS by up to 2.1×); across clusters, each query attends only to compressed per-cluster representatives carried in fast on-chip memory, following NSA's group-centric key/value sharing across heads. Within-sequence (autoregressive) attention keeps ordinary causal masks, since PoET's Phase 1 is genuinely sequential and existing causal block-sparse kernels apply there with minimal modification.

Third, mask stationarity for library scoring: when screening, we run block selection once on the wild-type sequence against the prompt, then score every variant using the reused selection, recomputing only the variant tokens' contributions. This is the component no prior system offers — NSA and PBS-Attn both re-derive routing per input — and it is what converts sparse attention from a constant-factor win into a change in what is feasible: the prompt's key/value cache and routing plan are computed once, and each additional variant costs only a shallow incremental pass.

Fourth, an accuracy-preservation guarantee strategy: the compressed representatives are trained jointly (NSA is natively trainable, and we follow that recipe) so the sparse model learns to work with its own compression rather than having sparsity imposed post hoc, which MACKO shows is where accuracy losses come from in rigid patterns like 2:4.

For the base model we will adapt a PoET-style tiered transformer trained on UniRef50 homolog clusters (29 million sets, the corpus PoET used); if a usable checkpoint is not available we train a mid-scale replica, matched in data and parameter count to a dense reference model we train under the identical recipe so the accuracy comparison isolates sparsity alone.

Baselines

The "do nothing" reference is a dense PoET-replica: the same tiered transformer architecture with full quadratic attention over the prompt, executed with a standard dense FlashAttention kernel. This is the accuracy ceiling and the wall-clock floor; we run it with the same prompt sets, the same model size, and the same hardware, and our method counts as succeeding only if it stays within 0.005 mean Spearman correlation of this dense twin while scoring a full variant library at least twice as fast. The strongest published accuracy competitor on indels is TranceptEVE, which reports a mean Spearman correlation of 0.516 on the ProteinGym indel benchmark, 0.472 on substitutions, and 0.915 ClinVar AUC, and which handles indels by dynamically re-aligning each variant to a family alignment and evaluating a per-family VAE; we run it as published (its per-family models, its alignment pipeline) on the same assays and additionally measure its per-variant wall-clock, since its known weakness is precisely the test-time alignment cost our design removes. Beating it means exceeding 0.516 indel Spearman at lower median wall-clock per scored variant. Two further method-transfer baselines make the comparison honest: Native Sparse Attention-style hierarchical attention and PBS-Attn-style token permutation, both applied naively to the concatenated prompt as if it were 1D text, tuned with the same budget we give our own method. Finally, the ablation that isolates our key ingredient is the identical cluster-blocked kernel with mask reuse disabled — block selection recomputed per variant — plus a variant with random cluster selection, so the gains decompose into clustering, compression, and mask reuse rather than an undifferentiated "sparse is faster" effect.

Why not just…?

Why not just run dense attention on bigger hardware? This is the most serious objection, and the file's evidence cuts both ways: MACKO beats dense cuBLAS by only 1.2–1.5× at 50% sparsity, while SMaT only overtakes cuBLAS at roughly 78% sparsity or higher. If homolog-set attention turns out to be only moderately concentrated, dense execution on an H100 is the right answer and this proposal should die. That is why our first experiment is a pure measurement, before any model training: we extract attention maps from a dense PoET-style model across UniRef50 families at several prompt depths and ask what fraction of clusters captures 95% of the attention mass. If the effective sparsity sits below the dense-favorable regime, we report that as a negative result; our prior is that it does not, because homologs are redundant by construction, but the experiment settles it either way.

Why not just apply NSA or PBS-Attn off the shelf? They would deliver most of the speedup with none of the new code, and if they also matched accuracy, our contribution would collapse into a porting exercise — we say this plainly. The concrete reasons to expect them to fall short are structural: both impose a 1D causal order, which breaks the permutation invariance PoET's between-sequence attention requires (PBS-Attn already reports 5.2% of heads degraded by its own segmentation in the text setting), and protein residue interactions do not decay with token distance the way language locality does, so sliding-window branches of NSA cover much less of the useful mass. We will run both as tuned baselines rather than argue from principle, and include a decisive shuffle test — permuting the order of homologs in the prompt must leave scored likelihoods unchanged — which our cluster-canonical design passes by construction and any 1D-order method fails. If either baseline matches our accuracy anyway, the fallback contribution is mask-reuse library scoring, which neither method supports.

Why not just truncate the prompt, or skip prompts entirely? A shorter prompt is the simplest speedup of all, and a plain autoregressive model like Tranception scores indels with no prompt overhead whatsoever. The file's evidence says both give up real accuracy: PoET shows performance grows with prompt depth up to 61,000 tokens and that unconditional models are hard to steer toward a target family, and TranceptEVE shows family-agnostic models lag family-conditioned ones (0.472 substitution and 0.516 indel Spearman with family context). Still, the threat is real: if an 8,000-token prompt captures, say, 95% of the accuracy of a 61,000-token one, truncation wins on simplicity. Our answer is an accuracy-versus-depth curve for both the dense and sparse models: the sparse method's value proposition is extending the feasible depth — targeting 128k–256k token prompts on a single GPU where dense attention does not fit in memory at all — and if the depth curve is flat past 16k tokens, we will report that the scaling hypothesis itself is wrong and the whole premise weakens.

Proposed Experiments and Decisive Checks

The feasibility measurement comes first: attention-mass concentration across homolog clusters on UniRef50 families at 8k, 32k, and 61k prompt tokens, establishing the sparsity regime and the cluster count $C$. The headline evaluation is the ProteinGym benchmark suite — 217 substitution assays and 66 indel assays covering roughly 300,000 mutants, plus ClinVar clinical variants (ProteinGym) — scored zero-shot with deep prompts, reporting mean Spearman correlation on substitutions and indels and AUC on ClinVar. Anchors from the file: TranceptEVE at 0.516 indel and 0.472 substitution Spearman and 0.915 ClinVar AUC, with EVE at 0.909 and ESM-1b at 0.882 ClinVar AUC as lower references; DPLM-Evo at 0.495 indel and 0.424 substitution Spearman; SCISOR at 0.573 Spearman on the single-deletion subset; ProteinNPT at 0.613 Spearman but only in the supervised, fixed-grid setting that cannot process indels at all. For PoET itself, no reported result found on Lacuna for its exact ProteinGym Spearman values, so our dense replica rather than a published number serves as its accuracy stand-in. Speed is measured the way practitioners experience it: wall-clock and memory to exhaustively score all single and double indel variants of a family on one GPU, variants per second at matched accuracy, and the maximum prompt depth that fits on that GPU for dense versus sparse. The mask-stationarity ablation quantifies the Jaccard overlap between wild-type and variant block selections and the accuracy and throughput cost of recomputing versus reusing. Generation quality is a secondary check: sampled proteins evaluated by ESMFold pLDDT, against DPLM-Evo's reported 83.6 average pLDDT and PoET's reported pLDDT above 90 on generated lysozymes and mutases. The decisive checks, stated in advance: cluster-blocked attention must match its dense twin within 0.005 mean Spearman on both ProteinGym suites; it must exceed TranceptEVE's 0.516 indel Spearman; it must deliver at least 2× library-scoring throughput at matched accuracy; and it must pass the homolog-order shuffle test that every 1D-causal alternative fails. A known limitation we state up front: none of this helps orphan proteins without homologs, where the prompt is empty and the sparse machinery has nothing to compress.