Accordion-6B-A0.5B-SFT
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 SFT model: Base-32K fine-tuned for 8,614 steps on reasoning-style conversations (thinking traces rendered as <think>…</think>), at 32K context with the five budgets mixed.
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-SFT"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, dtype=torch.bfloat16).cuda().eval()
messages = [{"role": "user", "content": "Solve the following math problem. Make sure to put the answer "
"(and only answer) inside \\boxed{}.\n\nWhat is the sum of the first 10 positive odd numbers?"}]
ids = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)["input_ids"].cuda()
out = model.loop_generate(ids, max_new_tokens=4096, loop_k=12, do_sample=True, temperature=0.6, top_p=0.95,
stop_token_ids=(tok.eos_token_id,))
print(tok.decode(out[0], skip_special_tokens=True)) # "<think>\n...\n</think>\n\n... \boxed{100}"
Prompt format. There are no role tokens. The chat template renders
<|end▁of▁sentence|> + user text + "\n\n"; the model answers with <think>\n…\n</think>\n\n followed by
the final answer and ends the turn with <|end▁of▁sentence|>. A system message is rendered like a user turn,
and earlier assistant turns are appended verbatim, each followed by <|end▁of▁sentence|>. Our evaluations used
temperature 0.6 / top-p 0.95 and 8K–30K new tokens. Reasoning can be long, so allow a generous max_new_tokens.
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-SFT --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. Chat-format evaluation with vLLM (bf16), temperature 0.6, top-p 0.95, one sample per problem (16 for AIME); answers are taken after </think>.
| $k$=0 | 3 | 6 | 9 | 12 | |
|---|---|---|---|---|---|
| Layer executions | 24 | 27 | 30 | 33 | 36 |
| GSM8K | 83.40 | 85.67 | 88.78 | 87.72 | 88.63 |
| MATH500 | 83.40 | 84.80 | 87.40 | 86.80 | 89.20 |
| AIME24 (avg@16) | 30.00 | 34.79 | 39.58 | 43.54 | 43.75 |
| AIME25 (avg@16) | 26.88 | 28.96 | 32.92 | 36.88 | 31.88 |
| HumanEval+ | 79.88 | 78.05 | 79.27 | 79.88 | 81.71 |
| MBPP+ | 69.58 | 67.72 | 73.02 | 70.90 | 72.75 |
| LiveCodeBench (454) | 26.65 | 31.94 | 34.58 | 36.34 | 37.89 |
| IFEval (prompt, strict) | 62.11 | 64.88 | 65.99 | 63.40 | 60.07 |
| IFBench | 17.33 | 20.33 | 20.33 | 19.33 | 23.00 |
| MMLU-Redux | 60.88 | 63.47 | 65.82 | 66.17 | 65.16 |
Few-shot base-style benchmarks no longer improve with $k$ after SFT (five-cluster average 49.22 / 48.71 / 48.27 at $k$ = 0 / 6 / 12); the chat-style evaluations above do.
Single training run, single seed; paired-bootstrap intervals are in the paper. Scripts to reproduce this table are in Accordion-Loop (eval/chat).
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},
}