Accordion: Elastic-Depth Inference via Fixed-Prefix Layer Looping
Organizations: Tsinghua University · Baidu Inc.
Abstract
Large language models serve applications with diverse inference budgets, but training and maintaining separate models for each budget incurs substantial costs. Recent Looped Transformers enable flexible inference computation through parameter reuse, but maintaining strong performance across different inference budgets remains an open challenge. We introduce Accordion, a mixture-of-experts-based model that supports five inference budgets through fixed-prefix layer looping. Each budget follows a pre-defined execution path, while the minimum budget retains the unlooped model. Joint pretraining samples one budget per micro-batch and optimizes its next-token prediction loss without additional cross-budget consistency objectives. We further preserve these inference budgets through supervised fine-tuning and reinforcement learning, where parameter-group merging and budget-matched multi-teacher on-policy distillation integrate three domain experts into one model. After 3.6T tokens of pretraining, increasing inference depth improves Accordion-6B-A0.5B's five-category macro-average across 37 tasks by 3.01 percentage points, with the middle budget capturing 89% of this gain using half as many additional layer executions. The final model surpasses each domain expert on its corresponding task-and-budget average, while achieving strong instruction-following performance across all budgets and retaining depth-dependent gains in mathematical reasoning and code generation.
Figures & tables
| Model | Training budgets | Mean | |||
| Five-budget model | 2.5793 | 2.5703 | 2.5696 | 2.5744 | |
| Three-budget model | 2.5810 | 2.5729 | 2.5721 | 2.5766 | |
| Four-budget model | 2.5814 | – | 2.5719 | 2.5767 |
| Routing | Mean | |||||
| Shared router | 2.5793 | 2.5731 | 2.5703 | 2.5698 | 2.5696 | 2.5724 |
| Separate router | 2.5814 | 2.5746 | 2.5715 | 2.5705 | 2.5702 | 2.5737 |
| Separate router + exclusion | 2.5823 | 2.5764 | 2.5718 | 2.5704 | 2.5694 | 2.5741 |
| Configuration | 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 |
| Stage | Tokens (B) | Cumulative | Context | Learning rate | Warmup / optimizer |
| General | 3,000 | 3.00T | 8K | , constant | 2,000 / initialize |
| Mid-training | 150 | 3.15T | 8K | , constant | 0 / continue |
| Annealing | 450 | 3.60T | 8K | 0 / continue | |
| Context extension | 50 | 3.65T | 32K | 200 / reset |
| Setting | Value |
| Layers / hidden size / Q / KV / head dim | 24 / 1536 / 12 / 4 / 128 |
| Routed / shared / active experts; intermediate size | 128 / 1 / 8; 384 |
| Total / active parameters; vocabulary | 6.03B / 0.54B; 128,000 |
| Loopable window / budgets | 7–18 / |
| Training tokens / context / tokens per step | 3.6T / 8K / 8.39M |
| Peak LR / final LR / schedule | / 10% of peak / WSD |
| Domain | Expert pool (prompts) | MOPD sample (prompts) | MOPD share |
| Mathematics | 181,405 | 19,200 | |
| Code | 21,679 | 19,200 | |
| Instruction following | 80,291 | 19,200 | |
| Total | 283,375 | 57,600 |
| Adjacent layers | Spaced layers | |||||||
| Removed layers | 7–9 | 10–12 | 13–15 | 16–18 | 7, 11, 15 | 8, 12, 16 | 9, 13, 17 | 10, 14, 18 |
| Sum of singles | 24.65 | 19.79 | 8.00 | 0.86 | 16.32 | 15.27 | 12.15 | 9.56 |
| Joint effect | 8.07 | 3.61 | 1.23 | 0.25 | 16.49 | 15.81 | 12.19 | 9.13 |
| Joint / sum | 0.33 | 0.18 | 0.15 | 0.29 | 1.01 | 1.03 | 1.00 | 0.96 |
Appendix figures & tables39 assets
Supplementary material from the paper’s appendix.
Appendix
| Source | Available (B tokens) | General 3,000B | Mid 150B | Anneal 450B | Expected used (B) | Expected repetitions |
| Nemotron-CC web, high quality (v2/v2.1) | 1,243 | 23% | 17% | 13% | 774 | 0.62 |
| Nemotron-CC web, medium quality (v2/v2.1) | 2,161 | 15.25% | 7% | 3% | 481.5 | 0.22 |
| Nemotron-CC synthetic rephrasings | 3,503 | 22% | 17% | 12% | 739.5 | 0.21 |
| Nemotron-CC Diverse-QA + HQ-DQA | 679 | 6.5% | 7% | 5% | 228 | 0.34 |
| Nemotron Specialized (RQA, STEM-SFT, InfiniByte) | 228 | 2.5% | 5% | 8% | 118.5 | 0.52 |
| Nemotron reasoning (Math-v2, Comp.-Prog., PrismMath) | 102 | 0% | 6% | 12% | 63 | 0.62 |
| Metric | Web | Synthetic web | Reasoning | Mathematics | Code |
| Long documents (B tokens) | 8 | 0 | 5 | 5 | 7 |
| Replay (B tokens) | 4 | 3 | 6.25 | 4.25 | 7.5 |
| Share (%) | 24 | 6 | 22.5 | 18.5 | 29 |
| Category | Tasks and prompting Scoring |
| Knowledge | MMLU ( Hendrycks et al., 2021a ) (5-shot) Multiple-choice accuracy TriviaQA ( Joshi et al., 2017 ) Natural Questions ( Kwiatkowski et al., 2019 ) (5-shot) Closed-book exact match |
| Common sense | ARC-C / ARC-E ( Clark et al., 2018 ) (25-/8-shot) CommonsenseQA ( Talmor et al., 2019 ) HellaSwag ( Zellers et al., 2019 ) (10-shot) WinoGrande ( Sakaguchi et al., 2019 ) (5-shot) OpenBookQA ( Mihaylov et al., 2018 ) BoolQ ( Clark et al., 2019 ) , PIQA ( Bisk et al., 2019 ) (0-shot) Task-specific harness scoring |
| Reasoning | BBH ( Suzgun et al., 2022 ) (3-shot CoT) Strict answer matching aggregate over subtasks |
| Mathematics | GSM8K ( Cobbe et al., 2021 ) (3-shot CoT) Flexible answer extraction Full MATH (4-shot) Mathematical-equivalence checking |
| Code | HumanEval ( Chen et al., 2021 ) / HumanEval+ ( Liu et al., 2023 ) (0-shot) MBPP ( Austin et al., 2021 ) / MBPP+ (3-shot) Greedy pass@1 CPU subprocess test execution |
| Summary | Tasks | Category scope |
| Core aggregate | 18 | Five: knowledge, common sense, reasoning, mathematics and code. |
| Secondary aggregate | 34 | Six: the core categories plus reading, with 16 additional tasks overall. |
| Full-table summary | 37 | Five display groups; knowledge and reading are combined under Knowledge and QA. Every displayed task is included. |
| Domain | Accordion-Base | ||||
| Web | 2.3059 | 2.2976 | 2.2935 | 2.2921 | 2.2919 |
| Math | 1.3505 | 1.3419 | 1.3379 | 1.3367 | 1.3366 |
| Code | 0.8693 | 0.8629 | 0.8596 | 0.8586 | 0.8584 |
| Setting | Value | Setting | Value |
| Sequences per domain | 1,400 | Expert parallelism degree | 1 |
| Tokens per sequence | 8,192 | Micro-batch / global batch (sequences) | 4 / 28 |
| Loss tokens per domain | 11,468,800 | Evaluation iterations | 50 |
| GPUs | 7 | Random seed | 1234 |
| Task | Gain | 95% CI | Task | Gain | 95% CI |
| MMLU | BoolQ | ||||
| TriviaQA | PIQA | ||||
| Natural Questions | BBH | ||||
| ARC-C | GSM8K | ||||
| ARC-E | Full MATH | ||||
| CommonsenseQA | HumanEval |
| Setting | Value |
| Layers / hidden size / Q / KV / head dim | 24 / 768 / 6 / 2 / 128 |
| Routed / shared / active experts; intermediate size | 128 / 1 / 8; 192 |
| Total / active parameters; vocabulary | 1.61B / 0.14B; 129,280 |
| Loopable window / budgets | 7–18 / |
| Training tokens / context / tokens per step | 80B / 8K / 2.1M |
| Peak LR / final LR / schedule | / 1% of peak / WSD |
| Accordion-Base-32K | Qwen3 | OLMoE | Ouro | ||||||
| Category | 0.6B | 1.7B | 0125 | 1.4B | |||||
| Knowledge and QA | 49.27 | 49.94 | 50.34 | 50.43 | 50.55 | 41.80 | 49.65 | 50.44 | 51.36 |
| Common sense | 65.28 | 66.18 | 66.61 | 66.56 | 66.62 | 57.00 | 65.33 | 66.60 | 67.67 |
| Reasoning | 39.13 | 40.60 | 42.30 | 42.43 | 42.57 | 33.90 | 43.37 | 31.20 | 48.23 |
| Mathematics | 40.25 | 41.83 | 43.40 | 43.85 | 43.66 | 42.41 | 53.18 | 30.53 | 50.30 |
| Code | 40.87 | 43.52 | 44.20 | 44.95 | 44.65 | 31.67 | 46.13 | 17.67 | 45.28 |
| Domain | |||||
| Web | 2.3007 | 2.2923 | 2.2883 | 2.2869 | 2.2867 |
| Math | 1.3436 | 1.3347 | 1.3308 | 1.3296 | 1.3295 |
| Code | 0.8681 | 0.8618 | 0.8586 | 0.8576 | 0.8574 |
| Context | [95% CI] | |||||
| 4K | 86.52 | 86.29 | 86.87 | 87.27 | 87.23 | |
| 8K | 78.15 | 79.18 | 79.44 | 79.97 | 79.95 | |
| 16K | 70.10 | 73.94 | 74.38 | 74.15 | 74.03 | |
| 32K | 49.49 | 51.80 | 54.58 | 54.90 | 54.95 |
| 4K context | |||||
| Task | |||||
| S1 | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 |
| S2 | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 |
| S3 | 97.20 | 93.20 | 95.00 | 95.40 | 95.40 |
| MK1 | 95.60 | 96.60 | 96.40 | 96.60 | 96.00 |
| MK2 | 99.40 | 99.80 | 100.00 | 100.00 | 100.00 |
| 16K context | |||||
| Task | |||||
| S1 | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 |
| S2 | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 |
| S3 | 97.80 | 97.80 | 97.40 | 97.60 | 97.80 |
| MK1 | 69.20 | 72.20 | 77.80 | 78.80 | 79.20 |
| MK2 | 86.80 | 91.60 | 93.80 | 92.80 | 93.20 |
| Edit / layer | 7 | 8 | 9 | 10 | 11 | 12 |
| Remove attention | 1.86 | 3.11 | 2.71 | 2.34 | 2.45 | 1.98 |
| Remove MoE | 5.32 | 10.23 | 6.73 | 3.03 | 7.80 | 5.62 |
| Remove both writes | 7.94 | 9.07 | 7.64 | 7.28 | 6.86 | 5.66 |
| Fix expert set | 0.57 | 3.23 | 6.08 | 0.08 | 1.93 | 0.21 |
| Fix set and weights | 1.03 | 4.08 | 5.95 | 0.21 | 2.13 | 0.26 |
| Attention, | 0.32 | 0.50 | 0.54 | 0.54 | 0.53 | 0.25 |
| Measurement | Base-32K | Instruct | RL |
| Baseline NLL | 1.5674 | 1.6974 | 1.7046 |
| Remove all writes | 13.38 [12.92, 13.87] | 9.66 [8.92, 10.41] | 7.22 [6.44, 7.97] |
| Remove all MoE | 38.23 [37.28, 39.18] | 43.04 [41.76, 44.30] | 47.20 [45.87, 48.53] |
| Remove all attention | 16.94 [16.38, 17.52] | 29.79 [28.82, 30.70] | 29.65 [28.68, 30.56] |
| Fix all expert sets | 12.58 [12.10, 13.06] | 17.98 [17.22, 18.71] | 19.56 [18.78, 20.33] |
| Removed layers | 16–18 | 13–15 | 10–12 | 7–9 | 7, 11, 15 |
| Joint effect | 0.25 | 1.23 | 3.61 | 8.07 | 16.49 |
| 95% interval | [0.18, 0.32] | [1.09, 1.37] | [3.37, 3.84] | [7.72, 8.46] | [15.98, 17.04] |
| Sum of singles | 0.86 | 8.00 | 19.79 | 24.65 | 16.32 |
| Joint / sum | 0.29 | 0.15 | 0.18 | 0.33 | 1.01 |
| Ratio 95% interval | [0.23, 0.36] | [0.14, 0.17] | [0.17, 0.19] | [0.32, 0.34] | [1.00, 1.03] |
| Removed layers | 7, 8 | 8, 9 | 8, 11 | 9, 10 | 9, 11 | 10, 11 | 12, 13 |
| Joint effect | 8.78 | 12.91 | 16.60 | 14.45 | 16.56 | 6.70 | 8.61 |
| 95% interval | [8.43, 9.16] | [12.45, 13.43] | [16.07, 17.18] | [13.97, 14.98] | [16.04, 17.13] | [6.40, 7.01] | [8.28, 8.93] |
| Sum of singles | 17.02 | 16.71 | 15.93 | 14.91 | 14.49 | 14.13 | 9.94 |
| Joint / sum | 0.52 | 0.77 | 1.04 | 0.97 | 1.14 | 0.47 | 0.87 |
| Ratio 95% interval | [0.50, 0.53] | [0.76, 0.79] | [1.03, 1.05] | [0.95, 0.98] | [1.13, 1.16] | [0.46, 0.49] | [0.85, 0.88] |
| Measurement | ||||
| Long / short gain | 1.15 | 1.29 | 1.44 | 1.44 |
| 95% interval | [0.97, 1.43] | [1.10, 1.57] | [1.23, 1.73] | [1.23, 1.73] |
| Metric | |||||
| Exact match (%) | 8.50 | 10.00 | 11.75 | 12.00 | 12.00 |
| Answer NLL change | 0.000 | -0.224 | -0.259 | -0.272 | -0.259 |
| Category | Dataset / retained subset | Single pass (B) | Epochs | Training (B) |
| Nemotron-SFT-Math-v3 | 18.098 | 1 | 18.098 | |
| OpenMathReasoning (CoT) | 23.592 | 1 | 23.592 | |
| Mathematics | OpenR1-Math-220k | 1.028 | 1 | 1.028 |
| Nemotron-SFT-Comp.-Prog.-v2 (Python) | 1.985 | 1 | 1.985 | |
| Nemotron-SFT-Comp.-Prog.-v2 (C++) | 2.014 | 1 | 2.014 | |
| AceReason-1.1-SFT (code) | 9.529 | 1 | 9.529 |
| Tasks | Maximum output tokens |
| GSM8K, IFEval, IFBench, MMLU-Redux | 8,192 |
| MATH500, HumanEval+, MBPP+ | 16,384 |
| AIME 2024, AIME 2025, LiveCodeBench | 30,000 |
| Task | 95% CI | ||||||
| Greedy (one response per problem) | |||||||
| GSM8K | 75.82 | 79.76 | 81.20 | 82.26 | 81.27 | ||
| MATH500 | 69.40 | 76.60 | 77.60 | 78.40 | 82.20 | ||
| HumanEval+ | 65.24 | 63.41 | 70.12 | 68.29 | 65.85 | ||
| MBPP+ | 60.05 | 62.17 | 66.40 | 66.14 | 66.67 | ||
| LiveCodeBench | 18.94 | 23.79 | 27.97 | 26.65 | 26.21 | ||
| Domain | Public dataset / subset | Prompts |
| Instruction following | Nemotron-Cascade-RL-Instruction-Following | 98,092 |
| Nemotron-RL-instruction_following | 45,079 | |
| Nemotron-RL instruction following (structured outputs) | 9,437 | |
| Mathematics | Nemotron-RL-math-OpenMathReasoning | 81,277 |
| OpenR1-Math-220k | 59,703 | |
| AceReason-Math | 46,280 |
| Expert | Selected step | Validation score (%) | Stopping step | Entropy at stopping | Entropy threshold |
| IF | 130 | 81.11 | 133 | 1.811 | 1.8 |
| Mathematics | 30 | 47.89 | 45 | 1.533 | 1.5 |
| Code | 32 | 70.85 | 35 | 1.527 | 1.5 |
| Quantity | Value or change |
| IF mean training reward, first 50 recorded steps | |
| Mathematics validation gain over initial evaluation (pp) | |
| Code validation gain over initial evaluation (pp) | |
| MOPD task reward, ten-step run | |
| MOPD token distillation loss, ten-step run | |
| Mathematics validation at step 40 (%) | 48.40 |
| Task | 95% CI | Task | 95% CI | ||
| GSM8K | HumanEval+ | – | |||
| MATH500 | MBPP+ | ||||
| AIME 2024 | – | LiveCodeBench | |||
| AIME 2025 | – | MMLU-Redux |
| Parameter group | Tensors | IF | Code | Math |
| Attention projections and attention normalization; shared MoE experts; loop gates; layer normalization, including the final norm | 289 | 1 | 0.5 | 0.5 |
| Routed expert projections; routers; embeddings; language-model head | 74 | 1 | 1 | 1 |
| Frozen balancing biases | 48 | Copied from SFT | ||
| Total | 411 | – | – | – |
| Variant | Instruction following | Code | Mathematics |
| IF + code | +1.76 [+0.35,+3.11] | +0.47 [−0.77,+1.62] | – |
| IF + math | +1.93 [+0.51,+3.28] | +2.03 [+0.83,+3.21] | −0.52 [−1.34,+0.32] |
| Code + math | −24.67 [−26.44,−22.91] | +1.97 [+0.85,+3.13] | −0.06 [−0.84,+0.69] |
| Unit weights | +1.85 [+0.47,+3.21] | +0.44 [−0.76,+1.66] | −4.92 [−5.95,−3.93] |
| Math 0.5 throughout | +2.69 [+1.31,+4.11] | +1.17 [+0.12,+2.27] | −2.24 [−3.03,−1.44] |
| Shared code/math 0.5 | +2.36 [+0.90,+3.79] | +1.78 [+0.64,+2.98] | −0.93 [−1.75,−0.10] |
| Comparison | Mean gain | 95% CI |
| Student versus IF expert, instruction following | ||
| Student versus mathematics expert, mathematics | ||
| Student versus code expert, code | ||
| Student versus grouped merge, mathematics |
| Setting | Value | Setting | Value |
| Training pool (prompts) | 57,600 | Warmup (training steps) | 10 |
| Prompts per rollout batch | 576 | Peak learning rate | |
| Responses per prompt | 8 | Student nodes | 36 |
| Responses per rollout batch | 4,608 | Additional teacher nodes | 4 |
| Max. prompt tokens | 2,048 | GPUs per node | 8 H800 |
| Max. response tokens | 28,672 | Teacher inference instances | 32 |
| Calculated model costs at 8K | |||||
| Layer executions | 24 | 27 | 30 | 33 | 36 |
| Rel. train FLOPs | 1.000 | 1.101 | 1.202 | 1.303 | 1.404 |
| KV/token (KiB) | 48 | 54 | 60 | 66 | 72 |
Efficient Language Model Inference
Efficient language model inference reduces the compute, memory, latency, and energy needed to generate useful outputs.
See all 321 papers