Architecture
~9 min readUpdated: November 2026

ScanAR: 13.8x Faster Parallel Row-Scan Autoregressive Decoding

ScanAR Parallel Row-Scan Autoregressive Visual Decoding Architecture

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.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

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.

Key Architectural Takeaways
Quick Implementation Examplescanar-inference-controller.ts
scanar-inference-controller.tstypescript
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);
Video Guides

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 LengthAttention MethodTraining Step Time (s)Peak Memory (GB)
4KCausal AR Baseline10.1 s91.9 GB
4KScanAR Dense 4-D Mask16.2 s105.6 GB
4KScanAR + FlexAttention10.5 s94.5 GB
8KCausal AR Baseline20.2 s91.9 GB
8KScanAR Dense 4-D Mask—OOM
8KScanAR + FlexAttention21.3 s94.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 / BenchmarkMethodDecoding StepsLatency / ThroughputQuality Metric
Emu3.5-Image-34BRaster AR Baseline1,02464.60 s / img80.48 GenEval
Emu3.5-Image-34BBlockDiffusion646.17 s / img73.83 GenEval
Emu3.5-Image-34BFlashAR635.68 s / img80.29 GenEval
Emu3.5-Image-34BScanAR (Post-Train)644.69 s / img (13.8x)82.36 GenEval
Xiaomi-Robotics-U0 (34B)Raster U0-Seq—57.3 s / img81.3% Valid Output
Xiaomi-Robotics-U0 (34B)ScanAR—5.2 s / img (11.1x)91.3% Valid Output
LlamaGen-B (~120M)Raster Baseline256117.9 img/s5.46 FID / 193.6 IS
LlamaGen-B (~120M)ScanAR (Scratch)32669.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.

bash
# 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.

Google Search Questions & Answers

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 guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness