Manuscript Offprint

arXiv:2610.39223

Where Position Matters: Profiling-Guided Layer-Wise RoPE Allocation in Transformers

Zhiwei Liu, Boao Kong, Bing Liu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Rotary Position Embedding (RoPE) typically uses uniform coverage across Transformer layers despite heterogeneous positional requirements. Phase-off interventions reveal non-uniform, model-specific rotary-phase dependence, while coverage interventions relate it to coverage-upgrade benefits. We propose profiling-guided layer-wise RoPE allocation, assigning high/low coverage under a fixed budget using early coverage-benefit profiles. The framework supports fixed-width query/key representations and physical rotary-dimension allocation in Multi-head Latent Attention (MLA). Normalized-depth mapping transfers profiles within model families, enabling small-model measurements to guide larger-model allocations before pretraining. A brief analysis relates selection and transfer to score calibration and inter-layer interactions. From-scratch experiments demonstrate validation-loss improvements over available budget-matched baselines, while analytical resource accounting identifies favorable quality-storage-compute trade-offs for physical MLA. These results connect positional demand to transferable, efficient architecture design.

1 Introduction

Transformers [26, 8] model interactions within a sequence through attention, with positional encodings [20, 19] providing information about token order and distance. Rotary Position Embedding (RoPE) [24] applies position-dependent rotations to query and key dimension pairs, allowing attention scores to encode relative positional relationships. This mechanism introduces two architectural choices: how many dimensions receive rotary transformations at each layer, and how these dimensions are distributed across network depth. Connecting these choices to the positional requirements of individual layers creates a design space for improving language modeling under resource constraints.

Recent studies demonstrate the flexibility of rotary configurations. A systematic investigation of partial RoPE [12] examines how rotary coverage affects training dynamics and convergence, showing that reduced coverage can achieve performance comparable to full rotation. RNoPE-SWA [30] interleaves RoPE-based sliding-window attention with global attention using no positional embeddings, exploiting complementary layer functions to improve quality and efficiency. RFIS and RPD [22] further characterize attention-head specialization through frequency interventions and changes in attention distributions, providing architectural guidance for hybrid attention. These advances highlight the flexibility of rotary design and motivate adapting coverage to the positional demands of individual layers. Turning this idea into a practical design procedure requires reliable demand measurements, explicit budgeted allocation rules, and cost-effective access to profiling information across model scales, bringing the following challenges into focus.

Limitations of existing approaches. The practical value of a positional profile depends on its connection to task performance, its ability to guide layer-wise allocation, and the cost of obtaining it at the target scale.

*Zhiwei Liu and Boao Kong contributed equally to this work. †Boao Kong is the corresponding author. Email: kongboao@stu.pku.edu.cn.

L1. Limited calibration between positional dependence and task-level utility. Frequency-level analyses [3] and head-level functional profiling [22] reveal how rotary modulation shapes attention behavior. Translating these observations into layer-wise allocation requires a quantitative connection to the language-modeling objective: how strongly does each layer depend on rotary phase, and how well does this dependence predict the benefit of increasing its coverage? Establishing this connection is essential for using positional profiles as allocation signals.

L2. Coarse-grained allocation of rotary resources across layers. Uniform partial RoPE [12] assigns a common coverage ratio across depth, while RNoPE-SWA [30] uses a predefined interleaving structure. These allocation rules offer limited flexibility for matching coverage to model-specific layer requirements. Varying coverage-upgrade benefits call for explicit allocation and matched-budget layer-placement comparisons.

L3. Repeated profiling costs across model scales. Checkpoint-based positional analyses [3, 22] require trained model states and additional evaluations. Applying this workflow separately at each target scale incurs repeated costs for checkpoint acquisition, interventions, and configuration selection. Reusing structural information from smaller models therefore becomes an important step toward determining larger-model allocations before training.

These challenges motivate a unified framework for rotary allocation with efficient reuse of profiling information. We therefore ask:

How can positional demand guide model-specific RoPE allocation under a fixed budget, and how can small-model profiles support larger-scale architecture design?

Main contributions. We introduce profiling-guided layer-wise RoPE allocation, connecting positional-demand measurement, budgeted architecture design, and cross-scale profile transfer. We first quantify layer-wise dependence through phase-off interventions and calibrate the resulting scores against coverage-upgrade benefits. We then assign high and low rotary coverage using early coverage-benefit scores. Finally, a normalized-depth mapping transfers small-model profiles into allocations specified before target-model training. Our contributions are threefold.

C1. Task-level positional-demand measurement and calibration (addressing L1). We use phase-off profiling, which replaces a layer's rotary transformation with the identity while preserving its pre-rotation query/key representations and attention mask. Paired changes in validation loss quantify the layer's dependence on rotary phase. Across four pretrained models and 136 layers, we identify strongly non-uniform and model-specific demand profiles. Controlled coverage interventions on selected high-, medium-, and low-demand layers further reveal strong ranking agreement between phase-off scores and coverage-upgrade benefits, connecting positional dependence to actionable architectural changes.

C2. Model-specific RoPE allocation under a fixed budget (addressing L2). We assign higher coverage to layers with larger early coverage-benefit scores and lower coverage to the remaining layers, subject to a prescribed total rotary-pair budget. Within each allocation experiment, configurations share a master frequency bank and use nested frequency-pair subsets. We provide a fixed-carrier implementation that preserves complete query/key widths, together with a physical rotary-dimension implementation for Multi-head Latent Attention (MLA) [14, 15]. The latter connects layer-wise allocation to projection parameters, attention computation, and positional-key storage. A brief motivating analysis explains how upgrade benefits, score calibration, and inter-layer interactions inform the selection rule.

C3. Within-family cross-scale allocation transfer (addressing L3). We map small-model allocation profiles to larger models along normalized depth and combine the transferred scores with the target budget to determine layer-wise coverage before training. This procedure reuses source-model measurements for architecture selection at larger scales. From-scratch experiments with transferred allocations examine their language-modeling behavior under different attention parameterizations, connecting source-side structural measurements to target-scale training outcomes.

References (30)