Full text not available for this paper

Neural Dimensional Analysis: Foundations of Dimensionless and Scale-Consistent Computation

Summary (Overview)

  • Unified framework: Introduces Neural Dimensional Analysis (NDA), a framework based on dimensional consistency that unifies scale-control mechanisms in Transformers (normalization, residual scaling, attention temperatures, loss weighting, and adaptive updates) under one set of local typing rules.
  • Key theoretical contribution: Defines neural units as transformation laws under a rescaling group, proving that forward unit declarations fix gradient transformation laws (Reverse-mode dual typing, Prop. 1), enabling unit-consistent diagnostics and network design.
  • Novel diagnostics and architecture: Introduces dimensionless Unit Violation Indices (UVI) for diagnosing scale mismatches and the Gauge-Canonical Transformer (GCT), which computes every block on dimensionless coordinates with orthogonalized residual additions.
  • Strong empirical results: GCT remains stable across a 16× learning-rate range (51M–1B parameters), achieves superior depth transfer (3.903 vs 4.243 nats for nGPT at L=48), and shows exceptional quantization robustness (only +0.009 nats loss increase under per-tensor int8 at 1B, vs up to +5.51 for baselines).
  • Broad applicability: Validates NDA principles beyond language modeling via vision benchmarks and physics-informed neural networks (PINNs), where unit-aware loss aggregation preserves accuracy across a 10⁴ unit sweep.

Introduction and Theoretical Foundation

Background and Motivation

Modern Transformers rely on a broad family of scale-control mechanisms:

  • Normalization: BatchNorm, LayerNorm, RMSNorm normalize activations
  • Residual scaling: DeepNet, ReZero, LayerScale, Fixup control residual addition scales
  • Attention regulation: Attention scaling and QK-Norm regulate softmax inputs
  • Loss balancing: Loss-balancing methods and adaptive optimizers manage scale imbalances

The paper observes that all these mechanisms manage how quantities of different scales interact within a neural network, and interprets them through the lens of dimensional consistency—a fundamental principle from physics.

Theoretical Foundation: Neural Units

The core insight is to define neural units as transformation laws governing how internal tensors rescale when the computation graph is rescaled. Unlike physical units, neural units describe internal scaling behavior even when data have no physical units.

Rescaling group and representations:

Let G:=(R+)K\mathcal{G} := (\mathbb{R}_+)^K be a rescaling group with one factor per independent internal scale degree of freedom. A neural unit of node vv is a representation:

ρv:G→GL(Vv),xv↦ρv(g)xv\rho_v : \mathcal{G} \to \text{GL}(V_v), \quad x_v \mapsto \rho_v(g) x_v

A tensor is dimensionless if and only if ρv≡I\rho_v \equiv I. For scalar units, we use continuous characters:

χu(g):=∏k=1Kgkuk,u∈RK\chi_u(g) := \prod_{k=1}^{K} g_k^{u_k}, \quad u \in \mathbb{R}^K

Unit consistency for an operation y:=f(x1,…,xn)y := f(x_1, \ldots, x_n) requires the equivariance identity:

f(ρ1(g)x1,…,ρn(g)xn)=ρy(g)f(x1,…,xn)∀g∈Gf(\rho_1(g) x_1, \ldots, \rho_n(g) x_n) = \rho_y(g) f(x_1, \ldots, x_n) \quad \forall g \in \mathcal{G}

Key Theoretical Results

Proposition 1 (Reverse-mode dual typing): If the loss node is typed dimensionless and every primitive operation is unit-consistent, then every reverse-mode gradient node transforms by the dual law ρv−⊤\rho_v^{-\top}.

Under scalar rescaling x↦cxx \mapsto cx, we get ∇xL↦c−1∇xL\nabla_x L \mapsto c^{-1}\nabla_x L, meaning the primal–dual RMS product Πx:=RMS(x)⋅RMS(∇xL)\Pi_x := \text{RMS}(x) \cdot \text{RMS}(\nabla_x L) is comparable across rescalings.

Local Typing Rules

OperationRule
Additionz:=x+yz := x + y requires u(x)=u(y)=u(z)u(x) = u(y) = u(z)
NormalizationN(x):=x/RMS(x)N(x) := x/\text{RMS}(x) removes units (nondimensionalization)
Softmax/AttentionLogit differences must be dimensionless; temperature converts units
ActivationsSigmoid, tanh, GELU, SiLU require dimensionless arguments
Gated MLPsz:=v⊙gz := v \odot g requires u(g)=1u(g) = 1 for gate
Loss aggregationL:=∑iλiLiL := \sum_i \lambda_i L_i forces u(λi)=u(Li)−1u(\lambda_i) = u(L_i)^{-1}
Optimizer updatesθt+1=θt+Δθt\theta_{t+1} = \theta_t + \Delta\theta_t needs u(Δθ)=Uθu(\Delta\theta) = U_\theta

Calibrated attention temperature:

τℓ,h:=dh sQ,ℓ,h sK,ℓ,h\tau_{\ell,h} := \sqrt{d_h} \, s_{Q,\ell,h} \, s_{K,\ell,h}

where sQs_Q and sKs_K are per-head coordinate scales, and the standard dh\sqrt{d_h} is the sQ=sK=1s_Q = s_K = 1 special case.

Loss weight factorization:

λi=αi/Si,u(Si)=u(Li),u(αi)=1\lambda_i = \alpha_i / S_i, \quad u(S_i) = u(L_i), \quad u(\alpha_i) = 1

where 1/Si1/S_i converts each loss to dimensionless value and αi\alpha_i sets task preference.

Residual Scale Dynamics

For residual addition hℓ+1=hℓ+rℓh_{\ell+1} = h_\ell + r_\ell with step size αℓ:=RMS(rℓ)/RMS(hℓ)\alpha_\ell := \text{RMS}(r_\ell)/\text{RMS}(h_\ell):

sℓ+12=sℓ2(1+αℓ2+2αℓcℓ),cℓ:=⟨hℓ,rℓ⟩∥hℓ∥∥rℓ∥s_{\ell+1}^2 = s_\ell^2 (1 + \alpha_\ell^2 + 2\alpha_\ell c_\ell), \quad c_\ell := \frac{\langle h_\ell, r_\ell \rangle}{\|h_\ell\| \|r_\ell\|}

For persistent positive alignment (cℓ≥c0>0c_\ell \geq c_0 > 0), bounded scale requires ∑ℓαℓ=O(1)\sum_\ell \alpha_\ell = O(1), giving O(L−1)O(L^{-1}) per layer. Orthogonalization removes the linear term, permitting ∑ℓαℓ2=O(1)\sum_\ell \alpha_\ell^2 = O(1) with uniform Θ(L−1/2)\Theta(L^{-1/2}) steps.

Methodology

Unit Violation Indices (UVI)

UVI measures dimensionless log-deviations from target values or log-dispersion across depth:

UVIres(ℓ):=log⁡αℓ+ϵα⋆+ϵ,α⋆:=12L\text{UVI}_{\text{res}}(\ell) := \log \frac{\alpha_\ell + \epsilon}{\alpha^\star + \epsilon}, \quad \alpha^\star := \frac{1}{\sqrt{2L}} UVIattn(ℓ,h):=log⁡vˉℓ,h+ϵv⋆+ϵ,v⋆:=1\text{UVI}_{\text{attn}}(\ell, h) := \log \frac{\bar{v}_{\ell,h} + \epsilon}{v^\star + \epsilon}, \quad v^\star := 1

where αℓ\alpha_\ell is the measured residual step size and vˉℓ,h\bar{v}_{\ell,h} is the batch-averaged row-centered logit variance.

Gauge-Canonical Transformer (GCT)

GCT computes every block on normalized, dimensionless coordinates via the factorization:

unitful=unit scale×canonical coordinate\text{unitful} = \text{unit scale} \times \text{canonical coordinate}

Canonicalizer (with numerical stability floor):

C(x):=xRMS(x)2+ϵxC(x) := \frac{x}{\sqrt{\text{RMS}(x)^2 + \epsilon_x}}

Orthogonalized residual update:

aˉℓ:=Φℓ(hˉℓ),a^ℓ:=C(Phˉℓ⊥aˉℓ)\bar{a}_\ell := \Phi_\ell(\bar{h}_\ell), \quad \hat{a}_\ell := C(P_{\bar{h}_\ell}^{\perp} \bar{a}_\ell) hˉℓ+:=C(hˉℓ+αℓa^ℓ)\bar{h}_{\ell+} := C(\bar{h}_\ell + \alpha_\ell \hat{a}_\ell)

where the orthogonal projector is:

Phˉ⊥a:=a−⟨a,hˉ⟩∥hˉ∥2hˉ,hˉ≠0P_{\bar{h}}^\perp a := a - \frac{\langle a, \bar{h} \rangle}{\|\bar{h}\|^2} \bar{h}, \quad \bar{h} \neq 0

and learnable dimensionless scalars αℓ\alpha_\ell are initialized at 1/2L1/\sqrt{2L}.

Key components:

  • Queries/keys canonicalized per head: qˉ:=C(q)\bar{q} := C(q), kˉ:=C(k)\bar{k} := C(k)
  • Per-head dimensionless gain ghg_h initialized at 1
  • Normalized gate: g~:=C(a)σ(C(a))\tilde{g} := C(a)\sigma(C(a)) for gated MLPs
  • Dimensionless logits from C(hˉL)C(\bar{h}_L) with learnable logit gain

Experimental Setup

  • Models: Decoder-only Transformers with 51M, 124M, 350M, and 1B parameters
  • Baselines: Pre-LN, LLaMA-style, QK-Norm, nGPT
  • Data: FineWeb-Edu with identical data order, token budget, and optimization recipe
  • Tests: Learning-rate robustness, depth transfer, internal-rescaling invariance, PTQ robustness, PINN unit invariance

Empirical Validation / Results

Learning-Rate Robustness

GCT and nGPT remain stable across the full 16× learning-rate range and retain low validation loss at the highest rates. At rate 9.6×10−39.6 \times 10^{-3}:

  • GCT and nGPT continue improving
  • QK-Norm's loss is 0.197 nats above its best
  • Pre-LN and LLaMA-style stopped early (~8% of budget) due to UVI threshold

Depth Transfer (Fixed Budget, 400M Tokens)

ArchitectureL=24L=48
Pre-LN4.3974.598
LLaMA-style4.3224.513
QK-Norm4.2064.322
nGPT3.9964.243
GCT (ours)3.9733.903
GCT without P⊥P^\perp3.9833.938
nGPT with P⊥P^\perp4.0053.968

Adding the GCT projection to nGPT reduces loss by 0.275 nats at L=48, demonstrating the NDA-derived component's broad applicability.

Post-Training Quantization (PTQ) at 1B

ArchitectureBaseW4W8A8Stream int8 (tensor)Stream int8 (token)Stream int4 (tensor)Stream int4 (token)
Pre-LN2.759+0.045+0.028+3.018+0.049+6.390+7.101
LLaMA-style2.744+0.032+0.348+5.513+0.030+7.117+5.474
QK-Norm2.737+0.029+0.833+5.426+0.021+8.074+5.230
nGPT2.751+0.038+0.075+0.032+0.008+19.083+4.661
GCT (ours)2.756+0.028+0.079+0.009+0.001+9.517+0.739

Key finding: NDA predicts that cross-token scale variation consumes log⁡2κscale\log_2 \kappa_{\text{scale}} bits of effective resolution, where κscale\kappa_{\text{scale}} is the ratio of largest to smallest token RMS. The zero-floor GCT stream fixes κscale=1\kappa_{\text{scale}} = 1.

Weight-Space Fingerprint

Prop. 6 predicts zero radial sensitivity ⟨W,∇WL⟩F\langle W, \nabla_W L \rangle_F when downstream computation cancels rescaling. All 54 of 54 architecture-by-role predictions match across eight trained 124M models; 34 of 34 cells match at 1B.

PINN Results

Across a 10410^4 unit sweep, NDA's scaled output head and loss weights keep worst relative L2L_2 error at 0.015, whereas equal or adaptive weights degrade for at least one rescaling.

Theoretical and Practical Implications

Theoretical Contributions

  1. Unified unit calculus: Provides a graph-level unit calculus covering activations, objectives, gradients, and updates, linking forward computation and backpropagation through a single set of unit rules (Prop. 1).

  2. Quantization theory: Establishes that worst-case downstream output error grows as Θ(κscale/q)\Theta(\kappa_{\text{scale}}/q) where q=2b−1−1q = 2^{b-1} - 1, formalizing how cross-token scale variation consumes bits of effective resolution.

  3. Residual stability analysis: Proves that orthogonalized residual additions permit Θ(L−1/2)\Theta(L^{-1/2}) per-layer steps while maintaining bounded cumulative squared step size, as in depth-wise μ\muP.

Practical Implications

  1. Diagnostic tool: UVI provides inexpensive, actionable diagnostics on small batches during training, locating scale mismatches at specific interfaces.

  2. Architecture design: GCT demonstrates that explicit scale management grounded in dimensional analysis yields:

    • More reliable learning-rate transfer across model sizes
    • Better depth scaling without hyperparameter retuning
    • Superior quantization robustness for deployment
    • Unit-invariant loss aggregation for multi-task and physics-informed learning
  3. General principle: The success of NDA across language modeling, vision, and PINNs suggests dimensional consistency as a fundamental neural network design principle, not merely a practical trick.

Conclusion

Neural Dimensional Analysis establishes dimensional consistency as a typing principle for scale management across the entire computation graph. The framework:

  1. Unifies existing scale-control mechanisms (normalization, residual scaling, attention temperature, loss weighting, optimizer updates) under one set of local typing rules
  2. Provides testable diagnostics (UVI) and a weight-space audit that locate scale mismatches
  3. Yields a practical architecture (GCT) that achieves competitive clean performance while providing superior learning-rate robustness, depth transfer, and quantization resilience
  4. Extends beyond language modeling to vision and physics-informed neural networks

Future directions suggested by this work include:

  • Applying NDA to other architectures (CNNs, graph neural networks)
  • Exploring unit-consistent objectives for multi-modal learning
  • Extending the framework to structured state spaces and other sequence models
  • Investigating connections with neural ODEs and other physics-grounded architectures

The results collectively establish dimensional consistency as a neural network design principle, offering a principled alternative to the ad-hoc scale-control mechanisms currently used in deep learning.

Related papers