Accordion-6B-A0.5B-Base-32K
Paper · Project page · Code · All models

Accordion is a 24-layer Mixture-of-Experts language model (≈6.0B total parameters, ≈0.54B active non-embedding parameters per token) trained so that one set of weights serves five inference compute budgets. During training, each micro-batch samples $k \in {0, 3, 6, 9, 12}$ and the first $k$ layers of the middle window (layers 7–18) each run a second time in place (layer looping: each layer has its own self-loop; the second pass is scaled by a zero-initialised per-channel $\tanh(g)$ gate and reuses the same router, with a separate expert-selection bias). At inference you pick $k$, i.e. 24 to 36 layer executions per token, with no change to the weights. This differs from whole-model recurrence (e.g. Ouro), which repeats the entire layer stack.
This is the 32K base model: Base-8K followed by 50B tokens (5,960 steps) of long-context training at 32K. It is the starting point of the SFT model.
Model family
| Model | Stage | Context |
|---|---|---|
| Accordion-6B-A0.5B-Base-8K | pre-training 3T + mid-training 0.15T + annealing 0.45T tokens | 8K |
| Accordion-6B-A0.5B-Base-32K | Base-8K + 50B tokens of 32K long-context training | 32K |
| Accordion-6B-A0.5B-SFT | Base-32K + supervised fine-tuning (reasoning traces) | 32K |
| Accordion-6B-A0.5B-RL | SFT + RL (IF / math / code experts → grouped merge → 10 steps of multi-teacher on-policy distillation) | 32K |
All four keep the five budgets: training and RL always mix $k \in {0,3,6,9,12}$.
Architecture
| Layers | 24 (layers 7–18 loopable) |
| Hidden size | 1536 |
| Attention | GQA, 12 query / 4 KV heads, head dim 128, QK-RMSNorm, RoPE θ = 500,000 |
| MoE | 128 routed experts, top-8 (sigmoid scores, aux-loss-free bias for selection) + 1 shared expert, expert FFN 384 |
| Vocabulary | 128,000 (DeepSeek-V3 tokenizer) |
| Budgets | $k$ ∈ {0, 3, 6, 9, 12} (Low / Medium / High / XHigh / Ultra) → 24 / 27 / 30 / 33 / 36 layer executions |
| Weights | bf16; expert_bias* buffers kept in fp32 |
Each layer execution keeps its own KV cache, so the KV cache grows with $k$ (×1.5 at $k$=12).
Usage
The modeling code ships with the checkpoint (trust_remote_code=True). Tested with transformers 4.57.1 and
5.17.0, torch 2.14. The budget is chosen per call with loop_k (default: config.loop_k = 0).
Generation uses the model's own
loop_generate(greedy or nucleus sampling, left-padded batches).model.generate()is not supported, because every layer execution needs its own KV-cache slot.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "btzyd/Accordion-6B-A0.5B-Base-32K"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, dtype=torch.bfloat16).cuda().eval()
ids = [tok.eos_token_id] + tok("The capital of France is", add_special_tokens=False)["input_ids"]
x = torch.tensor([ids], device="cuda")
for k in (0, 6, 12): # 24 / 30 / 36 layer executions
out = model.loop_generate(x, max_new_tokens=32, loop_k=k, stop_token_ids=(tok.eos_token_id,))
print(k, tok.decode(out[0], skip_special_tokens=True))
# log-likelihood at a given budget
loss = model(x, labels=x, loop_k=12).loss
vLLM. The accordion-vllm plugin serves this model with one budget per engine, set by LOOPMOE_K:
pip install vllm==0.24.0 "git+https://github.com/btzyd/Accordion-Loop#subdirectory=vllm_plugin"
LOOPMOE_K=12 vllm serve btzyd/Accordion-6B-A0.5B-Base-32K --trust-remote-code --dtype bfloat16 --max-model-len 32768
Notes:
- The tokenizer has only three special tokens:
<|begin▁of▁sentence|>(0, never seen in training — do not add it),<|end▁of▁sentence|>(1, document separator / end of turn) and<|▁pad▁|>(2). Every document in training was preceded by token 1, so prefix inputs with it, as the examples do. - Budgets other than the five trained ones (e.g. $k$=5, or looping an arbitrary set of layers via
loop_layers_active) run, but were never trained and are generally worse.
Evaluation
Same weights, five budgets. Few-shot base-model suite (lm-evaluation-harness, our HF backend). The five-cluster average is the mean over the knowledge, commonsense, reasoning, math and code clusters (MMLU, TriviaQA, NQ · ARC-C/E, CSQA, HellaSwag, WinoGrande, OBQA, BoolQ, PIQA · BBH · GSM8K, MATH · HumanEval(+), MBPP(+)).
| $k$=0 | 3 | 6 | 9 | 12 | |
|---|---|---|---|---|---|
| Layer executions | 24 | 27 | 30 | 33 | 36 |
| Five-cluster average | 52.01 | 54.16 | 55.26 | 55.81 | 55.76 |
| MMLU | 58.39 | 60.34 | 61.06 | 61.25 | 61.40 |
| MMLU-Pro | 31.80 | 34.88 | 35.38 | 36.03 | 35.97 |
| BBH (CoT, 3-shot) | 54.81 | 58.16 | 60.96 | 61.34 | 61.25 |
| GSM8K (CoT) | 55.50 | 59.97 | 61.49 | 62.55 | 62.77 |
| MATH | 39.70 | 39.92 | 41.10 | 42.32 | 42.32 |
| HumanEval+ | 35.98 | 39.02 | 39.63 | 40.24 | 39.63 |
| MBPP+ | 62.96 | 64.81 | 66.40 | 66.93 | 67.20 |
| RULER 4K | 86.52 | 86.29 | 86.87 | 87.27 | 87.23 |
| RULER 8K | 78.15 | 79.18 | 79.44 | 79.97 | 79.95 |
| RULER 16K | 70.10 | 73.94 | 74.38 | 74.15 | 74.03 |
| RULER 32K | 49.49 | 51.80 | 54.58 | 54.90 | 54.95 |
RULER is the mean of 13 tasks. HumanEval is lower than in Base-8K because the model more often appends a closing code fence that breaks the completion; it is scored as-is.
Single training run, single seed; 95% paired-bootstrap intervals for the $k$=12 − $k$=0 differences are in the paper. Scripts to reproduce this table are in Accordion-Loop (eval/base, eval/ruler).
Limitations
- A research model at small scale (0.5B active parameters); it is not safety-tuned and can produce wrong, biased or harmful text.
- Mostly English, with some code and math; other languages were not a training target.
- Only the HF reference implementation and the vLLM plugin in Accordion-Loop support layer looping; standard inference engines will not load this architecture.
Citation
@misc{zhang2026accordionelasticdepthinferencefixedprefix,
title={Accordion: Elastic-Depth Inference via Fixed-Prefix Layer Looping},
author={Yudong Zhang and Wei Ding and Kaili Zheng and Yuchen Ding and Zhenyu Zhang},
year={2026},
eprint={2610.32492},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2610.32492},
}