One way to make a vision transformer small is to reuse the same block of layers over and over, looping a few layers many times instead of stacking many distinct ones. This works poorly when one network must serve several dense prediction tasks at once. Dense prediction means producing an output at every pixel: semantic labels, depth, surface orientation, object edges. These tasks want different features, and a looped block computes the same transformation for all of them at every depth. We propose to let the tasks share every large weight matrix and to put all task-specific and depth-specific behavior into one cheap place: the gate of a gated linear unit.
A gated linear unit is a feedforward layer that multiplies a feature stream by a learned, input-dependent mask between 0 and 1. We condition that mask on which task is being computed and on which loop iteration it is in. We also factor the mask into a "what" part (which channels pass) and a "where" part (which image locations pass), borrowing the channel-and-spatial split from dual-attention vision models. The claim is that a tied backbone plus a few thousand gate parameters per task and iteration can match per-layer low-rank adapters and untied multi-task models at the same parameter count. There is also a systems benefit: the shared weights are loaded once and applied to every task stream at every iteration.
Core Claim
In a weight-tied multi-task dense-prediction transformer, the gate of a gated feedforward layer is a sufficient and much cheaper site for specialization than the weights themselves. Concretely, let $x$ be the token features at loop iteration $r$ for task $t$. Let $W_v$ and $W_g$ be the shared value and gate matrices of a gated feedforward layer. Let $a_{t,r}$ be a learned channel bias vector, and let $s_{t,r}(x)$ be a one-channel spatial map produced by a tiny depthwise convolution over channel-pooled features. The feedforward output is
$$y = (W_v x) \odot \sigma\big(W_g x + a_{t,r}\big) \odot s_{t,r}(x),$$
where $\sigma$ is the logistic sigmoid and $\odot$ is element-wise multiplication, with $s_{t,r}(x)$ broadcast across channels. Only $a_{t,r}$ and the small convolution in $s_{t,r}$ are unique to a (task, iteration) pair, which is on the order of $d$ plus a few hundred parameters for width $d$. A rank-$k$ adapter on the same layer costs about $2dk$ per matrix. The gate stays input-dependent at test time, because both $W_g x$ and $s_{t,r}(x)$ depend on the image.
Where This Sits
Three lines of multi-task dense prediction work motivate the problem but leave the backbone alone. TaskPrompter adds learnable task tokens that interact with image patches along spatial and channel axes inside an untied ViT and reuses the attention maps as decoder features. DeMT uses per-task channel mixing and deformable spatial convolution before a task-interaction transformer decoder. InvPT models all tasks jointly with global spatial attention in a growing-resolution decoder. All three keep every backbone layer's weights distinct and use ungated feedforward layers. Our proposal changes the backbone instead: it is tied across depth, and tasks differ only through gates. TaskPrompter is the closest in spirit, since its spatial-channel task interaction is what we move into the feedforward gate. The difference is that TaskPrompter specializes through attention over extra tokens in an untied network, whereas we specialize through multiplicative gates inside a tied one.
InterroGate constrains the design and also motivates it. It learns gates that route each task through shared or task-specific branches, then freezes those gates into static masks and prunes the unused branches. Its authors note that the gating is channel-only and suggest gating over patch tokens as future work. We take up that suggestion with the spatial factor, and we test their static-at-inference choice directly against dynamic gates.
Two papers supply the parameter-sharing method. Relaxed Recursive Transformers loop a tied block with per-iteration low-rank adapters. They initialize those adapters from a truncated singular value decomposition of the difference between the pretrained layer weights and the tied weights, and recover much of an untied model's quality. We reuse their pretrained-layer initialization for the tied block. We replace their adapters with gate conditioning and extend the setting from single-task text to multi-task vision.
Masked Gated Linear Unit provides the systems argument. It identifies the memory traffic of loading two feedforward matrices as the bottleneck of gated layers. It reports a 34% speedup and 47% memory reduction over standard gated-layer kernels by deriving both streams from one masked matrix. In our design, tying raises the reuse of each loaded weight by a factor of (iterations × tasks). Their masked single-matrix variant is an optional add-on we test, not the core idea.
The Feedback Transformer is a constraint on the design. Its feedback from top layers to bottom layers requires processing tokens one after another. We therefore loop over depth only, keeping all patches parallel.
The dual-attention literature motivates factoring the gate into channel and spatial parts. ABD-Net runs parallel spatial and channel attention, and boundary-aware dual attention uses boundary maps to gate semantic channels. Both argue that channel weighting alone amplifies background uniformly. ATRC reports that boundary detection benefits least from shared features. Together these predict where the spatial factor should matter most.
Research Program
We build a backbone with three parts. A short untied stem of two layers is shared across tasks. A tied block of $K$ layers is looped $R$ times per task stream. Lightweight task heads sit on top. The tied block is initialized by averaging pretrained ViT layers, following Relaxed Recursive Transformers. All task streams run as one batch through the same weights, so the large matrices are fetched once per iteration regardless of the number of tasks. Compute still grows with the number of tasks, and we report FLOPs honestly alongside parameters and measured latency.
The analysis has three parts. First, we trace parameter-versus-quality curves across $K$, $R$, and backbone width. Second, we compare where specialization lives: gate bias, spatial map, adapters, or both. Third, we inspect learned spatial maps per task and iteration to test whether early iterations become location-selective and late iterations become channel-selective, as the "where then what" intuition predicts.
Baselines
The naive reference point is the tied backbone with no conditioning at all. All tasks share the same looped block and differ only in their heads. This is the ALBERT-style setting that Relaxed Recursive Transformers show loses capacity. Any method must clear it. It is run with identical data, schedule, and heads.
The strongest parameter-matched competitor is the same tied backbone with per-task, per-iteration low-rank adapters. This is Relaxed Recursive Transformers extended to tasks, with ranks chosen so the adapters' total parameters equal our gate parameters, and also at a 4× larger budget. Both variants get the same truncated-SVD-style initialization where applicable and the same hyperparameter search budget. Beating it means equal or better multi-task improvement over single-task models (the $\Delta_m$ metric) at matched parameters. Matching it at a quarter of its specialization parameters would also count.
The strongest absolute systems are untied multi-task models. On NYUD-v2, TaskPrompter reports 55.30 semantic segmentation mIoU, and on PASCAL-Context it reports 80.89 mIoU. DeMT reports $\Delta_m$ = 3.36% on NYUD-v2 with a Swin-T backbone at 100.7 GFLOPs. InterroGate reports +2.06 multi-task score with HRNet-18. We do not expect to beat TaskPrompter's absolute numbers with a much smaller backbone. The fair test is against an untied multi-task model of the same family, retrained by us at our total parameter count. We define success as a better parameter-quality frontier, with DeMT's $\Delta_m$ of 3.36% as the target for the full-size configuration.
The key ablations isolate the gate's ingredients. They are channel bias only (a static per-task scaling close to InterroGate's channel gating), spatial map only, and both factors. We also compare dynamic gates against the same gates frozen to their dataset-average values at inference, which is InterroGate's static choice.
Why not just…?
Why not just use a smaller untied multi-task model with the same parameter count? This is the most serious threat. If width and depth trade off cleanly, tying buys nothing. The parameter-matched untied baseline is in every comparison. If it matches our frontier, we report that tying with gate conditioning is not worth the extra compute, and the proposal fails on its central claim.
Why not just put per-task low-rank adapters on the tied weights? Relaxed Recursive Transformers show that adapters work for single-task text, so adapters may simply be enough. Our bet is narrower: specialization in dense multi-task vision is mostly about which features and locations to pass, and a gate expresses that far more cheaply than a weight update. The matched-budget and 4×-budget adapter comparisons settle this. If adapters win at matched budget, we would adopt a hybrid and say so.
Why not just scale channels per task, FiLM-style, without any spatial gate? Channel-only conditioning is simpler and close to what InterroGate already does. The dual-attention literature argues that it amplifies background, but that argument comes from single-task models. The channel-only ablation answers the question directly. The specific prediction is that the spatial factor's gain concentrates on boundary detection, the task ATRC finds least helped by sharing. If no gain appears there, the spatial factor should be dropped.
Why not keep gates but freeze them at inference, as InterroGate does? Freezing enables pruning, and pruning is a real efficiency win. The frozen-gate ablation measures what input dependence is worth. If the gap is negligible, static gates plus pruning are the better engineering choice.
Proposed Experiments
We train on NYUD-v2 with four tasks: segmentation (mIoU), depth (RMSE), surface normals (mean error), and boundaries (odsF). We also train on PASCAL-Context with five tasks, adding human parsing and saliency. We report per-task metrics and $\Delta_m$ against single-task models trained with the same backbone family. Each configuration uses three seeds, with total parameters, FLOPs, and measured throughput reported at batch sizes where the shared-weight fetch is the bottleneck. We additionally test the masked single-matrix gated layer from MGLU inside the tied block.
Three checks are decisive. First, the frontier check: at two or more parameter budgets, the gated tied model must sit above both the untied matched model and the matched-adapter tied model in $\Delta_m$. Second, the gate-swap check: running the depth stream with the segmentation stream's gates should sharply degrade depth while leaving the shared weights untouched. This would confirm that the gates, not the heads, carry the task identity. Third, the per-task attribution check: the spatial factor's contribution, measured by the channel-only versus full ablation, should be largest for boundaries and smallest for depth. If the gains appear uniformly instead, the "where" story is wrong even if the model works.
References
- TaskPrompter: Spatial-Channel Multi-Task Prompting for Dense Scene Understanding
- DeMT: Deformable Mixer Transformer for Multi-Task Learning of Dense Prediction
- InvPT: Inverted Pyramid Multi-task Transformer for Dense Scene Understanding
- InterroGate: Learning to Share, Specialize, and Prune Representations for Multi-task Learning
- Relaxed Recursive Transformers: Effective Parameter Sharing with Layer-wise LoRA
- Masked Gated Linear Unit
- Accessing Higher-level Representations in Sequential Transformers with Feedback Memory.
- ABD-Net: Attentive but Diverse Person Re-Identification
- Boundary-Aware Dual Attention Guided Liver Segment Segmentation Model
- Exploring Relational Context for Multi-Task Dense Prediction