TL;DR
HACK++ is a training-free Key-Value (KV) cache compression framework designed specifically for Visual Autoregressive (VAR) models. By identifying a stable functional split between "contextual" and "structural" attention heads and decoupling immediate attention computation from long-term cache storage, HACK++ slashes memory footprints by over 2× and accelerates inference while maintaining near-lossless image generation quality.
What Problem Does This Paper Address?
Autoregressive (AR) models have taken the visual generation world by storm, but traditional next-token prediction models suffer from painfully long decoding chains. Visual Autoregressive (VAR) models fix this by shifting to a next-scale paradigm, generating images as a coarse-to-fine sequence of multi-scale token maps. While this allows for highly parallel decoding within each scale, it introduces a massive new bottleneck.
As generation progresses, vanilla VAR models indiscriminately cache the KV pairs of all historical scales. Because the sequence length grows cumulatively, the per-step attention computation becomes increasingly expensive ($O(n^4)$ complexity), and the KV cache rapidly inflates until it dominates memory consumption.
Existing KV cache compression methods built for Large Language Models (LLMs) fail here. LLMs cleanly separate a one-time prefilling stage from single-token decoding. VAR models, by contrast, interleave prefilling and decoding behaviors at every single scale. Simply applying LLM compression rules discards tokens that VAR attention critically depends on, leading to severe image degradation.
Methods
The authors introduce HACK++, a training-free, head-aware compression framework that operates in two stages:
- Offline Calibration: A one-time, near-free calibration step using just 50 samples. It calculates attention variance to classify attention heads into two categories and precomputes cross-scale attention priors.
- Online Inference: During image generation, HACK++ applies a Decoupled Attention and Cache Compression pipeline:
- Phase 1 (Pre-attention): Bounds immediate attention computation cost under an attention budget ($B_a$) by selecting a temporary subset of tokens.
- Phase 2 (Post-attention): Compresses the actual accumulated KV cache stored for future scales under a tighter cache budget ($B_c$), ensuring $B_c < B_a$ for maximum memory savings.
To select which tokens to keep, HACK++ uses Pattern-Specific Importance Estimation:
- Contextual Heads use a lightweight query-subset attention mechanism to approximate token importance online.
- Structural Heads bypass expensive online attention matrices entirely, using a cheap combination of precomputed offline scale priors and online value norms.
Finally, a Reliance-Aware Adaptive Cache Budget Allocation dynamically shifts the cache budget across head types, layers, and generation steps based on how heavily future steps are expected to rely on that specific history.
Datasets
The framework was validated across seven different VAR-family models spanning three distinct tasks:
- Text-to-Image Generation: Evaluated on MJHQ-30K, HPSv2.1, and ImageReward.
- Class-Conditional Generation: Evaluated on ImageNet-1K.
- Unified Understanding-and-Generation: Evaluated on GenEval and DPG-Bench.
Key Insights and Ideas
- The Contextual vs. Structural Dichotomy: The authors discovered that VAR attention heads naturally and stably split into two types. Contextual Heads exhibit a vertical attention pattern, focusing on semantic consistency regardless of query position. Structural Heads exhibit a multi-diagonal pattern, mapping query-dependent spatial configurations across scales to maintain geometric coherence.
- Asymmetric Failure Modes: Head-masking experiments revealed that disabling contextual heads destroys semantic grounding (e.g., missing objects from prompts), while disabling structural heads causes severe geometric deformation and texture inconsistency.
- Decoupling Attention from Cache: Immediate attention computation and future cache storage serve entirely different purposes. The authors observed a massive "redundancy gap" where cached historical tokens occupy a huge fraction of the attention input but receive very little actual attention mass at later scales. Treating them separately allows for much more aggressive cache eviction.
Key Results
- Near-Lossless Compression: On the Infinity-2B and 8B models, HACK++ maintained near-lossless image generation quality using only a 30% attention budget and a 10% cache budget. It remained remarkably robust even under an extreme 1% cache budget.
- Resource Efficiency: For Infinity-8B, HACK++ reduced the memory footprint by 2.04× (dropping from 59.00 GB to 28.89 GB) and accelerated inference throughput by 1.52×.
- Enhanced Batching: By shrinking the KV cache footprint, HACK++ allows models to scale to much larger batch sizes. When combined with FlashAttention, vanilla Infinity-8B (which normally out-of-memories past a batch size of 4) successfully scaled to a batch size of 18, yielding a 2.76× throughput gain.
Limitations and Future Work
While highly effective, the authors note that their current head taxonomy is binary (contextual vs. structural). A finer-grained taxonomy based on nuanced historical scale reliance could unlock even higher compression ratios. Additionally, they suggest that the clear separation of semantic and spatial control in early scales opens up exciting future avenues for controllable generation and image editing, allowing users to selectively manipulate specific head types to steer content or layout.
Summary updated