When a transformer is fine-tuned on twenty CT scans, every attention head still recomputes, for every voxel and every scan, a fresh pattern of where to look. Attention here means the operation that weights neighboring positions by query–key similarity. Many of those heads may not need to be recomputed at all. If a head looks at roughly the same relative offsets regardless of the input, its dynamic computation adds cost and gives the model an input-dependent pathway through which it can fit scanner artifacts and noise. We propose to measure, head by head, how much a pretrained 3D segmentation transformer's attention actually depends on the input. Heads that barely vary are replaced with their average pattern, which is a fixed convolution kernel. Only the genuinely input-dependent heads are kept, and the resulting model is fine-tuned on the small target set.
The bet is twofold. Fewer dynamic heads make inference cheaper. The number of dynamic heads a model can afford also grows with the amount of training data, so the right number at twenty scans is much smaller than at a thousand. If both hold, efficient attention becomes a tool for small-sample learning rather than only for speed, and choosing which heads to freeze becomes a principled step that can be checked against data-size curves.
Core Claim
Two papers motivate the claim and one constrains it. Hard-Coded Gaussian Attention for Neural Machine Translation replaced learned self-attention with fixed Gaussians around the diagonal and matched a learned Transformer on IWSLT16 En-De (30.3 versus 30.0 BLEU). Its minimal variant decoded 30.2% faster. Hard-coding cross-attention, however, cost 5–10 BLEU. The lesson we take is that many but not all attention computations are redundant, and the redundant ones should be found rather than assumed. Adaptive Attention Distillation shows that in few-shot segmentation, attention "drifts" onto background clutter under noise. This suggests input-dependent attention is exactly where scarce data gets misfit.
Our claim is the following. In a pretrained 3D neighborhood-attention segmenter, heads whose attention distributions vary little across inputs can be replaced by their mean relative-offset pattern before low-data fine-tuning. Doing so preserves or improves accuracy at small training-set sizes while cutting attention cost. The fraction of heads that can be frozen without loss shrinks as the target set grows.
This differs from the Gaussian work in three ways. We do not design a fixed pattern a priori. We derive it from the pretrained model. We keep a measured subset of heads dynamic. We also work in 3D medical vision, not translation.
Research Program
The host model is the architecture of NA-UNETR. It restricts query–key products to local $k \times k \times k$ voxel windows, uses dilated windows for long-range vessel context, pretrains on 1,000 ImageCAS angiography volumes, and fine-tunes with Low-Rank Adaptation (LoRA, a method that trains only small low-rank weight updates). NA-UNETR keeps every head dynamic. We keep its pretraining recipe and change only what happens between pretraining and fine-tuning.
For each head $h$, we compute an input-dependence score on the target training data:
$$s_h = \mathbb{E}_{x,i}\left[\, \| a_{h,i}(x) - \bar a_h \|_1 \right].$$
Here $a_{h,i}(x)$ is the head's attention distribution over its $k^3$ window offsets at voxel $i$ of scan $x$. The quantity $\bar a_h$ is that distribution averaged over all voxels and scans. Averaging over relative offsets makes $\bar a_h$ translation-invariant. A frozen head therefore computes a fixed depthwise convolution of its values, ordinary for dilated heads too, and its query and key projections can be deleted.
We rank heads by $s_h$ and freeze the lowest-scoring fraction $\rho$. We then sweep $\rho$ and fine-tune the remaining dynamic heads with LoRA. Frozen kernels can either stay fixed or be fine-tuned as a handful of parameters per head, which we treat as an ablation. The score is cheap: one forward pass over the training scans.
The analysis has three parts. The first is the accuracy-versus-$\rho$ curve at each training-set size. The second asks where the optimal $\rho^*$ falls as size grows. The third is a check of whether the heads that stay dynamic are the dilated long-range heads, which would match the finding that CNNs lose vessel continuity in NA-UNETR. Because Xu et al. show that FLOPs misrepresent runtime when memory access is irregular, we report measured wall-clock time and peak memory, not just operation counts. Frozen heads become regular convolutions, so their savings should be real on GPUs.
Baselines
The naive reference point is fully dynamic NA-UNETR fine-tuned with LoRA, which is the configuration at $\rho = 0$. On the 20-scan LAD-SEG cohort, NA-UNETR reports 45.64% Dice and 38.16 mm HD95. It is the strongest published method on this exact question. Beating it means higher Dice or lower HD95 at the same data, with lower measured latency. The same paper reports nnU-Net at 42.54% Dice on LAD-SEG, and nnU-Net is the strongest pure-convolution competitor. We run it with its own self-configuration on identical splits and the same ImageCAS pretraining where applicable.
On full ImageCAS, ImageCAS reports 82.96% Dice for its coarse-to-fine method. NA-UNETR reaches 79.49%. For subsampled ImageCAS training sets of 20–100 scans, no reported result was found on Lacuna, so we produce all such numbers ourselves.
Fairness is enforced as follows. Every arm uses the same pretrained checkpoint, splits, augmentation, epochs, and an equal hyperparameter search budget. We also give the fully dynamic baseline the same search over LoRA rank and dropout that our method gets.
Two ablations isolate the key ingredient, which is choosing heads by measured input-dependence. The first freezes a random set of heads at the same $\rho$. The second replaces selected heads with hand-designed isotropic Gaussians, in the style of You et al., instead of their measured mean map. A third control matches trainable-parameter count: we reduce LoRA rank in the dynamic baseline until it adapts as few parameters as our frozen model. This tests whether the effect is just less capacity.
Why not just…?
Why not just use nnU-Net, since a frozen head is a convolution anyway? This is the most serious objection. At $\rho = 1$ our model is essentially a pretrained CNN. The proposal survives only if an intermediate $\rho$ beats both endpoints. That would mean a few dynamic heads carry information convolution cannot, consistent with NA-UNETR's 3.1-point margin over nnU-Net on LAD-SEG. If accuracy rises monotonically with $\rho$ up to 1, the honest conclusion is that a pretrained CNN suffices, and we would report that.
Why not just regularize the dynamic model harder, with lower LoRA rank, more dropout, or attention dropout? These reduce capacity uniformly, whereas our method removes input-dependence selectively and also removes compute. The parameter-matched and tuned-dropout controls in Baselines test this directly. If they match our accuracy, the regularization half of the claim fails and only the efficiency half remains.
Why not just shrink the window or freeze all heads to Gaussians, as in the NMT work? The Gaussian work itself shows a uniform hard-coding policy breaks for the computations that need dynamic alignment, with cross-attention losing 5–10 BLEU. It also degrades on long-distance agreement. The Gaussian and random-selection ablations measure whether choosing heads by measured variance matters. If random freezing matches it, the score is unnecessary and the simpler policy wins.
Proposed Experiments
The main experiment builds a data-size curve on ImageCAS. We train on nested subsets of 20, 50, 100, 300, and 1,000 scans from a source checkpoint pretrained on a disjoint ImageCAS portion. We sweep $\rho$ over $\{0, 0.25, 0.5, 0.75, 0.9, 1\}$ and report Dice, HD95, latency, and memory over five seeds. The decisive check is whether $\rho^*$ decreases with training-set size and whether, at 20–50 scans, some $\rho^* \in (0,1)$ beats both $\rho = 0$ and nnU-Net beyond seed variance.
The second experiment targets the actual clinical shift. Using the ImageCAS-pretrained model, we fine-tune on LAD-SEG, if access is obtained from its authors, and compare against the published 45.64% Dice. We also test whether head scores computed on contrast data differ from those computed on the non-contrast target. A large difference would indicate that the contrast shift lives in specific heads.
The third experiment checks generality on AMOS and FLARE'22 at the 1% label regime used by MedGMAE. We apply the same freezing procedure to a neighborhood-attention encoder. The claim is falsified if variance-ranked freezing is no better than random freezing on two of the three settings, or if no intermediate $\rho$ beats both endpoints at small data.
References
- Hard-Coded Gaussian Attention for Neural Machine Translation
- Adaptive Attention Distillation for Robust Few-Shot Segmentation under Environmental Perturbations
- A Neighborhood Attention Transformer Network for Enhanced 3D Segmentation of the Left Anterior Descending Artery
- DEFA: Efficient Deformable Attention Acceleration via Pruning-Assisted Grid-Sampling and Multi-Scale Parallel Processing
- ImageCAS: A large-scale dataset and benchmark for coronary artery segmentation based on computed tomography angiography images
- MedGMAE: Gaussian Masked Autoencoders for Medical Volumetric Representation Learning