Fudan's HARoPE Fixes AI Image Generation's Broken Spatial Reasoning
A new drop-in positional encoding called HARoPE uses per-head SVD transforms to fix RoPE's weakness at spatial layout, color, and counting in image generation.
ProTakeaways
- HARoPE is a head-wise adaptive extension of Rotary Position Embedding aimed at fine-grained image generation.
- It inserts a learnable SVD-parameterized linear transform before RoPE's rotation, preserving relative-offset attention.
- Each attention head gets its own transform, enabling specialized positional receptive fields and cross-axis mixing.
- On DiT-B/2 ImageNet, FID-50K drops from 9.49 (RoPE) to 8.90; Inception Score rises to 127.01.
- On FLUX.1-dev, GenEval overall improves from 0.757 to 0.771 at 1024px, with bigger gains on spatial tasks.
- Code is released at github.com/Studentxll/HARoPE; adds only about 3 percent parameters and FLOPs.
Rotary Position Embedding, or RoPE, has become the default way to inject positional information into transformers for large language models. But when you push it into image generation, it starts to crack in ways you can actually see in the output: objects end up on the wrong side of each other, colors leak onto the wrong subject, and prompts asking for exactly five apples produce four or six. A team from Fudan University, Alibaba, and Baidu is proposing a fix called HARoPE, a head-wise adaptive variant that plugs into existing diffusion transformers with a tiny parameter bump and measurably tightens compositional accuracy.
Where vanilla RoPE breaks on pixels
RoPE works by rotating pairs of query and key features by an angle tied to their position, so attention scores end up depending only on the relative offset between tokens. That's elegant in 1D text. In 2D images, the standard extension just splits the feature dimensions in half, uses one block for the x-axis and one for the y-axis, and reuses the same frequency spectrum on each. The paper identifies three problems with this: rigid frequency allocation across axes, block-diagonal structures that enforce axis-wise independence and suppress diagonal or rotational couplings, and a single shared positional mapping applied identically to every attention head.
The visible symptoms are the fine-grained failures shown in prompt benchmarks: spatial relations, color-aware cues, and exact object counts. Different heads in a transformer are known to specialize at different receptive field sizes, but standard RoPE gives all of them the same positional lens.

An SVD sandwich around the rotation
HARoPE's idea is small and surgical. For each attention head, it inserts a learnable linear transformation A immediately before the rotary map, parameterized as a singular value decomposition A = U Σ V⊤, where U and V are orthogonal and Σ is diagonal with positive entries. Queries get multiplied by A⊤ and keys by A⁻¹ before the usual RoPE rotation is applied.
Each factor plays a distinct role:
- V rotates the feature space so the rotary planes line up with directions the model has actually learned to care about, instead of the fixed coordinate pairs (q₀,q₁), (q₂,q₃), and so on.
- Σ reweights how much positional capacity each of those directions gets, effectively reallocating frequency budget.
- U maps the positionally enriched signal back into the model's native basis.
Because the same A is applied to queries and keys, the math still collapses to a function of the position offset n−m, so RoPE's strict relative-offset property is preserved. Giving each head its own A is what unlocks per-head specialization. The transform is initialized to the identity so a pretrained model starts from the exact RoPE baseline, and singular values are kept near one via softplus to avoid exploding or vanishing norms.

Numbers on ImageNet, Flux, and SD3
The authors evaluated HARoPE across image understanding, class-conditional generation, and text-to-image, comparing to absolute position embeddings, axial and mixed 2D-RoPE, VideoRoPE, and STRING/Rethinking RoPE. On class-conditional ImageNet with DiT-B/2 at 1M steps, HARoPE hits FID-50K of 8.90 and Inception Score of 127.01, beating vanilla RoPE at 9.81 and the strongest prior extension at 9.31.
The text-to-image results are more interesting because that's where compositional prompts actually get stressed. On FLUX.1-dev at 1024x1024, HARoPE lifts the GenEval overall score from 0.757 to 0.771 and DPGBench from 83.26 to 83.77. The gap grows on layout-heavy tasks: on T2I-CompBench, HARoPE consistently outperforms RoPE in spatial dimensions such as 2D-Spatial (0.307 to 0.337 at 1024px) and 3D-Spatial, and at 2048px it boosts the Position score from 0.370 to 0.455 and the Attribute score from 0.623 to 0.660. Swapping RoPE for HARoPE in SD3-medium also drops FID on MS-COCO from 5.35 to 5.22.
An ablation rules out the obvious critique that the wins come from extra parameters. A parameter-matched RoPE+SVD baseline that inserts identical SVD layers post-projection but without per-head specialization gives negligible improvement over vanilla RoPE and even degrades some GenEval metrics at 2048px, while HARoPE keeps its lead. The overhead is modest: about a 2.7 to 4.1 percent bump in parameters and FLOPs versus RoPE.
What this is and isn't good for
HARoPE is designed as a drop-in replacement for existing multidimensional RoPE, and the code is available on GitHub. It's most useful when you're training or fine-tuning a diffusion transformer and care about compositional accuracy at higher resolutions, where the frequency-allocation problems in standard 2D RoPE get worse. The FLUX experiments in the paper were done as LoRA fine-tunes at rank 32 for 4,000 iterations, which is a realistic budget for teams adapting an open model.
The limitations are worth naming. Evaluation is confined to the image domain, and generalization to video, audio, or 3D remains empirically unvalidated. The transformation matrices are also static after training rather than input-conditional, so a prompt that needs a very different spatial prior than the training distribution won't get one on the fly. And in a handful of T2I-CompBench columns at 512px, plain RoPE still edges HARoPE out, so this isn't a strict monotone improvement, it's a bias toward better structural reasoning that shows up most clearly as resolution and prompt complexity scale up.