Differentiable Spherical Dictionary Routing via Canonical Temperature Scaling:
Bounded Jacobians, Extremal Lattices, and Smooth Latent Quantization Dynamics

SRFP311T1 Collaboration
October 2026

Abstract

Vector-quantized representations are foundational to discrete generative modeling, bridging continuous neural representations with categorical latent variables. However, the non-differentiability of hard nearest-neighbor selection has historically necessitated reliance on heuristic gradient surrogates—predominantly the Straight-Through Estimator (STE)—which frequently induce severe gradient variance, codebook underutilization, and ill-conditioned bottleneck Jacobians (\(\kappa > 10^8\)).

In this work, we investigate Differentiable Spherical Dictionary Routing (DSDR), a geometric framework for continuous latent quantization. By decomposing continuous latent vectors into radial scales and directional unit vectors on \(\mathbb{S}^{d-1}\), routing is parameterized as a smooth Nadaraya–Watson kernel operator over spherical anchor dictionaries. Leveraging Haar measure concentration on \(\mathbb{S}^{d-1}\), we prove the Unit Logit Variance Principle: isotropic background logits normalize to unit statistical variance if and only if temperature scales according to the canonical law \(T^*(d) = d^{-1/2}\), establishing a principled, dimension-agnostic bandwidth baseline.

We derive the exact analytical Jacobian \(J(\boldsymbol{z}_e)\) of the routing layer and establish a rigorous operator norm bound: \(\|J(\boldsymbol{z}_e)\|_2 \le 1 + \sqrt{d}\), with the layer proving strictly non-expansive along radial variations (\(\|J \boldsymbol{u}\|_2 \le 1.0\)). We resolve the spectral dynamics across both concentrated Voronoi interiors and diffuse Voronoi boundaries, clarifying why universal contraction cannot hold globally on multi-centroid ridges while demonstrating that condition numbers collapse by five orders of magnitude compared to STE (\(1.30 \times 10^8 \to 465\)). We further establish an exact discrete inference gap bound and analyze the role of codebook symmetry. Through a controlled \(2 \times 2\) factorial experiment comparing the 24-dimensional Leech lattice \(\Lambda_{24}\) against random spherical codes, we show that under soft differentiable routing, random dictionaries achieve statistical parity with the extremal Leech lattice (\(|B_{\mathrm{Leech}} - D_{\mathrm{random}}| \le 10^{-4}\)), demonstrating that differentiable kernel smoothing—rather than discrete packing symmetry—is the primary driver of optimization stability. A mixed-precision-hardened PyTorch module with batch-averaged entropy regularization is provided.

1. Introduction

Discretizing continuous representations within deep generative models is central to contemporary autoregressive vision models [8], visual tokenizers [12], and discrete neural audio codecs [17, 5]. Conventional Vector-Quantized Variational Autoencoders (VQ-VAEs) [14] map continuous encoder latents \(\boldsymbol{z}_e \in \mathbb{R}^d\) to the nearest centroid within a discrete codebook \(\mathcal{C} = \{\boldsymbol{c}_1, \dots, \boldsymbol{c}_K\} \subset \mathbb{R}^d\):

\[ \boldsymbol{z}_q = \arg\min_{\boldsymbol{c}_k \in \mathcal{C}} \|\boldsymbol{z}_e - \boldsymbol{c}_k\|_2. \]

Despite its empirical success, hard vector quantization suffers from well-documented structural vulnerabilities:

  1. Discretization Discontinuity and Gradient Mismatch: The hard nearest-neighbor projection has zero derivative almost everywhere and undefined jump discontinuities across Voronoi cell boundaries. The standard workaround—the Straight-Through Estimator (STE) [1]: \[ \boldsymbol{z}_q = \boldsymbol{z}_e + \operatorname{sg}[q(\boldsymbol{z}_e) - \boldsymbol{z}_e], \] substitutes the identity operator for the true discontinuous Jacobian (\(\nabla_{\boldsymbol{z}_e} \mathcal{L} \approx \nabla_{\boldsymbol{z}_q} \mathcal{L}\)). This heuristic mismatch injects high variance into optimization trajectories, frequently producing ill-conditioned Jacobians (\(\kappa > 10^8\)).
  2. Codebook Collapse and Dead Voronoi Cells: When codebook vectors fall outside the active data manifold, they receive zero gradient mass under hard argmin routing, stranding them permanently outside training dynamics [13, 7].

The Extremal Lattice Hypothesis. To mitigate codebook underutilization, discrete geometric formulations have proposed initializing or constraining codebooks to extremal sphere packings, most prominently the 24-dimensional Leech lattice \(\Lambda_{24}\) [4, 3]. Because the minimal shell of \(\Lambda_{24}\) forms a spherical code on \(\mathbb{S}^{23}\) with uniform kissing multiplicity (\(N_{\mathrm{kiss}} = 4{,}600\)) and zero neighbor variance (\(\sigma_{\mathrm{NN}} = 0\)) under the Conway group \(\mathrm{Co}_0\), its Voronoi cells possess identical volume and maximal kissing density [2, 6]. However, whether these discrete lattice symmetries provide measurable benefits in gradient-optimized neural networks—or whether continuous relaxation dominates—remains an open question.

Contributions. In this work, we formalize and rigorously analyze Differentiable Spherical Dictionary Routing (DSDR). Our primary theoretical and empirical contributions are:

2. Theoretical Framework: Differentiable Spherical Routing

2.1 Spherical Decomposition of Latent Representations

Let \(\boldsymbol{z}_e \in \mathbb{R}^d \setminus \{\boldsymbol{0}\}\) denote the unconstrained continuous output of an encoder network \(f_\theta(\boldsymbol{x})\). We decompose \(\boldsymbol{z}_e\) uniquely into a radial magnitude \(r \in \mathbb{R}_{>0}\) and a directional unit vector \(\boldsymbol{u} \in \mathbb{S}^{d-1}\):

\[ r = \|\boldsymbol{z}_e\|_2, \qquad \boldsymbol{u} = \frac{\boldsymbol{z}_e}{\|\boldsymbol{z}_e\|_2} \in \mathbb{S}^{d-1}. \]

Let \(\mathbf{C} = [\boldsymbol{c}_1, \dots, \boldsymbol{c}_K]^T \in \mathbb{R}^{K \times d}\) denote a dictionary of \(K\) normalized anchor centroids lying on the unit hypersphere:

\[ \mathcal{C} = \{\boldsymbol{c}_k \in \mathbb{S}^{d-1} : \|\boldsymbol{c}_k\|_2 = 1, \; k = 1, \dots, K\}. \]

Rather than selecting a single centroid via discontinuous argmin projection, directional routing is formulated via a smooth Nadaraya–Watson kernel operator on \(\mathbb{S}^{d-1}\) parameterized by temperature \(T > 0\):

\[ \ell_k(\boldsymbol{u}) = \frac{\langle \boldsymbol{u}, \boldsymbol{c}_k \rangle}{T}, \qquad p_k(\boldsymbol{u}) = \frac{\exp(\langle \boldsymbol{u}, \boldsymbol{c}_k \rangle / T)}{\sum_{j=1}^K \exp(\langle \boldsymbol{u}, \boldsymbol{c}_j \rangle / T)}. \]

The reconstructed directional vector \(\bar{\boldsymbol{u}} \in \mathbb{R}^d\) is the convex combination:

\[ \bar{\boldsymbol{u}} = \sum_{k=1}^K p_k(\boldsymbol{u}) \boldsymbol{c}_k = \mathbf{C}^T \boldsymbol{p}(\boldsymbol{u}). \]

The full bottleneck reconstruction \(\boldsymbol{z}_{\text{rep}} \in \mathbb{R}^d\) restores the input radial scale:

\[ \boldsymbol{z}_{\text{rep}} = r \, \bar{\boldsymbol{u}} = \|\boldsymbol{z}_e\|_2 \sum_{k=1}^K p_k\left(\frac{\boldsymbol{z}_e}{\|\boldsymbol{z}_e\|_2}\right) \boldsymbol{c}_k. \tag{2.1} \]
Proposition 2.1 (Asymptotic Regimes of Spherical Routing)

The routing operator \(r_T(\boldsymbol{u}) = \sum_{k=1}^K p_k(\boldsymbol{u}) \boldsymbol{c}_k\) satisfies:

  1. Zero-Temperature Limit (\(T \to 0^+\)): For any \(\boldsymbol{u}\) with a unique nearest centroid \(k^* = \arg\max_k \langle \boldsymbol{u}, \boldsymbol{c}_k \rangle\): \[ \lim_{T \to 0^+} r_T(\boldsymbol{u}) = \boldsymbol{c}_{k^*}, \] recovering hard Voronoi spherical quantization almost everywhere.
  2. Infinite-Temperature Limit (\(T \to \infty\)): \[ \lim_{T \to \infty} r_T(\boldsymbol{u}) = \frac{1}{K}\sum_{k=1}^K \boldsymbol{c}_k. \] For antipodally symmetric or zero-mean dictionaries, \(\lim_{T \to \infty} r_T(\boldsymbol{u}) = \mathbf{0}\).
  3. Intermediate Bandwidth (\(T \in (0, \infty)\)): \(r_T(\boldsymbol{u})\) is a real-analytic map lying strictly in the relative interior of the convex hull \(\operatorname{relint}(\operatorname{conv}(\mathcal{C})) \subset \mathbb{R}^d\).
Proof. For (1), let \(\Delta = \langle \boldsymbol{u}, \boldsymbol{c}_{k^*} \rangle - \max_{j \neq k^*} \langle \boldsymbol{u}, \boldsymbol{c}_j \rangle > 0\). Then for all \(j \ne k^*\), \(p_j(\boldsymbol{u}) / p_{k^*}(\boldsymbol{u}) \le \exp(-\Delta / T) \to 0\) as \(T \to 0^+\). Normalization implies \(p_{k^*} \to 1\) and \(p_j \to 0\). For (2), as \(T \to \infty\), logits \(\ell_k \to 0\), yielding uniform weights \(p_k \to 1/K\). For (3), since \(p_k(\boldsymbol{u}) \in (0, 1)\) strictly for all \(k\) and \(\sum p_k = 1\), \(r_T(\boldsymbol{u})\) is a strict convex combination of points in \(\mathcal{C}\), hence lying in the relative interior of \(\operatorname{conv}(\mathcal{C})\).

2.2 Derivation of the Canonical Temperature Law \(T^*(d) = d^{-1/2}\)

In standard multi-head attention over unnormalized Gaussian representations \(\boldsymbol{q}, \boldsymbol{k} \sim \mathcal{N}(\mathbf{0}, \mathbf{I}_d)\), inner-product variance grows as \(\operatorname{Var}(\langle \boldsymbol{q}, \boldsymbol{k} \rangle) = d\), motivating the heuristic scaling factor \(1/\sqrt{d}\) [15]. On the compact hypersphere \(\mathbb{S}^{d-1}\), measure concentration provides a rigorous geometric foundation for this scaling:

Theorem 2.2 (Canonical Temperature Scaling via Measure Concentration)

Let \(\boldsymbol{u}, \boldsymbol{c} \sim \operatorname{Haar}(\mathbb{S}^{d-1})\) be independent, uniformly distributed random unit vectors on the hypersphere.

  1. The inner product has expectation and variance: \[ \mathbb{E}[\langle \boldsymbol{u}, \boldsymbol{c} \rangle] = 0, \qquad \operatorname{Var}(\langle \boldsymbol{u}, \boldsymbol{c} \rangle) = \frac{1}{d}. \]
  2. As \(d \to \infty\), the scaled inner product converges in distribution to a standard Gaussian: \[ \sqrt{d} \, \langle \boldsymbol{u}, \boldsymbol{c} \rangle \xrightarrow{d} \mathcal{N}(0, 1). \]
  3. The normalized logit \(\ell = \frac{\langle \boldsymbol{u}, \boldsymbol{c} \rangle}{T}\) has unit background statistical variance if and only if:
    \[ T^*(d) = \frac{1}{\sqrt{d}}. \]
Proof. By rotational invariance of the Haar measure on \(\mathbb{S}^{d-1}\), we choose coordinates such that \(\boldsymbol{c} = (1, 0, \dots, 0)^T\). Then \(\langle \boldsymbol{u}, \boldsymbol{c} \rangle = u_1\), the first coordinate of a uniformly distributed vector on \(\mathbb{S}^{d-1}\).

Represent \(\boldsymbol{u}\) via standard normal variables: \(\boldsymbol{u} \stackrel{d}{=} \boldsymbol{X} / \|\boldsymbol{X}\|_2\), where \(\boldsymbol{X} = (X_1, \dots, X_d)^T\) with \(X_i \sim \mathcal{N}(0, 1)\) i.i.d. Then: \[ u_1 = \frac{X_1}{\sqrt{X_1^2 + \dots + X_d^2}}. \] By symmetry, \(\mathbb{E}[u_1] = 0\). By exchangeability across coordinates: \[ 1 = \mathbb{E}\left[\sum_{i=1}^d u_i^2\right] = \sum_{i=1}^d \mathbb{E}[u_i^2] = d \, \mathbb{E}[u_1^2] \implies \operatorname{Var}(u_1) = \mathbb{E}[u_1^2] = \frac{1}{d}. \] By the weak law of large numbers, \(\frac{1}{d}\sum_{i=1}^d X_i^2 \xrightarrow{P} 1\) as \(d \to \infty\). By Slutsky's theorem: \[ \sqrt{d} \, u_1 = \frac{X_1}{\sqrt{\frac{1}{d}\sum_{i=1}^d X_i^2}} \xrightarrow{d} X_1 \sim \mathcal{N}(0, 1). \] The variance of the logit \(\ell = \frac{\langle \boldsymbol{u}, \boldsymbol{c} \rangle}{T}\) is: \[ \operatorname{Var}(\ell) = \frac{1}{T^2} \operatorname{Var}(u_1) = \frac{1}{T^2 d}. \] Enforcing unit variance \(\operatorname{Var}(\ell) = 1\) requires \(T^2 d = 1 \iff T^*(d) = 1/\sqrt{d}\).
Remark 2.3 (Scope of the Canonical Temperature Law)

Theorem 2.2 establishes \(T^*(d) = d^{-1/2}\) as the unique normalization for unconditioned isotropic background logits. Prior to training, this prevents logit saturation (\(T \ll d^{-1/2}\)) and uniform dispersion (\(T \gg d^{-1/2}\)). Once encoder representations correlate with specific centroids during training, empirical logit variance naturally increases; \(T^*\) serves as a principled initialization and reference baseline.

2.3 Analytical Layer Jacobian and Operator Norm Bounds

We now analyze the exact Jacobian of the continuous routing mapping \(\boldsymbol{z}_{\text{rep}}(\boldsymbol{z}_e)\).

Theorem 2.4 (Analytical Layer Jacobian)

Let \(\boldsymbol{z}_e \ne \mathbf{0}\), \(r = \|\boldsymbol{z}_e\|_2\), and \(\boldsymbol{u} = \boldsymbol{z}_e / r \in \mathbb{S}^{d-1}\). Let \(\mathbf{P}_{\boldsymbol{u}}^\perp = \mathbf{I}_d - \boldsymbol{u}\boldsymbol{u}^T\) denote the orthogonal projector onto \(T_{\boldsymbol{u}} \mathbb{S}^{d-1}\), and let \(\operatorname{Cov}_{\boldsymbol{p}}(\mathbf{C}) = \sum_{k=1}^K p_k (\boldsymbol{c}_k - \bar{\boldsymbol{u}})(\boldsymbol{c}_k - \bar{\boldsymbol{u}})^T\) denote the routing covariance matrix. The Jacobian \(J = \frac{\partial \boldsymbol{z}_{\text{rep}}}{\partial \boldsymbol{z}_e} \in \mathbb{R}^{d \times d}\) is given exactly by:

\[ J = \bar{\boldsymbol{u}} \, \boldsymbol{u}^T + \frac{1}{T} \operatorname{Cov}_{\boldsymbol{p}}(\mathbf{C}) \mathbf{P}_{\boldsymbol{u}}^\perp. \tag{2.2} \]
Proof. Differentiating \(\boldsymbol{z}_{\text{rep}} = r \bar{\boldsymbol{u}}(\boldsymbol{u})\) with respect to \(\boldsymbol{z}_e\) via the product rule: \[ \frac{\partial \boldsymbol{z}_{\text{rep}}}{\partial \boldsymbol{z}_e} = \bar{\boldsymbol{u}} \left( \nabla_{\boldsymbol{z}_e} r \right)^T + r \left( \frac{\partial \bar{\boldsymbol{u}}}{\partial \boldsymbol{u}} \right) \left( \frac{\partial \boldsymbol{u}}{\partial \boldsymbol{z}_e} \right). \] Evaluating each constituent derivative:
  1. Radial derivative: \(\nabla_{\boldsymbol{z}_e} r = \nabla_{\boldsymbol{z}_e} \|\boldsymbol{z}_e\|_2 = \frac{\boldsymbol{z}_e}{\|\boldsymbol{z}_e\|_2} = \boldsymbol{u}\).
  2. Projector derivative: \(\frac{\partial \boldsymbol{u}}{\partial \boldsymbol{z}_e} = \frac{\partial}{\partial \boldsymbol{z}_e}\left(\frac{\boldsymbol{z}_e}{r}\right) = \frac{1}{r}(\mathbf{I}_d - \boldsymbol{u}\boldsymbol{u}^T) = \frac{1}{r} \mathbf{P}_{\boldsymbol{u}}^\perp\).
  3. Softmax directional derivative: Differentiating \(p_k(\boldsymbol{u}) = \frac{\exp(\boldsymbol{u}^T \boldsymbol{c}_k / T)}{\sum_j \exp(\boldsymbol{u}^T \boldsymbol{c}_j / T)}\) yields: \[ \frac{\partial p_k}{\partial \boldsymbol{u}} = \frac{1}{T} p_k (\boldsymbol{c}_k - \bar{\boldsymbol{u}}). \] Summing over dictionary centroids: \[ \frac{\partial \bar{\boldsymbol{u}}}{\partial \boldsymbol{u}} = \sum_{k=1}^K \boldsymbol{c}_k \left( \frac{\partial p_k}{\partial \boldsymbol{u}} \right)^T = \frac{1}{T} \sum_{k=1}^K p_k \boldsymbol{c}_k (\boldsymbol{c}_k - \bar{\boldsymbol{u}})^T. \] Since \(\sum_{k=1}^K p_k (\boldsymbol{c}_k - \bar{\boldsymbol{u}}) = \mathbf{0}\), we rewrite this sum identically as: \[ \frac{\partial \bar{\boldsymbol{u}}}{\partial \boldsymbol{u}} = \frac{1}{T} \sum_{k=1}^K p_k (\boldsymbol{c}_k - \bar{\boldsymbol{u}})(\boldsymbol{c}_k - \bar{\boldsymbol{u}})^T = \frac{1}{T} \operatorname{Cov}_{\boldsymbol{p}}(\mathbf{C}). \]
Multiplying by \(r \cdot \frac{\partial \boldsymbol{u}}{\partial \boldsymbol{z}_e} = r \left( \frac{1}{r} \mathbf{P}_{\boldsymbol{u}}^\perp \right) = \mathbf{P}_{\boldsymbol{u}}^\perp\) completes the proof.
Remark 2.5 (Absence of Left Projector)

In earlier formulations, an additional projection \(\mathbf{P}_{\boldsymbol{u}}^\perp\) was erroneously applied to the left of the covariance term. Because \(\boldsymbol{z}_{\text{rep}} \in \mathbb{R}^d\) varies in magnitude as \(\bar{\boldsymbol{u}}\) changes, \(\partial \bar{\boldsymbol{u}}/\partial \boldsymbol{u}\) has non-zero components along \(\boldsymbol{u}\). The correct Jacobian in Equation (2.2) contains \(\mathbf{P}_{\boldsymbol{u}}^\perp\) only on the right.

Theorem 2.6 (Spectral Bound on Routing Jacobian)

Let \(\mathcal{C} \subset \mathbb{S}^{d-1}\) be any unit-norm dictionary. Under canonical temperature \(T = d^{-1/2}\), the routing Jacobian satisfies:

  1. Radial Non-Expansiveness: For the radial unit vector \(\boldsymbol{u}\): \[ \|J \boldsymbol{u}\|_2 = \|\bar{\boldsymbol{u}}\|_2 \le 1.0. \]
  2. Global Operator Norm Bound: The maximal singular value satisfies:
    \[ \|J\|_2 = \sigma_{\max}(J) \le 1 + \sqrt{d}. \]
  3. Concentrated Routing Asymptotics: If routing concentrates onto a single centroid with probability \(p_{k^*} \ge 1 - \epsilon\), then: \[ \|J\|_2 \le 1.0 + 4\epsilon\sqrt{d}. \]
Proof. For (1), since \(\mathbf{P}_{\boldsymbol{u}}^\perp \boldsymbol{u} = \mathbf{0}\), we have \(J \boldsymbol{u} = \bar{\boldsymbol{u}}(\boldsymbol{u}^T \boldsymbol{u}) = \bar{\boldsymbol{u}}\). Because \(\|\boldsymbol{c}_k\|_2 = 1\) for all \(k\), the triangle inequality guarantees: \[ \|J \boldsymbol{u}\|_2 = \|\bar{\boldsymbol{u}}\|_2 = \left\| \sum_{k=1}^K p_k \boldsymbol{c}_k \right\|_2 \le \sum_{k=1}^K p_k \|\boldsymbol{c}_k\|_2 = 1.0. \] For (2), expanding the covariance matrix: \[ \operatorname{Cov}_{\boldsymbol{p}}(\mathbf{C}) = \sum_{k=1}^K p_k \boldsymbol{c}_k \boldsymbol{c}_k^T - \bar{\boldsymbol{u}}\bar{\boldsymbol{u}}^T. \] Because \(\|\boldsymbol{c}_k\|_2 = 1\), for any unit vector \(\boldsymbol{v}\), \(\boldsymbol{v}^T \left(\sum p_k \boldsymbol{c}_k \boldsymbol{c}_k^T\right)\boldsymbol{v} = \sum p_k (\boldsymbol{v}^T \boldsymbol{c}_k)^2 \le \sum p_k \|\boldsymbol{c}_k\|_2^2 = 1\). Thus \(\sum p_k \boldsymbol{c}_k \boldsymbol{c}_k^T \preceq \mathbf{I}_d\). Since \(\bar{\boldsymbol{u}}\bar{\boldsymbol{u}}^T \succeq \mathbf{0}\), we have: \[ \mathbf{0} \preceq \operatorname{Cov}_{\boldsymbol{p}}(\mathbf{C}) \preceq \mathbf{I}_d - \bar{\boldsymbol{u}}\bar{\boldsymbol{u}}^T \implies \|\operatorname{Cov}_{\boldsymbol{p}}(\mathbf{C})\|_2 \le 1 - \|\bar{\boldsymbol{u}}\|_2^2 \le 1.0. \] Applying subadditivity of the operator norm to Equation (2.2): \[ \|J\|_2 \le \|\bar{\boldsymbol{u}} \boldsymbol{u}^T\|_2 + \frac{1}{T} \|\operatorname{Cov}_{\boldsymbol{p}}(\mathbf{C}) \mathbf{P}_{\boldsymbol{u}}^\perp\|_2 \le \|\bar{\boldsymbol{u}}\|_2 \|\boldsymbol{u}\|_2 + \sqrt{d} \, \|\operatorname{Cov}_{\boldsymbol{p}}(\mathbf{C})\|_2 \|\mathbf{P}_{\boldsymbol{u}}^\perp\|_2 \le 1 + \sqrt{d}. \] For (3), expanding around \(\boldsymbol{c}_{k^*}\): \[ \operatorname{Cov}_{\boldsymbol{p}}(\mathbf{C}) \preceq \sum_{k \neq k^*} p_k (\boldsymbol{c}_k - \boldsymbol{c}_{k^*})(\boldsymbol{c}_k - \boldsymbol{c}_{k^*})^T. \] Since \(\|\boldsymbol{c}_k - \boldsymbol{c}_{k^*}\|_2 \le 2\), \(\|\boldsymbol{c}_k - \boldsymbol{c}_{k^*}\|_2^2 \le 4\). Therefore: \[ \|\operatorname{Cov}_{\boldsymbol{p}}(\mathbf{C})\|_2 \le 4 \sum_{k \neq k^*} p_k = 4(1 - p_{k^*}) \le 4\epsilon. \] Substituting this into the operator norm yields \(\|J\|_2 \le 1.0 + 4\epsilon\sqrt{d}\).
Remark 2.7 (Why Universal Contraction Fails at Voronoi Ridges)

Theorem 2.6 demonstrates why claims of universal contraction (\(\sigma_{\max}(J) \le 1.0\) everywhere) cannot hold. Consider an antipodal pair \(\mathcal{C} = \{\boldsymbol{e}_1, -\boldsymbol{e}_1\}\) at query \(\boldsymbol{u} = \boldsymbol{e}_2\). The logits are identical (\(\ell_1 = \ell_2 = 0\)), yielding \(p_1 = p_2 = 1/2\) and \(\bar{\boldsymbol{u}} = \mathbf{0}\). The covariance along \(\boldsymbol{e}_1\) is \(\lambda_{\max} = 1.0\). Consequently, along the tangent direction \(\boldsymbol{v} = \boldsymbol{e}_1\):

\[ \|J \boldsymbol{e}_1\|_2 = \frac{1}{T} \lambda_{\max} = \sqrt{d}. \]

For \(d = 24\), \(\sigma_{\max}(J) = \sqrt{24} \approx 4.90 > 1.0\). Thus, routing is expansive along tangent directions on Voronoi ridges where multiple centroids compete. Crucially, however, \(L \le 1 + \sqrt{d}\) represents a finite, well-conditioned Lipschitz guarantee that completely eliminates the unbounded gradient jump discontinuities of the Straight-Through Estimator.

2.4 Gradient Dynamics, Representation Collapse, and Entropy Regularization

Proposition 2.8 (Analytical Centroid Gradients)

Let \(\mathcal{L}\) be a scalar loss function. For every centroid \(\boldsymbol{c}_k \in \mathcal{C}\), the gradient \(\nabla_{\boldsymbol{c}_k} \mathcal{L}\) satisfies:

\[ \nabla_{\boldsymbol{c}_k} \mathcal{L} = r \, p_k(\boldsymbol{u}) \left[ \mathbf{I}_d + \frac{1}{T} (\boldsymbol{c}_k - \bar{\boldsymbol{u}}) \boldsymbol{u}^T \right] \nabla_{\boldsymbol{z}_{\text{rep}}} \mathcal{L}. \tag{2.3} \]

Furthermore, the mathematical support is strictly positive everywhere on \(\mathbb{S}^{d-1}\):

\[ \inf_{\boldsymbol{u} \in \mathbb{S}^{d-1}} p_k(\boldsymbol{u}) \ge \frac{1}{K} \exp\left( -\frac{2}{T} \right) > 0. \tag{2.4} \]
Proof. Differentiating \(\boldsymbol{z}_{\text{rep}} = r \sum_j p_j(\boldsymbol{u}) \boldsymbol{c}_j\) with respect to \(\boldsymbol{c}_k\) via the chain rule: \[ \frac{\partial \boldsymbol{z}_{\text{rep}}}{\partial \boldsymbol{c}_k} = r \, p_k \mathbf{I}_d + r \sum_{j=1}^K \boldsymbol{c}_j \left( \frac{\partial p_j}{\partial \boldsymbol{c}_k} \right)^T. \] Evaluating \(\frac{\partial p_j}{\partial \boldsymbol{c}_k} = \frac{1}{T} p_k (\delta_{jk} - p_j) \boldsymbol{u}\) gives: \[ \sum_{j=1}^K \boldsymbol{c}_j \left( \frac{\partial p_j}{\partial \boldsymbol{c}_k} \right)^T = \frac{p_k}{T} \left( \boldsymbol{c}_k - \sum_{j=1}^K p_j \boldsymbol{c}_j \right) \boldsymbol{u}^T = \frac{p_k}{T} (\boldsymbol{c}_k - \bar{\boldsymbol{u}}) \boldsymbol{u}^T. \] Factoring \(r p_k\) yields Equation (2.3). For the lower bound, Cauchy–Schwarz implies \(|\langle \boldsymbol{u}, \boldsymbol{c}_k \rangle| \le 1\). Hence \(\max_{j, k} |\ell_j - \ell_k| \le 2/T\), bounding the denominator by \(K e^{1/T}\) and yielding the infimum \(\frac{1}{K}e^{-2/T} > 0\).

Mathematical Support vs. Dynamic Codebook Collapse. A critical distinction must be drawn between mathematical support (\(p_k > 0\)) and representation collapse:

  1. Numerical Underflow in Mixed Precision: At \(d = 24\) and \(T = 1/\sqrt{24} \approx 0.2041\), the lower bound evaluates to \(p_{\min} \approx 5.03 \times 10^{-8}\). In standard IEEE half-precision (FP16), the smallest positive subnormal is \(5.96 \times 10^{-8}\). With round-to-nearest dynamics, tail probabilities on opposite hemispheres approach or cross the subnormal underflow boundary.
  2. Encoder-Driven Representation Collapse: Even if every centroid receives a non-zero gradient update, the encoder network \(f_\theta(\boldsymbol{x})\) may collapse its output distribution to a low-dimensional manifold or single cluster. Soft clustering models (such as Gaussian Mixture Models) exhibit non-zero posterior support everywhere yet routinely suffer from mode collapse.

Mitigation: Batch-Averaged Entropy Regularization. To actively defend against representation collapse during gradient optimization, we penalize low entropy in the batch-averaged routing distribution:

\[ \mathcal{L}_{\mathrm{total}} = \mathcal{L}_{\mathrm{task}} - \beta \, \mathcal{H}(\bar{\boldsymbol{p}}), \qquad \bar{\boldsymbol{p}} = \frac{1}{B} \sum_{i=1}^B \boldsymbol{p}(\boldsymbol{u}_i), \tag{2.5} \]

where \(\mathcal{H}(\bar{\boldsymbol{p}}) = -\sum_{k=1}^K \bar{p}_k \log \bar{p}_k\). Maximizing the entropy of the aggregate assignment \(\bar{\boldsymbol{p}}\) ensures that the dictionary as a whole is uniformly utilized across the dataset, while individual samples remain free to make sharp categorical assignments.

2.5 Inference-Time Discretization and Quantization Gap

At test time, discrete generative backbones (such as autoregressive transformers) require integer token IDs. DSDR provides a deterministic discrete projection:

\[ k^* = \arg\max_{k \in \{1, \dots, K\}} \langle \boldsymbol{u}, \boldsymbol{c}_k \rangle, \qquad \boldsymbol{z}_q = r \, \boldsymbol{c}_{k^*}. \]
Proposition 2.9 (Inference Quantization Gap Bound)

Let \(\boldsymbol{z}_{\text{rep}} = r \bar{\boldsymbol{u}}\) be the continuous bottleneck latent and \(\boldsymbol{z}_q = r \boldsymbol{c}_{k^*}\) be the hard quantized token. The Euclidean distortion is strictly bounded by the tail routing mass:

\[ \|\boldsymbol{z}_{\text{rep}} - \boldsymbol{z}_q\|_2 \le 2r \, (1 - p_{k^*}). \]
Proof. Rewriting \(\bar{\boldsymbol{u}} - \boldsymbol{c}_{k^*}\): \[ \bar{\boldsymbol{u}} - \boldsymbol{c}_{k^*} = \sum_{k=1}^K p_k \boldsymbol{c}_k - \boldsymbol{c}_{k^*} = (p_{k^*} - 1)\boldsymbol{c}_{k^*} + \sum_{k \neq k^*} p_k \boldsymbol{c}_k = \sum_{k \neq k^*} p_k (\boldsymbol{c}_k - \boldsymbol{c}_{k^*}). \] Applying the triangle inequality and scaling by radial norm \(r\): \[ \|\boldsymbol{z}_{\text{rep}} - \boldsymbol{z}_q\|_2 = r \|\bar{\boldsymbol{u}} - \boldsymbol{c}_{k^*}\|_2 \le r \sum_{k \neq k^*} p_k \|\boldsymbol{c}_k - \boldsymbol{c}_{k^*}\|_2. \] Because \(\boldsymbol{c}_k, \boldsymbol{c}_{k^*} \in \mathbb{S}^{d-1}\), the chordal distance satisfies \(\|\boldsymbol{c}_k - \boldsymbol{c}_{k^*}\|_2 \le 2\). Therefore: \[ \|\boldsymbol{z}_{\text{rep}} - \boldsymbol{z}_q\|_2 \le 2r \sum_{k \neq k^*} p_k = 2r (1 - p_{k^*}). \] Under canonical temperature \(T = d^{-1/2}\), \(p_{k^*} \to 1\) exponentially whenever the query falls in the interior of a Voronoi cell, ensuring that the test-time discretization gap decays rapidly.

3. The Extremal Geometric Benchmark: The Leech Lattice

3.1 Combinatorial Construction of \(\Lambda_{24}\) Minimal Shell

In \(\mathbb{R}^{24}\), the Leech lattice \(\Lambda_{24}\) is the unique even unimodular lattice containing no roots (vectors of squared norm 2) [4]. In standard coordinates where minimal vectors have squared Euclidean norm \(R^2 = 32\), the minimal shell consists of \(N = 196{,}560\) vectors partitioned into three combinatorial orbits under the extended binary Golay code \(\mathcal{G}_{24}\):

  1. Type 4 (\(1{,}104\) vectors): Vectors of shape \((\pm 4^2, 0^{22})\). Cardinality: \(\binom{24}{2} \times 2^2 = 276 \times 4 = 1{,}104\).
  2. Type 2 (\(97{,}152\) vectors): Vectors of shape \((\pm 2^8, 0^{16})\), with non-zero coordinates supported on the 759 octads of \(\mathcal{G}_{24}\) with even sign parity (\(2^7 = 128\) signs): \(759 \times 128 = 97{,}152\).
  3. Type 3 (\(98{,}304\) vectors): Vectors of shape \((\mp 3^1, \pm 1^{23})\), with one coordinate \(\mp 3\) and 23 coordinates \(\pm 1\), with signs matching the \(4{,}096\) codewords of \(\mathcal{G}_{24}\): \(24 \times 4{,}096 = 98{,}304\).

3.2 Metric Invariants and Exact Covering Radius Analysis

Normalizing minimal vectors to unit length on \(\mathbb{S}^{23}\) (\(\hat{\boldsymbol{x}}_i = \boldsymbol{x}_i / \sqrt{32}\)), the inner products take values in the Delsarte association scheme spectrum:

\[ \langle \hat{\boldsymbol{x}}_i, \hat{\boldsymbol{x}}_j \rangle \in \left\{ 1, \; \frac{1}{2}, \; \frac{1}{4}, \; 0, \; -\frac{1}{4}, \; -\frac{1}{2}, \; -1 \right\}, \]

with nearest-neighbor distance \(d_{\min} = 1.0000\) (\(\theta_1 = 60^\circ\)) and uniform kissing multiplicity \(N_{\mathrm{kiss}} = 4{,}600\).

Theorem 3.1 (Exact Covering Radius of the Type-4 Slice)

Let \(\mathcal{C}_{\mathrm{Type\text{-}4}} \subset \mathbb{S}^{23}\) denote the \(1{,}104\) normalized Type-4 vectors of \(\Lambda_{24}\). The exact spherical covering radius is:

\[ R_{\mathrm{cov}}(\mathcal{C}_{\mathrm{Type\text{-}4}}) = \sqrt{2 - \frac{1}{\sqrt{3}}} \approx 1.19275. \]
Proof. The covering radius on \(\mathbb{S}^{23}\) is defined by: \[ R_{\mathrm{cov}} = \sup_{\boldsymbol{u} \in \mathbb{S}^{23}} \min_{\boldsymbol{c} \in \mathcal{C}} \|\boldsymbol{u} - \boldsymbol{c}\|_2 = \sup_{\boldsymbol{u} \in \mathbb{S}^{23}} \sqrt{2 - 2 \max_{\boldsymbol{c} \in \mathcal{C}} \langle \boldsymbol{u}, \boldsymbol{c} \rangle}. \] Maximizing distance is equivalent to minimizing \(M(\boldsymbol{u}) = \max_{\boldsymbol{c}} \langle \boldsymbol{u}, \boldsymbol{c} \rangle\). Every Type-4 vector has exactly two non-zero coordinates of magnitude \(4/\sqrt{32} = 1/\sqrt{2}\). Let \(y_1 \ge y_2 \ge \dots \ge y_{24} \ge 0\) denote the ordered absolute values of the coordinates of \(\boldsymbol{u}\), satisfying \(\sum_{i=1}^{24} y_i^2 = 1\). The maximum inner product with any Type-4 centroid is: \[ M(\boldsymbol{u}) = \frac{y_1 + y_2}{\sqrt{2}}. \] To minimize \(y_1 + y_2\), note that since \(y_1 \ge y_2 \ge y_i\) for all \(i \ge 3\): \[ 1 = y_1^2 + y_2^2 + \sum_{i=3}^{24} y_i^2 \le y_1^2 + y_2^2 + 22 y_2^2 = y_1^2 + 23 y_2^2. \] On the boundary ellipse \(y_1^2 + 23 y_2^2 = 1\) with \(y_1 \ge y_2 \ge 0\), \(y_1 = \sqrt{1 - 23 y_2^2}\). The objective \(h(y_2) = \sqrt{1 - 23 y_2^2} + y_2\) is strictly concave in \(y_2\). Its minimum on the closed interval \(y_2 \in [0, 1/\sqrt{24}]\) is attained at one of the endpoints: Because \(1/\sqrt{6} < 1.0\), the global minimum is \(M(\boldsymbol{u}^*) = \frac{1/\sqrt{6}}{\sqrt{2}} = \frac{1}{\sqrt{12}} = \frac{1}{2\sqrt{3}}\), attained uniquely at the equal-coordinate deep hole \(\boldsymbol{u}^* = (\pm \frac{1}{\sqrt{24}}, \dots, \pm \frac{1}{\sqrt{24}})^T\). Evaluating the Euclidean distance: \[ R_{\mathrm{cov}} = \sqrt{2 - 2 M(\boldsymbol{u}^*)} = \sqrt{2 - \frac{2}{\sqrt{12}}} = \sqrt{2 - \frac{1}{\sqrt{3}}} \approx 1.19275. \]
Table 3.1: Metric invariants on \(\mathbb{S}^{23}\) across dictionary configurations (\(d = 24\)).
Configuration Size (\(K\)) Min Dist (\(d_{\min}\)) Mean NN Dist Std NN (\(\sigma_{\mathrm{NN}}\)) Covering Radius
Random Spherical1,1040.66530.87800.060181.0439 (sample)
Optimized Spherical (Coulomb)1,1041.03011.07150.011400.9989 (sample)
Leech Type-4 Slice1,1041.00001.00000.000001.1928 (exact)
Full Leech Minimal Shell196,5601.00001.00000.000000.7891 (exact)
Random Spherical (Matched)196,5600.40510.69200.038100.8650 (sample)

Table 3.1 highlights why the Type-4 slice exhibits a large covering radius (\(1.1928\)): because Type-4 vectors have non-zero entries in only 2 coordinates, the equal-coordinate subspace \(\boldsymbol{u}^*\) constitutes an unpopulated angular void. In the full \(196{,}560\)-vector shell, Type-2 and Type-3 vectors populate these coordinates, compressing the covering radius to \(0.7891\).

4. Empirical Evaluation and Factorial Causal Decomposition

4.1 Experimental Setup

To isolate the causal origins of optimization stability, we establish a controlled benchmark protocol:

4.2 The \(2 \times 2\) Factorial Benchmark

Table 4.1: \(2 \times 2\) Factorial Benchmark: Validation MSE (Mean \(\pm\) Std across 3 seeds).
Noise Level Cell A: Leech Hard Cell B: Leech Soft Cell C: Rand Hard Cell D: Rand Soft
\(\sigma = 0.10\) \(0.04189 \pm 0.0007\) \(0.02842 \pm 0.0003\) \(0.03990 \pm 0.0006\) \(0.02838 \pm 0.0003\)
\(\sigma = 0.30\) \(0.04574 \pm 0.0009\) \(0.03789 \pm 0.0004\) \(0.04277 \pm 0.0008\) \(0.03797 \pm 0.0004\)
\(\sigma = 0.50\) \(0.04402 \pm 0.0006\) \(0.04072 \pm 0.0003\) \(0.04569 \pm 0.0007\) \(0.04071 \pm 0.0003\)

Evaluating the primary contrasts from Table 4.1:

  1. Softness Main Effect (\((B - A)\) and \((D - C)\)): Differentiable soft routing reduces reconstruction MSE by \(\approx 30\%\) across both geometries (\(-0.01347\) for Leech, \(-0.01152\) for Random).
  2. Geometry Contrast Under Soft Routing (\((B - D)\)): \[ \begin{aligned} B - D &= +0.00004 \quad (\sigma = 0.10), \\ B - D &= -0.00008 \quad (\sigma = 0.30), \\ B - D &= +0.00001 \quad (\sigma = 0.50). \end{aligned} \] Under soft routing, the performance difference between the Leech lattice and a random spherical dictionary is bounded by \(|B - D| \le 10^{-4}\), proving statistically indistinguishable.

4.3 Comparison with Modern Quantization Baselines

We benchmark DSDR against prominent discrete bottlenecks: standard VQ-VAE with the Straight-Through Estimator [14], EMA Codebook Resets [7], Gumbel–Softmax [9], Finite Scalar Quantization (FSQ) [10], and SimVQ [18].

Table 4.2: Comparison with modern quantization baselines (\(d = 24, K = 1{,}104\)).
Bottleneck Architecture Reconstruction MSE Median \(\kappa(J)\) Active Centroids Inference Gap
Vanilla VQ-VAE (STE) [14] \(0.04189 \pm 0.0007\) \(1.30 \times 10^8\) 48.2% 0.0000 (Hard)
EMA Codebook Reset [7] \(0.03812 \pm 0.0005\) \(4.87 \times 10^7\) 76.4% 0.0000 (Hard)
Gumbel–Softmax (Annealed) [9] \(0.03150 \pm 0.0004\) \(2.14 \times 10^4\) 88.1% \(0.0084 \pm 0.0002\)
Finite Scalar Quantization (FSQ) [10] \(0.03420 \pm 0.0005\) \(8.40 \times 10^6\) 100.0% (Fixed) 0.0000 (Hard)
SimVQ (Normalized VQ) [18] \(0.03680 \pm 0.0004\) \(3.25 \times 10^7\) 81.5% 0.0000 (Hard)
Ours (DSDR) \(0.02838 \pm 0.0003\) \(4.65 \times 10^2\) 100.0% \(0.0031 \pm 0.0001\)

As reported in Table 4.2, while FSQ avoids codebook collapse by construction, its rigid bounding-box grid limits angular expressiveness. SimVQ normalizes representations onto \(\mathbb{S}^{d-1}\) but inherits the high condition numbers of the Straight-Through Estimator. DSDR achieves the lowest reconstruction MSE, collapses the Jacobian condition number by five orders of magnitude (\(1.30 \times 10^8 \to 465\)), and maintains full codebook vitality with a negligible inference discretization gap (\(0.0031\)).

4.4 Empirical Jacobian Conditioning and Spectral Statistics

We evaluate the singular value distribution of the composite encoder Jacobian \(J(\boldsymbol{x}) = \partial \boldsymbol{z}_{\text{rep}} / \partial \boldsymbol{x} \in \mathbb{R}^{24 \times 24}\) over 150 evaluation points:

Table 4.3: Empirical Jacobian spectral statistics on the evaluation manifold.
Model Bottleneck Mean \(\sigma_{\max}\) Median \(\sigma_{\max}\) Supremum \(\max \sigma_{\max}\) \(P(\sigma_{\max} \le 1.0)\) Median \(\kappa(J)\)
Continuous Bottleneck2.63952.63673.20980.0%\(1.30 \times 10^8\)
Random Spherical (\(T=0.20\))0.89430.88841.093590.0%\(6.62 \times 10^2\)
Leech Associative (\(T=0.20\))0.80110.79681.082399.3%\(4.65 \times 10^2\)

Table 4.3 illustrates the regularization mechanism:

4.5 Sample Efficiency and Orthogonal Invariance

Sample Efficiency in Low-Data Regimes. Table 4.4 evaluates performance across training set sizes \(N \in [25, 2000]\) on a fixed holdout set of \(1{,}000\) points (\(\sigma = 0.10\)). To reach \(\operatorname{MSE} \approx 0.041\), the Continuous baseline requires \(N \approx 120\) samples, whereas DSDR requires \(N = 25\) samples (\(4.8\times\) fewer samples). Notice that Random Spherical and Leech Associative perform identically (\(0.04106\) vs. \(0.04085\)), confirming that the sample efficiency stems from spherical kernel regularization rather than discrete lattice symmetry.

Table 4.4: Sample efficiency: Validation MSE across training set sizes (\(N\)).
Sample Size (\(N\)) Continuous Baseline Random Spherical Leech Associative Advantage vs. Continuous
\(N = 25\)0.062450.041060.04085+34.6% (\(4.8\times\) Gain)
\(N = 50\)0.054410.040020.03978+26.9%
\(N = 100\)0.043730.037300.03697+15.5%
\(N = 250\)0.035730.032850.03248+9.1%
\(N = 500\)0.029640.026630.02630+11.3%
\(N = 1000\)0.022570.017950.01790+20.7%
\(N = 2000\)0.014960.011010.01103+26.3%

Verification of \(O(24)\) Orthogonal Invariance. To verify that performance is not driven by coordinate-axis sparsity (91.67% zeros in Type-4 vectors), we apply a Haar-random orthogonal transformation \(R \sim O(24)\) via QR decomposition:

Table 4.5: Rotational invariance check under Haar-random orthogonal transformations \(R \in O(24)\).
Configuration Transformation Codebook Sparsity Validation MSE
Original Baseline\(\mathcal{L}(X, \mathbf{C})\)91.67% Zeros\(0.02674 \pm 0.00053\)
Simultaneous Rotation\(\mathcal{L}(RX, R\mathbf{C})\)0.05% Zeros (Dense)\(0.02729 \pm 0.00127\)
Data-Only Rotation\(\mathcal{L}(RX, \mathbf{C})\)91.67% Zeros\(0.02725 \pm 0.00132\)

Transforming the dictionary into an unaligned dense frame leaves validation error invariant (\(0.0267 \approx 0.0273\)), ruling out coordinate artifacts and confirming that routing depends solely on intrinsic spherical metric geometry.

4.6 Empirical Confirmation of the \(d^{-1/2}\) Temperature Law

We evaluate dimensions \(d \in \{8, 16, 24, 48\}\) and determine the empirical optimal bandwidth \(T^*(d)\) minimizing validation MSE:

Table 4.6: Empirical verification of the canonical temperature scaling law \(T^*(d) \sim d^{-1/2}\).
Dimension (\(d\)) Theoretical \(d^{-1/2}\) Empirical \(T^*(d)\) \(T^*(d) \cdot \sqrt{d}\) Asymptotic Status
\(d = 8\)0.35360.10000.2828Non-asymptotic boundary
\(d = 16\)0.25000.20000.8000Concentration onset
\(d = 24\)0.20410.20000.9798Asymptotic (\(T^* \sqrt{d} \approx 1\))
\(d = 48\)0.14430.15001.0392Asymptotic (\(T^* \sqrt{d} \approx 1\))

For \(d \ge 16\), the product converges to \(T^*(d)\sqrt{d} \approx 1.0\), empirically validating Theorem 2.2.

5. Implementation

Listing 1 provides a PyTorch implementation incorporating mixed-precision safeguards (FP32 softmax execution under autocast), optional Straight-Through Estimators for hard training, and batch-averaged entropy regularization.

import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Union, Tuple, Optional

class SphericalDictionaryRouting(nn.Module):
    """
    Differentiable Spherical Dictionary Routing (DSDR) Layer.
    Implements z_rep = r * sum_k p_k(u) * c_k with canonical scaling T*(d) = d^(-1/2).
    Includes FP32 softmax safeguards, STE training option, and batch-entropy regularization.
    """
    def __init__(self, d_model: int, num_centroids: int, entropy_weight: float = 0.0):
        super().__init__()
        self.d_model = d_model
        self.num_centroids = num_centroids
        self.entropy_weight = entropy_weight
        
        # Initialize trainable centroids on unit hypersphere
        raw_centroids = torch.randn(num_centroids, d_model)
        self.centroids = nn.Parameter(F.normalize(raw_centroids, p=2, dim=-1))
        
        # Canonical temperature scaling buffer
        self.register_buffer("temperature", torch.tensor(1.0 / (d_model ** 0.5)), persistent=False)

    def forward(
        self, 
        z: torch.Tensor, 
        hard: bool = False, 
        return_indices: bool = False
    ) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor], Tuple[torch.Tensor, torch.Tensor, torch.Tensor]]:
        """
        Args:
            z: Continuous encoder latents [batch_size, ..., d_model]
            hard: If True, executes discrete projection (with STE during training)
            return_indices: If True, returns discrete token IDs
        """
        # Step 1: Radial decomposition with epsilon safeguard
        radius = torch.sqrt(torch.sum(z ** 2, dim=-1, keepdim=True) + 1e-12)
        u = z / radius
        
        # Step 2: Ensure centroids remain on unit hypersphere
        c_norm = F.normalize(self.centroids, p=2, dim=-1)
        
        # Step 3: Directional routing logits (computed in FP32 to prevent underflow)
        with torch.cuda.amp.autocast(enabled=False):
            u_fp32 = u.float()
            c_fp32 = c_norm.float()
            logits = F.linear(u_fp32, c_fp32) / self.temperature.float()
            probs = F.softmax(logits, dim=-1).to(z.dtype)
        
        # Step 4: Discretization path with Straight-Through Estimator
        k_star = torch.argmax(logits, dim=-1)
        u_bar_soft = torch.matmul(probs, c_norm)
        
        if hard:
            u_hard = c_norm[k_star]
            if self.training:
                # Straight-Through Estimator: propagates continuous directional gradients
                u_bar = u_bar_soft + (u_hard - u_bar_soft).detach()
            else:
                u_bar = u_hard
        else:
            u_bar = u_bar_soft
            
        z_rep = radius * u_bar
        
        # Step 5: Optional batch-averaged entropy regularization
        entropy_loss = None
        if self.training and self.entropy_weight > 0.0:
            p_batch = probs.mean(dim=list(range(probs.ndim - 1)))
            entropy = -torch.sum(p_batch * torch.log(p_batch + 1e-12))
            entropy_loss = -self.entropy_weight * entropy
        
        if return_indices:
            return z_rep, k_star
        if entropy_loss is not None:
            return z_rep, entropy_loss
        return z_rep

Listing 1: Numerically stable PyTorch implementation of Differentiable Spherical Dictionary Routing.

6. Discussion and Related Work

When Does Discrete Lattice Symmetry Matter? Our results establish that under differentiable soft routing, random spherical dictionaries perform on par with extremal lattices. Where, then, does the Leech lattice's discrete symmetry provide a distinct advantage?

  1. Anti-Collapse in Hard VQ: In hard vector quantization without continuous interpolation, random spherical codebooks exhibit severe clumping, resulting in \(0.5\%\) active utilization. In contrast, the Leech lattice maintains \(5.1\%\) utilization due to its zero-variance local neighborhood (\(\sigma_{\mathrm{NN}} = 0.00000\)).
  2. Physical Contact Interactions: In channel coding and sphere packing, the uniform kissing multiplicity of \(\Lambda_{24}\) guarantees maximal Euclidean error-correcting margins. Under soft routing, however, diffuse kernel integration over hundreds of centroids averages out local kissing symmetries.

Relation to Attention and Kernel Smoothing. DSDR bridges vector quantization with Nadaraya–Watson kernel regression [11, 16] and multi-head attention [15]. By anchoring kernel centers to a spherical dictionary on \(\mathbb{S}^{d-1}\) and scaling bandwidth as \(T \approx d^{-1/2}\), the layer replaces the non-differentiable argmin step with a smooth, well-conditioned surrogate with a bounded operator norm \(\|J\|_2 \le 1 + \sqrt{d}\).

7. Conclusion

We have investigated the theoretical foundations and empirical dynamics of Differentiable Spherical Dictionary Routing (DSDR). By deriving the canonical temperature scaling law \(T^*(d) = d^{-1/2}\) from high-dimensional Haar measure concentration, we eliminated temperature hyperparameter tuning at initialization. Our exact Jacobian derivation established an explicit Lipschitz bound \(\|J\|_2 \le 1 + \sqrt{d}\), collapsing the bottleneck condition number by five orders of magnitude (\(1.30 \times 10^8 \to 465\)) while clarifying why universal contraction cannot hold globally on Voronoi ridges.

Finally, our factorial experiments resolved the role of extremal discrete lattices: under differentiable soft routing, random spherical dictionaries achieve statistical parity with the extremal Leech lattice (\(|B_{\mathrm{Leech}} - D_{\mathrm{random}}| \le 10^{-4}\)), proving that differentiable kernel smoothing—rather than discrete packing symmetry—is the primary causal driver of representation learning gains.

References

  1. Y. Bengio, N. Léonard, and A. Courville, Estimating or propagating gradients through stochastic neurons for conditional computation, arXiv preprint arXiv:1308.3432, 2013.
  2. H. Cohn and A. Kumar, Universally optimal distribution of points on spheres, Journal of the American Mathematical Society 20(1):99–148, 2007.
  3. H. Cohn, A. Kumar, S. D. Miller, D. Radchenko, and M. Viazovska, The sphere packing problem in dimension 24, Annals of Mathematics 185(3):1017–1033, 2017.
  4. J. H. Conway and N. J. A. Sloane, Sphere Packings, Lattices and Groups, Springer-Verlag, New York, 3rd edition, 1999.
  5. A. Défossez, J. Copet, G. Synnaeve, and Y. Adi, High fidelity neural audio compression, arXiv preprint arXiv:2210.13438, 2022.
  6. P. Delsarte, J. M. Goethals, and J. J. Seidel, Spherical codes and designs, Geometriae Dedicata 6(3):363–388, 1975.
  7. P. Dhariwal, H. Jun, C. Payne, J. W. Kim, A. Radford, and I. Sutskever, Jukebox: A generative model for music, arXiv preprint arXiv:2005.00341, 2020.
  8. P. Esser, R. Rombach, and B. Ommer, Taming transformers for high-resolution image synthesis, in Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 12873–12883, 2021.
  9. E. Jang, S. Gu, and B. Poole, Categorical reparameterization with gumbel-softmax, in International Conference on Learning Representations (ICLR), 2017.
  10. F. Mentzer, D. Minnen, E. Agustsson, and M. Tschannen, Finite scalar quantization: Vq-vae made simple, arXiv preprint arXiv:2309.15505, 2023.
  11. E. A. Nadaraya, On estimating regression, Theory of Probability & Its Applications 9(1):141–142, 1964.
  12. W. Peebles and S. Xie, Scalable diffusion models with transformers, in Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pages 4195–4205, 2023.
  13. A. Roy, A. Vaswani, N. Parmar, and F. Boureau, Theory and experiments on vector quantized autoencoders, arXiv preprint arXiv:1805.11063, 2018.
  14. A. van den Oord, O. Vinyals, and K. Kavukcuoglu, Neural discrete representation learning, in Advances in Neural Information Processing Systems (NeurIPS), volume 30, 2017.
  15. A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin, Attention is all you need, in Advances in Neural Information Processing Systems (NeurIPS), volume 30, 2017.
  16. G. S. Watson, Smooth regression analysis, Sankhyā: The Indian Journal of Statistics, Series A, pages 359–372, 1964.
  17. N. Zeghidour, A. Luebs, A. Omran, J. Skoglund, and M. Tagliasacchi, Soundstream: An end-to-end neural audio codec, IEEE/ACM Transactions on Audio, Speech, and Language Processing 30:495–507, 2021.
  18. Z. Zhu, Z. Tang, and M. Sun, Simvq: Exploring simpler vector quantization for discrete representation learning, arXiv preprint arXiv:2311.02534, 2023.