---
title: 'FreeLOC: Training-Free Long Video Generation'
url: https://www.emergentmind.com/topics/freeloc
type: topic
---

# FreeLOC: Training-Free Long Video Generation

Searching arXiv for FreeLOC and closely related long-video generation work.
FreeLOC, introduced in "Free-Lunch Long Video Generation via Layer-Adaptive O.O.D Correction" [2603.25209], is a training-free inference framework for extending pre-trained short-video diffusion transformers to substantially longer video generation without retraining. Its central thesis is that long-video degradation in short-video video DiTs arises from two distinct out-of-distribution effects: frame-level relative position O.O.D., caused by temporal relative positions moving beyond the pretrained RoPE regime, and context-length O.O.D., caused by attention operating over far more tokens than the model was trained to handle. FreeLOC addresses these with Video-based Relative Position Re-encoding (VRPR), Tiered Sparse Attention (TSA), and an offline layer-adaptive probing procedure that determines where each correction should be applied [2603.25209].

## 1. Problem formulation and architectural scope

FreeLOC is designed for transformer-based video diffusion models that were trained on short clips, such as Wan2.1-T2V-1.3B and HunyuanVideo, and are then asked to generate much longer videos at inference time [2603.25209]. It is not a new generative model and does not require finetuning; rather, it is a plug-in, inference-time modification of self-attention and positional handling inside existing video DiTs.

The baseline attention form used in the paper is

$$
\text{Attention}(\mathbf{Q}, \mathbf{K}, \mathbf{V}) =
\text{softmax}\left(\frac{\text{RoPE}(\mathbf{Q})\text{RoPE}(\mathbf{K})^\top}{\sqrt{d}}\right)\mathbf{V},
$$

where \(\mathbf{Q}\), \(\mathbf{K}\), and \(\mathbf{V}\) are query, key, and value tokens, and \(d\) is key dimensionality [2603.25209]. For frame indices \(i\) and \(j\), the temporal relative position is

$$
P_{\text{ori}} = i-j.
$$

When the video length \(L\) is extended beyond the pretrained regime, the temporal relative-position range expands to \([-(L-1), L-1]\), and the attention context grows proportionally [2603.25209].

The intended input is a pretrained video DiT, a text prompt, a target length larger than the pretrained length, a precomputed layer sensitivity profile, and the hyperparameters for VRPR and TSA. The output is a generated long video at the requested length. The method is explicitly training-free: no gradient updates, no test-time optimization, and no retraining are required [2603.25209].

## 2. The two out-of-distribution pathologies

FreeLOC treats long-video failure not as a single extrapolation problem but as the superposition of two O.O.D. effects [2603.25209].

The first is **frame-level relative position O.O.D.**. Because video DiTs use 3D RoPE to encode spatiotemporal relations, extending generation length forces the model to extrapolate temporal relative positions beyond the range seen during training. The paper argues that this causes the model to misinterpret temporal dependencies, with visible consequences such as degraded visual quality and temporal inconsistency. It also reports that this effect is layer-dependent: some layers are much more sensitive than others [2603.25209].

The second is **context-length O.O.D.**. Even if relative positions are remapped into the pretrained domain, the self-attention softmax still operates over far more tokens than the model was trained to distribute probability mass across. The paper diagnoses this through rising attention entropy, which corresponds to more diffuse attention and weaker preservation of local detail. For a token-wise post-softmax attention distribution \(p_i\), the Shannon entropy is

$$
H(p_i) = - \sum_{j=1}^{L} p_{i,j} \ln(p_{i,j}).
$$

As context length increases, the reported entropy increases as well, which the paper associates with blurred details, weaker motion precision, and less stable local visual structure [2603.25209].

This decomposition is important because it motivates distinct remedies. A positional correction alone does not resolve attention diffusion, while a sparsity pattern alone does not correct RoPE extrapolation. FreeLOC therefore pairs a position re-encoding mechanism with a context-structuring mechanism and applies them selectively.

## 3. Core mechanisms: VRPR and TSA

### VRPR

VRPR, or **Video-based Relative Position Re-encoding**, remaps temporal relative positions back into the pretrained RoPE regime using a hierarchical multi-granularity scheme [2603.25209]. The method partitions temporal distances into three regions, controlled by thresholds \(W_1\) and \(W_2\):

1. \(|i-j| \le W_1\): fine-grained region  
2. \(W_1 < |i-j| \le W_2\): medium-grained region  
3. \(|i-j| > W_2\): coarse-grained region

In the fine-grained region, relative positions are preserved exactly. In the medium- and coarse-grained regions, positions are quantized with group sizes \(G_1\) and \(G_2\), respectively, so that local temporal precision is retained while longer-range relations are compressed back into the pretrained positional range [2603.25209]. The design premise is that nearby frames require exact temporal precision for motion and detail, whereas distant frames primarily need approximate ordering for global coherence.

The paper states that the re-encoded maximum relative position must remain within the pretrained range. For target length \(L_{\text{target}}\) and pretrained length \(L\), the hyperparameters are chosen so that

$$
\left\lfloor \frac{L_{\text{target}} - 1}{G_2} \right\rfloor
+
\left(
W_2 - \left\lfloor \frac{W_2}{G_2} \right\rfloor
- \left\lfloor \frac{W_2-W_1}{G_1} \right\rfloor
\right)
\le L - 1.
$$

Reported settings include \(W_1=10, W_2=14, G_1=2, G_2=8\) for Wan 4× extension, and \(W_1=12, W_2=20, G_1=2, G_2=8\) for Hunyuan 4× extension [2603.25209].

### TSA

TSA, or **Tiered Sparse Attention**, addresses context-length O.O.D. by structuring temporal attention density across scales rather than applying either full attention or a fixed sliding window [2603.25209]. It uses three tiers:

- dense local attention for nearby frames,
- striped attention for mid-range dependencies,
- pruning of very long-range direct attention, with a persistent attention sink.

The mask is defined over frames and within-frame token indices as

$$
\tilde M_{i,j,k,l} =
\begin{cases}
1, & \text{if } |i-j| < D_1 \text{ or } j=0 \\
1, & \text{if } D_1 \le |i-j| < D_2 \text{ and } |k-l| < D_s \\
0, & \text{otherwise.}
\end{cases}
$$

Here \(D_1\) and \(D_2\) are temporal thresholds, \(D_s\) is the stripe width, and \(j=0\) implements the **attention sink**, which is the initial frame and remains visible to all later frames [2603.25209]. The stripe width is chosen as

$$
D_s = \left\lfloor \frac{n D_1}{\alpha (D_2-D_1)} \right\rfloor,
$$

where \(n\) is the number of tokens per frame and \(\alpha\) is a density reduction factor [2603.25209]. Reported settings include \(D_1=8, D_2=24, \alpha=4\) for Wan 4× and \(D_1=12, D_2=36, \alpha=4\) for Hunyuan 4× [2603.25209].

The resulting division of labor is explicit: VRPR corrects positional extrapolation, while TSA keeps local attention dense, allows structured mid-range access, and preserves a global anchor through the first-frame sink.

## 4. Layer-adaptive probing and selective application

A defining feature of FreeLOC is that VRPR and TSA are not applied uniformly across all transformer layers [2603.25209]. Instead, the paper performs an offline layer-wise probing procedure to estimate which layers are sensitive to which O.O.D. source.

For **frame-level relative position O.O.D.**, the probe perturbs one self-attention layer at a time by shifting only the RoPE of keys while leaving queries unchanged. Sensitivity is then measured with two signals: **Vision Reward**, used as a proxy for human-rated generation quality, and **Attention Logits Difference (ALD)**,

$$
\|w_i^{\text{probing}}-w_i^{\text{original}}\| \,/\, |w_i^{\text{original}}|,
$$

where \(w_i\) is the average attention logits of layer \(i\) across heads and sampling steps [2603.25209]. Lower Vision Reward and higher ALD indicate greater positional sensitivity.

For **context-length O.O.D.**, the paper first generates long videos with VRPR already enabled, then replaces only one layer at a time with conventional sliding-window attention and measures the change in attention entropy. The **Context Length Sensitivity Score** is

$$
S_i = \frac{\|H_i^{\text{probing}} - H_i^{\text{original}}\|}{\|H_i^{\text{original}}\|}.
$$

Higher \(S_i\) indicates that the layer is more sensitive to context-length O.O.D. [2603.25209].

The supplementary reports that the top two-thirds of layers with the largest degradation or score increase are marked sensitive for each O.O.D. type, while the practical allocation used in FreeLOC assigns the top 50% of layers most sensitive to context length to **VRPR+TSA**, and the remaining layers to **VRPR only**; the authors describe this 50/50 split as the best sweet spot [2603.25209]. For Wan2.1-T2V-1.3B, published layer profiles are given for a 30-layer model; for HunyuanVideo, profiles are given for a 60-layer model [2603.25209].

This selectivity is not merely an efficiency heuristic. The ablations show that layer-adaptive assignment outperforms uniform application, random assignment, reverse assignment, and simple contiguous partitions. This suggests that different transformer layers specialize in different forms of temporal reasoning, and that indiscriminate correction can over-regularize insensitive layers [2603.25209].

## 5. Empirical performance, efficiency, and ablations

FreeLOC is evaluated on 100 prompts randomly sampled from VBench-long at 480p (\(832\times 480\)) on a single NVIDIA A100 80GB GPU, using 50 denoising steps and CFG \(6.0\). Wan uses UniPC sampling and Hunyuan uses Euler sampling [2603.25209]. The paper reports VBench metrics for video consistency—Subject Consistency (SC), Background Consistency (BC), Motion Smoothness (MS)—and video quality—Imaging Quality (IQ), Aesthetic Quality (AQ), Dynamic Degree (DD) [2603.25209].

The main results are summarized below.

| Setting | Consistency: SC / BC / MS | Quality: IQ / AQ / DD |
|---|---:|---:|
| Wan2.1-T2V-1.3B, 161 frames | 98.06 / 97.49 / 98.98 | 68.31 / 62.33 / 39.41 |
| Wan2.1-T2V-1.3B, 321 frames | 98.44 / 97.78 / 98.97 | 67.44 / 61.21 / 36.27 |
| HunyuanVideo, 253 frames | 97.92 / 97.34 / 98.99 | 68.92 / 62.38 / 40.22 |
| HunyuanVideo, 509 frames | 98.47 / 98.12 / 98.95 | 67.92 / 61.09 / 39.28 |

Across both model families and both extension ratios, the paper reports that FreeLOC is the strongest all-around method among training-free baselines such as Direct Sampling, Sliding Window, FreeNoise, FreeLong, and RIFLEx [2603.25209]. A notable result is that direct sampling can retain superficially high consistency scores on Wan 4×—for example SC \(98.50\) and BC \(97.89\)—while collapsing in Dynamic Degree to \(4.32\), indicating that long-video failure is not adequately captured by consistency metrics alone [2603.25209].

The ablations attribute the gains to all three components. For positional handling on Wan 4×, VRPR outperforms clipping, grouping, and reported RoPE scaling alternatives such as Linear Interpolation, YaRN, and NTK-aware scaling [2603.25209]. For attention structure, TSA outperforms Sliding Window and Selected Frame Attention on the reported balance of consistency and quality metrics [2603.25209]. For system composition, the best result on Wan 4× is obtained by the full layer-adaptive FreeLOC configuration rather than by Direct+TSA, Direct+VRPR, or uniform VRPR+TSA [2603.25209].

The user study also favors FreeLOC, with reported scores of \(4.11\) for Content Consistency, \(3.95\) for Video Quality, and \(3.78\) for Video-Text Alignment [2603.25209]. On efficiency, Wan 321-frame generation requires \(24.35\) s/step and \(29.87\) GB with FreeLOC, compared with \(33.93\) s/step and \(29.34\) GB for direct sampling, and \(48.15\) s/step and \(40.71\) GB for FreeLong [2603.25209]. The one-time probing stage is reported at about 4 hours on an RTX 4090 for Wan, and the derived layer profile is highly stable, with Spearman correlation \(\rho = 0.984 \pm 0.009\) when estimated from a single prompt [2603.25209].

## 6. Reproduction, limitations, and disambiguation

For reproduction, the paper emphasizes several implementation choices [2603.25209]. VRPR is implemented by modifying query and key position indices before RoPE rather than editing a full relative-position matrix, which preserves compatibility with efficient attention kernels such as FlashAttention2. TSA requires construction of a four-dimensional mask with dense local attention, striped mid-range attention, and an always-visible first-frame sink. The layer profile is architecture-specific and must be precomputed once per backbone. The reported code is available at `https://github.com/Westlake-AGI-Lab/FreeLOC` [2603.25209].

The paper also delineates clear limitations. FreeLOC assumes a transformer-based video diffusion model with RoPE-style positional encoding; its layer profiles are model-specific; and its evidence is concentrated on 2× and 4× extension rather than arbitrary unbounded length extrapolation [2603.25209]. The fixed first-frame attention sink is effective in the reported benchmarks, but the authors note that it may be suboptimal for videos with large scene changes, suggesting adaptive sinks as a plausible extension [2603.25209]. A further practical implication is that FreeLOC introduces an offline characterization stage even though runtime sampling remains training-free.

A common source of confusion is nomenclature. Despite its name, FreeLOC is not a geolocation, location-proof, 3D occupancy, or LiDAR localization system. arXiv contains similarly named but unrelated systems including HLOC for IP geolocation [1706.09331], FedLoc for federated localization [2003.03697], ProLoc for region proofs in hindsight [2404.04297], VerLoc for decentralized geo-location verification [2105.11928], LOcc for open-vocabulary occupancy prediction [2411.16072], LOC for open-set 3D occupancy prediction [2510.22141], and TreeLoc++ for forest LiDAR localization [2603.03695]. FreeLOC, by contrast, belongs to the literature on long-video generation with pretrained video diffusion transformers [2603.25209].

In the design space of training-free long-video generation, FreeLOC is best understood as a three-part synthesis: a diagnosis that long-video extrapolation induces two separate O.O.D. failures, a pair of corrections specialized to those failures, and a layer-adaptive selection rule that determines where those corrections are beneficial. Its significance lies less in inventing a new generative architecture than in showing that long-video quality can be improved materially at inference time by restructuring positional encoding and attention only where the pretrained model is demonstrably sensitive [2603.25209].

Source: https://www.emergentmind.com/topics/freeloc