Accordion-6B-A0.5B-RL
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 RL model (final). Starting from the SFT model, three domain experts (instruction following, math, code) were trained with RL (verl, all five budgets mixed in every batch), merged by parameter-group task arithmetic, and refined with 10 steps of multi-teacher on-policy distillation from the three experts. Weights are the bf16 cast of the fp32 master weights; this is the same bf16 model that was evaluated with vLLM.
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-RL"
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-RL --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 | 84.15 | 87.34 | 88.63 | 89.54 | 89.16 |
| MATH500 | 83.80 | 84.80 | 88.60 | 89.60 | 89.80 |
| AIME24 (avg@16) | 34.58 | 39.79 | 40.83 | 45.21 | 45.21 |
| AIME25 (avg@16) | 27.92 | 32.71 | 36.88 | 35.83 | 36.67 |
| HumanEval+ | 79.88 | 78.05 | 86.59 | 82.93 | 84.15 |
| MBPP+ | 69.58 | 71.43 | 71.43 | 72.49 | 73.81 |
| LiveCodeBench (454) | 28.63 | 29.74 | 39.87 | 37.89 | 35.24 |
| IFEval (prompt, strict) | 87.99 | 88.91 | 89.83 | 89.83 | 89.83 |
| IFBench | 48.33 | 50.67 | 50.67 | 52.67 | 46.67 |
| MMLU-Redux | 70.98 | 73.68 | 74.13 | 75.18 | 74.77 |
Compared with the SFT model the largest gains are in instruction following (IFEval +24 to +30, IFBench +24 to +33 points) and MMLU-Redux (+8 to +10); math and code change by a few points.
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},
}