Accordion: Elastic-Depth Inference via Fixed-Prefix Layer Looping
Summary (Overview)
- Accordion is a mixture-of-experts (MoE) Transformer that supports five inference budgets (Low, Medium, High, XHigh, Ultra) through fixed-prefix layer looping, using a single set of shared weights across all budgets.
- The architecture repeats a fixed prefix of layers 7–18 within a middle window, with zero-initialized residual gates controlling second-pass computations. The minimum budget (k=0) retains the unlooped model, avoiding the "one-loop tax" problem.
- After 3.6T tokens of pretraining, increasing inference depth improves the five-category macro-average across 37 tasks by 3.01 percentage points, with the middle budget (k=6) capturing 89% of this gain using half as many additional layer executions.
- The training pipeline extends elastic-depth inference through supervised fine-tuning (SFT) and reinforcement learning (RL), integrating three domain experts (instruction following, mathematics, code) via parameter-group merging and budget-matched multi-teacher on-policy distillation (MOPD).
- The final model (Accordion-RL) surpasses each domain expert on its corresponding task-and-budget average and outperforms four public reference models on IFEval at every inference budget.
Introduction and Theoretical Foundation
Background and Motivation
Large language models serve applications with diverse inference budgets, but training and maintaining separate models for each budget incurs substantial costs. Elastic inference aims to address this by supporting multiple compute choices within a single model. Existing approaches include:
- Nested architectures and subnetworks (Devvrit et al., 2023; Cai et al., 2024)
- Reduced execution depth (Fan et al., 2019; Schuster et al., 2022)
- Input-dependent computation allocation (Raposo et al., 2024; Bae et al., 2025)
Looped Transformers
Looped Transformers repeatedly apply shared parameters to increase effective depth. Key challenges include:
- The "one-loop tax" problem (Ladhak et al., 2026): jointly optimizing multiple inference depths can compromise shallow-path performance
- Maintaining elastic inference through the full training pipeline (pretraining, SFT, RL)
Key Theoretical Foundation
Accordion builds on layer looping from Loopie (Gao et al., 2026), which repeats selected Transformer layers consecutively rather than repeating an entire model. The architecture uses a fixed-prefix layer selection strategy, where each budget repeats a prefix of a middle window of layers.
Methodology
Architecture
Consider a pre-norm MoE transformer with physical layers and hidden dimension . Let be an ordered, contiguous middle window, and the budget menu. Budget repeats the prefix , with . Its path executes layer exactly:
times before moving to layer .
Configuration used: , ,
Training Objective
At each training micro-batch, a budget is sampled, and only path is executed. The next-token prediction loss is:
The full training objective includes a sequence-level MoE balancing term:
with .
Layer Looping Mechanism
For layer input , the first pass is:
If , the layer returns . Otherwise, it immediately applies a second pass:
The per-channel gates are zero-initialized and excluded from weight decay, making the second pass an identity map at initialization.
Computational Cost
For equal-shaped layers, FLOPs are approximately:
KV cache storage scales as relative to : at and at .
Design Studies (1.61B-parameter MoE)
Four key design choices were evaluated:
- Layer selection: Fixed prefix (7–18) outperforms fixed center, fixed suffix, and randomized strategies at all looped budgets
- Number of budgets: Five budgets outperform three or four at the same expected training computation
- Router sharing: Shared router achieves lowest mean loss (improvement of 0.0013 nats over separate routing)
- Budget-conditioned parameters: Budget-independent gates and norms achieve the lowest loss at every budget
Training Pipeline
| Stage | Tokens (B) | Cumulative | Context | Learning Rate |
|---|---|---|---|---|
| General | 3,000 | 3.00T | 8K | , constant |
| Mid-training | 150 | 3.15T | 8K | , constant |
| Annealing | 450 | 3.60T | 8K | |
| Context extension | 50 | 3.65T | 32K |
Model Configuration (Accordion-6B-A0.5B)
| Setting | Value |
|---|---|
| Layers / hidden size / Q / KV / head dim | 24 / 1536 / 12 / 4 / 128 |
| Routed / shared / active experts | 128 / 1 / 8 |
| Total / active parameters | 6.03B / 0.54B |
| Loopable window / budgets | 7–18 / {0, 3, 6, 9, 12} |
| Peak LR / final LR | / 10% of peak |
| AdamW β / weight decay | (0.9, 0.95) / 0.1 |
Reinforcement Learning Pipeline
Three domain experts are trained using GRPO/DAPO-style training, then combined via:
- Parameter-group merging (task arithmetic):
- Budget-matched multi-teacher on-policy distillation (MOPD): Each prompt's teacher is chosen by domain and evaluated at the same loop budget as the student
Empirical Validation / Results
Design Study Results
Table 1: Comparison of training-budget sets (validation loss in nats)
| Model | Training budgets | k=0 | k=6 | k=12 | Mean |
|---|---|---|---|---|---|
| Five-budget model | {0,3,6,9,12} | 2.5793 | 2.5703 | 2.5696 | 2.5744 |
| Three-budget model | {0,6,12} | 2.5810 | 2.5729 | 2.5721 | 2.5766 |
| Four-budget model | {0,4,8,12} | 2.5814 | - | 2.5719 | 2.5767 |
Table 3: Comparison of budget-conditioned parameters (validation loss in nats)
| Configuration | k=0 | k=3 | k=6 | k=9 | k=12 | Mean |
|---|---|---|---|---|---|---|
| Budget-independent gates and norms | 2.5793 | 2.5731 | 2.5703 | 2.5698 | 2.5696 | 2.5724 |
| Budget-conditioned gates | 2.5814 | 2.5761 | 2.5731 | 2.5723 | 2.5721 | 2.5750 |
| Budget-conditioned norm scales | 2.5830 | 2.5769 | 2.5735 | 2.5724 | 2.5722 | 2.5756 |
Specialist Comparison
Under equal training tokens (80B), Accordion achieves validation losses within 0.0030 nats of budget-specific specialists at all three evaluated budgets (k=0, 6, 12). Under equal training FLOPs, it improves on the FLOPs-matched specialist at k=12 by 0.0068 nats.
Base Model Results (37 Tasks)
Increasing budget from k=0 to k=12:
- Raises 37-task aggregate from 47.05 to 50.06 (+3.01 percentage points)
- Improves 36 of 37 task scores
- Middle budget (k=6) captures 89% of endpoint gain with ~21–24% increase in time per output token
Category averages (Figure 7):
- Largest gains in code, reasoning, and mathematics
- Ranks second in knowledge/QA and common sense at k=12
- Ranks first in code at k=9
Selected Benchmark Results (Accordion-Base vs. References)
| Benchmark | k=0 | k=6 | k=12 | Qwen3-0.6B | Qwen3-1.7B | OLMoE-0125 | Ouro-1.4B |
|---|---|---|---|---|---|---|---|
| MMLU | 58.2 | 60.9 | 60.9 | 52.5 | 62.7 | 55.2 | 67.5 |
| BBH | 54.8 | 60.0 | 60.8 | 40.8 | 53.3 | 32.6 | 70.8 |
| GSM8K | 53.1 | 59.4 | 61.3 | 59.2 | 71.3 | 51.1 | 78.6 |
| MATH (5,000) | 39.8 | 42.2 | 42.4 | 28.5 | 38.9 | 16.9 | 22.0 |
| HumanEval | 48.8 | 51.2 | 53.1 | 28.7 | 50.6 | 11.6 | 35.37 |
| MBPP | 46.6 | 50.2 | 51.8 | 39.0 | 55.6 | 21.0 | 58.0 |
Post-Training Results
Accordion-Instruct (SFT):
- Increasing budget improves 9 of 10 task scores
- Exceeds Qwen3-1.7B on HumanEval+ at k=12 (by 2.44 points), MBPP+ at k=6, and AIME 2025 at k=9
Accordion-RL (after RL and expert consolidation):
| Benchmark | k=0 | k=6 | k=12 | Qwen3-0.6B | Qwen3-1.7B |
|---|---|---|---|---|---|
| IFEval | 87.99 | 89.83 | 89.83 | 62.85 | 71.35 |
| MMLU-Redux | 70.98 | 74.13 | 74.77 | 57.69 | 74.84 |
| GSM8K | 84.15 | 88.63 | 89.16 | 79.45 | 90.14 |
| MATH500 | 83.80 | 88.60 | 89.80 | 72.80 | 89.20 |
| AIME 2024 | 34.58 | 40.83 | 45.21 | 12.08 | 44.58 |
| HumanEval+ | 79.88 | 86.59 | 84.15 | 46.34 | 79.27 |
Key findings:
- Exceeds all four public references on IFEval at every budget (margin ≥16.64 points over strongest reference)
- All 15 task–budget comparisons on IFEval, IFBench, and MMLU-Redux show higher scores after RL vs. SFT
- Exceeds each domain expert on its corresponding task-and-budget average (paired 95% intervals excluding zero)
Long-Context Results (RULER)
- At 4K context: +0.72 points from k=0 to k=12
- At 32K context: +5.47 points from k=0 to k=12
- At 16K, k=3 captures nearly all endpoint gain; at 32K, larger budgets unlock further gains through k=9
Mechanistic Analysis (Second Pass)
- Layer 9 retains only 1.52 of 8 routed experts on average between passes; most tokens share at most one expert
- Second-pass MoE writes are comparable in size to first-pass writes but nearly orthogonal to them
- Residual-stream cosines stay above 0.967 across the repeated window
- Removing adjacent repetitions together costs 15–33% of the summed individual effects (Hydra effect), while spaced triplets cost 96–103%
Theoretical and Practical Implications
Theoretical Implications
-
Fixed-prefix layer looping provides an effective mechanism for elastic-depth inference without the "one-loop tax," preserving unlooped path quality while enabling depth-dependent gains.
-
Uniform budget sampling during pretraining is sufficient—no cross-budget consistency objectives are needed, simplifying the training objective.
-
Shared parameters support distinct computations: The second pass performs input-dependent expert reselection and writes distinct residual updates, demonstrating that repeated layers do not simply duplicate first-pass computation.
-
Non-additive effects of repetition: The Hydra effect (joint removal costing less than sum of individual removals) for adjacent layers shows that depth benefits must be assessed on complete budget paths, not by summing individual layer contributions.
Practical Implications
-
One model, five inference budgets: Accordion provides flexible quality–cost trade-offs for diverse application needs, eliminating the need to train and maintain separate models.
-
Full-pipeline elastic inference: The approach extends through SFT and RL, making elastic depth practical for production deployment.
-
Public-data recipe at scale: The complete training pipeline uses publicly available datasets, enabling reproducibility and further research.
-
Task-specific operating points: Different tasks peak at different budgets (e.g., HumanEval at k=9, MBPP+ at k=12), allowing users to select the optimal budget per workload.
Conclusion
Accordion makes inference depth a selectable property of a single model through fixed-prefix layer looping. Key achievements:
- Five trained execution paths sharing one set of weights, with the minimum budget retaining the unlooped model
- Depth gains preserved through pretraining, SFT, and RL, with the base model obtaining most gains at the middle budget
- Budget-matched multi-teacher distillation combines three domain experts into a student exceeding each expert on its domain's task-and-budget average
- Strong instruction-following outperforming four public references on IFEval at every budget
- Mechanistic insights showing repeated layers reselect experts and write distinct updates, with prediction effects depending on neighboring repetitions
Future directions may include exploring alternative budget menus, extending to even larger scales, and investigating whether learned (rather than fixed) path selection can further improve the quality–cost frontier.
Related papers
- Aptamers as a sandbox for lab-in-the-loop agentic molecular discovery
Closed-loop LLM agents iteratively improved DNA aptamer hit rates from 0% to 42% across three wet-lab rounds, outperforming all 12 zero-shot computational predictors.
- When Agents Fail: Model or Harness—Who's to Blame?
Agent benchmark scores measure model-harness pairs jointly, not model capability alone; harness choice can reverse model rankings.
- Internalizing Chain-of-thought into Looped Transformers
Looped transformers can simulate Turing machines with both context window and chain-of-thought length reduced by a factor L, trading external tokens for internal recurrent computation.