ScanAR: 13.8x Faster Parallel Row-Scan Autoregressive Decoding

ScanAR (arXiv:2611.33761, Xiaomi Robotics) accelerates unified multimodal autoregressive image generation from HW sequential steps down to H+W steps without adding parameters or changing the tokenizer. On Emu3.5-Image-34B, ScanAR cuts 512x512 generation latency from 64.60s to 4.69s (13.8x speedup) while scoring 82.36 on GenEval.
ScanAR: 13.8x Faster Parallel Row-Scan Autoregressive Decoding: ScanAR (arXiv:2611.33761, Xiaomi Robotics) accelerates unified multimodal autoregressive image generation from HW sequential steps down to H+W steps without adding parameters or changing the tokenizer. On Emu3.5-Image-34B, ScanAR cuts 512x512 generation latency from 64.60s to 4.69s (13.8x speedup) while scoring 82.36 on GenEval. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- 13.8x Latency Reduction on 34B Models: Drops Emu3.5-Image-34B 512x512 latency from 64.60s (1,024 steps) down to 4.69s (64 steps).
- Zero Extra Parameters or Tokenizer Edits: Preserves raster grid ordering, unified text/image interleaved output, and standard next-token prediction heads.
- Higher Quality Than Raster Baseline: Reaches 82.36 GenEval after 20K post-training steps vs 80.48 baseline, 80.29 FlashAR, and 73.83 BlockDiffusion.
- Embodied & Video Transfer: Speeds up 34B Xiaomi-Robotics-U0 embodied scene generation 11.1x (57.3s to 5.2s) while boosting valid completions from 81.3% to 91.3%.
import { createAgent } from '@smoke-monkey/harness';const multimodalAgent = createAgent({agentId: 'scanar-unified-vision-agent',provider: 'custom',baseUrl: 'http://localhost:8000/v1',model: 'emu3.5-image-34b-scanar',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},sampling: {temperature: 0.0,extra_body: {decoding_mode: 'row_scan_parallel',grid_shape: [32, 32],attention_kernel: 'flex_attention',preserve_kv_prefix: true,},},});async function runEmbodiedPlan() {const res = await multimodalAgent.run('Generate interleaved subtask text and 512x512 embodied kitchen manipulation keyframes via ScanAR.');console.log('ScanAR Output:', res.summary);}runEmbodiedPlan().catch(console.error);
Watch: Related Video Guides
The KV Cache: Memory Usage in Transformers
How KV Cache Speeds Up LLMs for Faster AI Models on GPUs
What Is ScanAR? Cutting Visual Decoding Depth from HW to H+W
ScanAR (arXiv:2611.33761, Xiaomi Robotics) is a parallel visual decoding method for unified multimodal autoregressive (AR) models that generate text, actions, and images in one shared token sequence. Standard raster AR decodes an $H \times W$ grid token-by-token in $HW$ sequential forward passes (e.g., 1,024 steps for a $32 \times 32$ latent grid), saturating memory bandwidth during serving.
Unlike prior acceleration schemes such as VAR, PAR, or RandAR that replace the VQ tokenizer, alter the output head, or break interleaved text-image generation, ScanAR only redefines the predecessor mapping and attention visibility mask of visual tokens:
- Row 0 ($i = 0$): Decoded left-to-right sequentially ($W$ steps) to anchor global scene layout.
- Rows $i > 0$: Every token $(i, j)$ in row $i$ is predicted in a single parallel forward pass at step $s(i, j) = W + i - 1$ directly from the vertically aligned hidden state $\bar{h}_{i-1, j}$ of the row above.
Inside the attention mask $\mathcal{V}(q)$, tokens in row $R_i$ attend causally to all prefix tokens prior to $R_i$ and bidirectionally within $R_i$, leaving all nonvisual text tokens under standard causal rules.
FlexAttention Sparse Masking & Distillation Loss
Materializing a dense 4D attention mask for ScanAR across 8K context lengths triggers Out-Of-Memory (OOM) errors on 96+ GB GPUs (105.6 GB at 4K). ScanAR replaces dense masks with PyTorch FlexAttention, matching standard causal AR memory and step latency cleanly:
| Sequence Length | Attention Method | Training Step Time (s) | Peak Memory (GB) |
|---|---|---|---|
| 4K | Causal AR Baseline | 10.1 s | 91.9 GB |
| 4K | ScanAR Dense 4-D Mask | 16.2 s | 105.6 GB |
| 4K | ScanAR + FlexAttention | 10.5 s | 94.5 GB |
| 8K | Causal AR Baseline | 20.2 s | 91.9 GB |
| 8K | ScanAR Dense 4-D Mask | — | OOM |
| 8K | ScanAR + FlexAttention | 21.3 s | 94.2 GB |
During lightweight post-training (20K steps on 80M tokens), ScanAR combines cross-entropy visual loss $\mathcal{L}_{\text{vis}}$ with temperature-scaled KL distillation from the original raster teacher.
Emu3.5-34B, LlamaGen & Xiaomi-Robotics-U0 Empirical Benchmarks
Across unified 34B models and ImageNet class-conditional backbones, ScanAR delivers unmatched latency-quality scaling:
| Model / Benchmark | Method | Decoding Steps | Latency / Throughput | Quality Metric |
|---|---|---|---|---|
| Emu3.5-Image-34B | Raster AR Baseline | 1,024 | 64.60 s / img | 80.48 GenEval |
| Emu3.5-Image-34B | BlockDiffusion | 64 | 6.17 s / img | 73.83 GenEval |
| Emu3.5-Image-34B | FlashAR | 63 | 5.68 s / img | 80.29 GenEval |
| Emu3.5-Image-34B | ScanAR (Post-Train) | 64 | 4.69 s / img (13.8x) | 82.36 GenEval |
| Xiaomi-Robotics-U0 (34B) | Raster U0-Seq | — | 57.3 s / img | 81.3% Valid Output |
| Xiaomi-Robotics-U0 (34B) | ScanAR | — | 5.2 s / img (11.1x) | 91.3% Valid Output |
| LlamaGen-B (~120M) | Raster Baseline | 256 | 117.9 img/s | 5.46 FID / 193.6 IS |
| LlamaGen-B (~120M) | ScanAR (Scratch) | 32 | 669.4 img/s (5.7x) | 5.59 FID / 244.3 IS |
At batch serving on Emu3.5-Image-34B, ScanAR also reduced peak memory from 138.8 GB (FlashAR) to 110.7 GB while raising throughput to 0.87 img/s.
# Verify PyTorch FlexAttention support before post-training ScanAR
python3 -c "import torch; from torch.nn.attention.flex_attention import flex_attention; print('PyTorch:', torch.__version__, 'FlexAttention ready')"Reuse Standard Serving KV Caches
Because Row 0 and preceding text tokens remain causal and every subsequent row R_i appends strictly after earlier rows, standard prefix-cached vLLM or SGLang KV blocks work without architectural rewrites.
Frequently Asked Questions
Q:How much faster is ScanAR than standard raster decoding on Emu3.5-Image-34B?
ScanAR reduces 512x512 image generation latency on Emu3.5-Image-34B from 64.60 seconds (1,024 steps) to 4.69 seconds (64 steps)—a 13.8x speedup—while improving GenEval from 80.48 to 82.36.
Q:Does ScanAR require changing the VQ tokenizer or adding new model parameters?
No. ScanAR adds zero parameters and keeps the exact same backbone, vocabulary, tokenizer, and prediction head, modifying only the attention visibility mask and vertical row-predecessor alignment.
Q:Why does ScanAR use FlexAttention instead of a dense 4D mask during training?
A dense 4D attention mask exceeds GPU memory (OOM) at 8K sequence lengths and adds 60% step-time overhead at 4K. FlexAttention keeps 8K peak memory at 94.2 GB and matches causal AR training speed.
Q:Does ScanAR break interleaved text-and-image generation in robotics models?
No. Tested on the 34B Xiaomi-Robotics-U0 embodied model, ScanAR preserves interleaved output, speeds generation by 11.1x (57.3s to 5.2s), and increases valid finished outputs from 81.3% to 91.3%.
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.