---
title: 'JHCodec: Generalized Ray Tracing Sampler'
url: https://www.emergentmind.com/topics/jhcodec
type: topic
---

# JHCodec: Generalized Ray Tracing Sampler

Below is a focused technical summary of the paper’s **generalized ray tracing framework** for sampling.

---

## 1. Core idea: sampling by tracing rays in parameter space

The paper’s central idea is to reinterpret MCMC sampling geometrically:

- The parameter vector \(x\in \mathbb{R}^D\) is a point in a \(D\)-dimensional “optical medium.”
- The target density is represented by an unnormalized likelihood \(\mathcal{L}(x)\).
- One evolves trajectories not as particles under forces, but as **light rays** traveling through a medium whose **refractive index** depends on \(\mathcal{L}(x)\).

The key design principle is to choose the refractive index so that the geometric concentration of rays in space exactly matches the target density. The paper argues that in \(D\) dimensions, optical refraction changes ray density by powers of \(n^{D-1}\), so fair sampling is obtained with

\[
n(x) = \mathcal{L}(x)^{\frac{1}{D-1}}.
\]

This is the basic ray tracing sampler. But the paper goes further: by allowing arbitrary sample weights \(W(x)\) and/or variable speed \(v(x)\), the method becomes a **generalized framework** that includes several existing samplers as special cases.

So the contribution is not just “a new sampler”; it is a unifying geometric formalism in which many local MCMC methods correspond to different choices of:
- path geometry,
- refractive index \(n(x)\),
- speed \(v(x)\),
- and sample weight \(W(x)\).

---

## 2. Optical invariants that make the method work

### 2.1 Basic radiance

The paper derives that, in \(D\) dimensions, for refraction without reflection, the conserved optical quantity is

\[
R \equiv n^{1-D} L = \mathrm{constant},
\]

where \(L\) is the radiance, interpreted here as the **geometric density of ray paths**, i.e. the sampling density in position/direction space.

This is derived from power conservation across an interface plus Snell’s law. For incoming/outgoing bundles at indices \(n_1,n_2\),

\[
L_1 \cos(\theta_1)d\theta_1 \sin^{D-2}(\theta_1)
=
L_2 \cos(\theta_2)d\theta_2 \sin^{D-2}(\theta_2),
\]

and with differential Snell relations

\[
\frac{\sin(\theta_2)}{\sin(\theta_1)}
=
\frac{\cos(\theta_2)d\theta_2}{\cos(\theta_1)d\theta_1}
=
\frac{n_1}{n_2},
\]

one gets

\[
\frac{L_1}{L_2}
=
\left(\frac{n_1}{n_2}\right)^{D-1}.
\]

Hence \(Ln^{1-D}\) is invariant.

### 2.2 Etendue

The paper also defines the conserved \(D\)-dimensional optical phase-space quantity (analog of Liouville volume in Hamiltonian mechanics) as

\[
d^2G \equiv n^{D-1} dA \cos \theta \, d\Omega.
\]

This is the generalized **etendue**. Conservation of etendue explains how cross-sectional area and solid angle transform under ray propagation. The consequence for sampling is that the ray-bundle phase-space volume is compressed by a factor \(n^{D-1}\).

---

## 3. Fair sampling from likelihood via refractive index

The basic fair-sampling construction is:

\[
n(x) = \mathcal{L}(x)^\frac{1}{D-1}.
\]

Because radiance transforms as \(L \propto n^{D-1}\), this makes

\[
L(x) \propto \mathcal{L}(x).
\]

So the geometric density of ray paths is directly proportional to the target likelihood. This is the stationarity mechanism.

The paper gives a local detailed-balance style derivation: emit rays isotropically from a differential volume around \(x\) with intensity proportional to \(\mathcal{L}(x)\),

\[
\frac{d^3 P_x}{d A_x ds d\Omega_x} = C \mathcal{L}(x),
\]

with \(C\) independent of position and direction. Using conservation of etendue between \(x\) and \(\mathbf{y}\), one gets that the power density arriving at \(\mathbf{y}\) is

\[
\frac{d^3 P_x}{d A_\mathbf{y} ds d\Omega_\mathbf{y}}
=
C \frac{n(\mathbf{y})^{D-1}}{n(x)^{D-1}} \mathcal{L}(x)
=
C \mathcal{L}(\mathbf{y}),
\]

for the choice \(n^{D-1}=\mathcal{L}\). Because ray paths are reversible, forward and reverse transitions satisfy detailed balance.

### Resulting stationary distribution

For the unweighted constant-speed ray tracer, the stationary sampling density in parameter space is proportional to

\[
\pi(x) \propto \mathcal{L}(x).
\]

In the generalized weighted case, the samples may carry nonuniform weights \(W(x)\), but the effective weighted stationary measure remains the desired target \(\mathcal{L}(x)\).

---

## 4. Ray dynamics: constant-speed propagation

The standard ray equation used is

\[
\frac{d}{ds}\left(n(x)\frac{dx}{ds}\right) = \nabla_x n(x),
\]

where \(s\) is path length. Rewriting yields the evolution of the unit direction vector:

\[
\frac{d}{ds}\left(\frac{dx}{ds}\right)
=
\nabla_x \ln(n(x))
-
\left(\frac{dx}{ds}\cdot \nabla_x \ln(n(x))\right)\frac{dx}{ds}.
\]

This is important:
- only the gradient of \(\ln n\) matters,
- only the component of \(\nabla \ln n\) perpendicular to the direction of motion bends the ray.

If \(\theta\) is the angle between the direction of travel and \(\nabla \ln n\), then

\[
\frac{d\theta}{ds} = -\sin\theta |\nabla_x \ln(n(x))|.
\]

The paper integrates this exactly over one kick step to maintain reversibility:

\[
\tan\left(\frac{\theta_f}{2}\right)
=
\tan\left(\frac{\theta_i}{2}\right)
\exp(-\Delta s |\nabla_x\ln(n(x))|).
\]

### Constant speed vs HMC

This is the paper’s main dynamical distinction from HMC.

- **Ray tracing:** rays move at **constant speed through parameter space**; the likelihood only bends the trajectory.
- **HMC:** a particle accelerates/decelerates under the potential \(U(x)=-\ln \mathcal{L}(x)\); both direction and speed change because kinetic and potential energy exchange.

The paper emphasizes that constant speed means stochastic gradient errors perturb only the **direction**, not the kinetic energy. That is the basis for its robustness claims.

---

## 5. Acceptance rule and exactness with imperfect integrators

For an imperfect numerical integrator, the path will not preserve basic radiance exactly. The paper derives a local radiance boost for a direction update \(\Delta \theta\):

\[
\frac{L_{i+1}}{L_i}
=
\left(\frac{\sin(\theta)}{\sin(\theta+\Delta \theta)}\right)^{D-1}.
\]

Accumulating this over a trajectory yields a predicted ratio \(L(\mathbf{y})/L(x)\). Then the Metropolis-like correction is

\[
P(x\rightarrow\mathbf{y})
=
\min\left(1, \frac{\mathcal{L}(\mathbf{y})L(x)}{\mathcal{L}(x)L(\mathbf{y})}\right).
\]

In the generalized weighted framework, this becomes

\[
P(x\rightarrow\mathbf{y})
=
\min\left(1, \frac{n(x)^{1-D}L(x)}{n(\mathbf{y})^{1-D}L(\mathbf{y})}\right).
\]

This is exactly the inverse ratio of excess basic radiance at the endpoint, and it restores exact sampling provided:
1. the path map is reversible,
2. the Metropolis correction is applied,
3. the chain is ergodic.

---

## 6. Generalized ray tracing with weights and variable speed

The framework is generalized by allowing explicit sample weights \(W(x)\) and path speed \(v(x)\).

The paper states that the effective sample density scales as

\[
\frac{L(x) W(x)}{v(x)}.
\]

To preserve fair sampling, this must equal the target likelihood:

\[
\frac{L(x)W(x)}{v(x)} = \mathcal{L}(x).
\]

Since \(L \propto n^{D-1}\), one obtains the generalized refractive index

\[
n(x) =
\left(\frac{\mathcal{L}(x) v(x)}{W(x)}\right)^{\frac{1}{D-1}}.
\]

This is the master equation of the generalized framework.

Interpretation:
- changing \(n(x)\) changes **path geometry**,
- changing \(v(x)\) changes how much time is spent along the path,
- changing \(W(x)\) changes the weight assigned to visited points.

This separation is what lets the framework subsume HMC, microcanonical HMC, Gibbs, Metropolis, Monte Carlo integration, and tempered variants.

---

## 7. Ergodicity, scattering, barriers, and holes

### Ergodicity
Ray propagation by itself is deterministic given initial direction. To guarantee exploration, the direction must be refreshed. The paper proposes periodic full or partial momentum refreshes.

### Partial momentum refresh / scattering
A partial refresh is treated as a random rotation of direction, preserving Jacobian. The paper recommends performing it between completed integration steps. If no refresh occurs between Metropolis tests, failed proposals should reverse direction to maintain reversibility.

### Crossing likelihood barriers
A major claim is that ray tracing can cross **arbitrary likelihood barriers**, unlike ordinary HMC at fixed energy.

Why:
- In basic ray tracing, the speed is fixed and only curvature changes.
- There is no fixed energy ceiling preventing access to low-likelihood regions.
- Rays can pass through regions of arbitrarily low likelihood; they are merely refracted according to \(n(x)\).

This is contrasted with HMC, where a fixed total energy forbids entering regions with \(E+\ln \mathcal{L}(x)\le 0\).

### Crossing holes / disallowed regions
The paper further claims ray tracing can cross “holes” or disconnected allowed regions if boundaries are treated as **blackbody radiators**:
- boundaries absorb incoming rays,
- then re-emit them with Lambertian emissivity proportional to \(n^{D-1}\cos\theta\).

This gives a mechanism to move between disconnected components (“parameter space islands”), something standard Hamiltonian integration cannot do.

### Conditions for correct sampling
Correct sampling requires:
1. reversibility of the path integrator,
2. detailed balance via conserved basic radiance or Metropolis correction,
3. ergodicity via direction refresh/scattering,
4. either connected support, or special blackbody-boundary handling for islands.

---

## 8. Why stochastic gradients affect ray tracing differently from HMC

The paper’s main practical claim is **much stronger resilience to stochastic gradients**.

### HMC problem
Stochastic gradients inject energy into the trajectory, causing path heating. In SGHMC, this requires friction/diffusion terms tuned to the noise covariance.

### Ray tracing claim
Because ray tracing keeps path speed fixed, stochastic gradient errors do **not** accumulate as kinetic-energy heating. They mainly perturb direction, which is actually similar to the deliberate scattering needed for ergodicity.

The residual issue is wrong acceptance probabilities due to noisy likelihood estimates, not runaway heating.

The paper proposes a stochastic acceptance correction:

\[
P(x\to\mathbf{y}) =
\min\left(1,
\left(\frac{n(x)^{1-D} L(x)}{n(\mathbf{y})^{1-D} L(\mathbf{y})}\right)^\frac{1}{\sqrt{1+\sigma_\mathrm{sto}^2}}
\right),
\]

where \(\sigma_\mathrm{sto}^2\) is the variance of \(\ln(\mathcal{L}_\mathrm{batch}/\mathcal{L}_\mathrm{true})\).

But the paper also notes that when stochastic likelihood noise dominates integration error, a Metropolis test can become meaningless; then threshold/masking strategies are more useful.

---

## 9. Relationship to prior methods under the generalized framework

This is one of the paper’s most interesting claims: many samplers are recovered by choosing \(n(x)\), \(W(x)\), and \(v(x)\) appropriately.

### 9.1 Hamiltonian Monte Carlo as ray tracing

For HMC with potential \(U(x)=-\ln \mathcal{L}(x)\), and specific kinetic energy \(T=\frac12 |v|^2\), total energy conservation implies

\[
|v(x)| \propto \sqrt{E+\ln \mathcal{L}(x)}.
\]

Geometrically, the transverse component of velocity is conserved across potential jumps:

\[
|v_1|\sin\theta_1 = |v_\perp| = |v_2|\sin\theta_2,
\]

which has Snell-law form. Hence HMC paths are identical to ray paths with

\[
n(x)\propto |v(x)|
\]

and specifically

\[
n(x) \propto |v(x)| \propto \sqrt{E+\ln \mathcal{L}(x)}.
\]

So HMC is a generalized ray-tracing method where:
- refractive index depends on energy through \(\sqrt{E+\ln\mathcal{L}}\),
- speed is not constant,
- sample weighting is effectively inverse velocity.

At low likelihood where \(E+\ln\mathcal{L}(x)=0\), \(n=0\), so HMC has an impassable barrier. This explains geometrically why ordinary HMC cannot cross arbitrary likelihood barriers.

The paper also notes Langevin methods follow because they can be written as single-step HMC.

### 9.2 Microcanonical HMC

The paper identifies microcanonical HMC as the choice

\[
W(x) = \mathcal{L}(x)^{1/D},
\]

which leads to

\[
n(x) = \mathcal{L}(x)^{1/D}.
\]

This is close to standard ray tracing \(n=\mathcal{L}^{1/(D-1)}\) in large \(D\), so the path dynamics are similar asymptotically. The paper’s distinction is that ray tracing decouples speed from likelihood, which improves stochastic-gradient robustness.

### 9.3 Gibbs sampling

In this framework, Gibbs sampling corresponds to

\[
W(x)=\mathcal{L}(x), \qquad n=1.
\]

Since \(n\) is constant:
- rays are straight lines,
- \(\nabla \ln n = 0\),
- the phase-space Jacobian is trivial.

The weights \(\mathcal{L}(x)\) then enforce the conditional distribution along the chosen coordinate/subspace.

### 9.4 Metropolis(-Hastings)

A Metropolis step is described as:
- a **single ray-tracing step**,
- integrated by Euler,
- with \(n=1\),
- \(W(x)=\mathcal{L}(x)\),
- and proposal length \(\Delta s\) drawn from the chosen proposal distribution (often Gaussian).

So again the path is straight, and the usual accept/reject rule is recovered as the weighted-sampling correction.

### 9.5 Monte Carlo integration

Monte Carlo integration appears as a limiting case of Gibbs sampling with masked samples:
- weights are zero everywhere along the path,
- except at ray endpoints / refresh points, where they are \(\mathcal{L}(x)\).

So raw Monte Carlo integration is a degenerate straight-ray weighted sampler.

### 9.6 Goodman–Weare stretch move
The paper also sketches an interpretation of the stretch move:
- \(n=\infty\) outside a narrow cone from target walker to current walker,
- inside the cone, weighting \(W(z)=1/\sqrt{z}\) for \(z\in[1/a,a]\).
This is less central than the other correspondences but supports the unification claim.

---

## 10. Tempering inside the generalized framework

Because path geometry and weighting are separated, one can define a tempered family while still sampling the original target correctly.

For effective temperature \(\tau\), the paper gives

\[
n = \mathcal{L}(x)^\frac{1}{\tau\cdot (D-1)},
\qquad
W = v^{-1} = \mathcal{L}(x)^\frac{\tau-1}{\tau}.
\]

So:
- increasing \(\tau\) flattens the refractive-index landscape,
- low-likelihood regions are traversed faster / with lower weight.

If \(\tau\) depends on \(\ln \mathcal{L}\), then

\[
\nabla_x \ln(n(x)) =
\frac{\nabla_x \ln(\mathcal{L}(x))}{\tau\cdot (D-1)}
\left[
1 - \ln(\mathcal{L}(x))\frac{d\ln(\tau)}{d\ln(\mathcal{L}(x))}
\right].
\]

This preserves alignment with the \(\tau=1\) gradient direction up to a scalar.

---

## 11. Algorithmic implementation

### Inputs
The pseudocode `GRTSample` takes roughly:
- initial point \(x_0\),
- dimension \(D\),
- number of integration steps \(N\),
- path step size \(\Delta s\),
- refresh parameter \(f\),
- target likelihood \(\mathcal{L}(x)\),
- optional weight function \(W(x)\) (default 1).

### Required gradient
Only the gradient of the log refractive index is needed. In the basic weighted constant-speed implementation:

\[
\nabla \ln n = \frac{\nabla \ln (\mathcal{L}(x)/W(x))}{D-1}.
\]

So in practice one needs \(\nabla \ln \mathcal{L}(x)\) (or gradient of loss / log posterior), not the Hessian.

### Update scheme
The pseudocode uses a **drift-kick-drift** leapfrog structure:

1. partial momentum refresh,
2. half drift:
   \[
   x_{k+0.5}=x_k + 0.5\Delta s \cdot v/|v|,
   \]
3. kick using `UpdateV`,
4. another half drift.

The velocity magnitude is irrelevant for the path because only \(v/|v|\) matters in drifting.

### Partial refresh
The direction update is
\[
v \gets e^{-|f|}v + \sqrt{1-e^{-2|f|}}\,v',
\]
with fresh Gaussian \(v'\), i.e. Ornstein–Uhlenbeck-style partial refresh.

### Direction update
Inside `UpdateV`, one computes:
- \(\hat v = v/|v|\),
- \(\hat n = \nabla \ln n / |\nabla \ln n|\),
- initial angle \(\theta_i\),
- final angle \(\theta_f\) via the exact reversible formula.

Then the new velocity is
\[
v \gets f_v v + f_n |v|\hat n,
\]
where
\[
f_v = \frac{\sin(\theta_f)}{\sin(\theta_i)},
\qquad
f_n = \cos(\theta_f)-f_v\cos(\theta_i).
\]

The cumulative radiance change is tracked as
\[
\Delta \ln L \gets \Delta \ln L + (1-D)\ln(f_v).
\]

### Metropolis test
At the end,

\[
\ln(r) > \ln \left(\frac{\mathcal{L}(x_N)W(x_0)}{\mathcal{L}(x_0)W(x_N)}\right)-\Delta\ln L
\]

triggers rejection.

### Numerical integrators
The paper discusses:
- KDK and DKD leapfrog,
- random alternation between KDK and DKD,
- Omelyan second-order,
- Forest–Ruth / Yoshida fourth-order.

It finds Omelyan best over a broad practical range in a 10,000D Gaussian test.

### Complexity
Per integration step:
- one gradient of \(\ln \mathcal{L}\) (or loss) at a midpoint,
- \(O(D)\) vector operations.

So computational cost is similar in order to HMC: dominated by gradient evaluations. The key gain is not lower per-step cost but better behavior under noisy gradients and large-model minibatching.

---

## 12. Practical recommendations for neural networks

### Approximate likelihood from a loss
When no proper probabilistic likelihood is available, the paper proposes

\[
\ln \mathcal{L}(x) \approx -f_\mathrm{loss}(x)\cdot(D_\mathrm{eff}/(2\Delta f_\mathrm{loss})),
\]

where:
- \(f_\mathrm{loss}\) is the training loss,
- \(\Delta f_\mathrm{loss}\) is desired tolerance above optimum,
- \(D_\mathrm{eff}\) is an effective number of constrained parameters.

This is exact for Gaussian targets and suggested as a practical approximation for high-dimensional models.

### Recipe
The paper’s recommended workflow:
1. burn in with low-temperature ray tracing or Adam,
2. choose likelihood scaling / \(D_\mathrm{eff}\),
3. tune step size (start around \(\Delta s\sim 0.03\sqrt D\)),
4. tune refresh rate,
5. run many walkers,
6. assess convergence in **function space**, not necessarily weight space.

### High-dimensional caveats
- Neural-network posteriors in weight space are often filamentary and non-Gaussian.
- Convergence in weight space may be poor or absent even when function-space uncertainty is useful.
- The sampler is not generically separable; if subspaces have very different gradient scales, independent ray dynamics by subspace may help.

---

## 13. Experimental evidence relevant to the framework

### 13.1 Gaussian benchmarks
For a 10,000D Gaussian:
- with exact gradients, ray tracing and HMC have roughly similar performance when tuned well;
- Metropolis correction matters for imperfect integrators;
- Omelyan integrator performed best across a broad step-size range.

So the paper does **not** claim huge gains over exact-gradient HMC in benign settings.

### 13.2 Stochastic-gradient robustness
This is the headline empirical result.

For stochastic Gaussian gradients defined by
\[
\mathcal{L}_\mathrm{sto}(\mathbf{x}) \equiv \exp\left(-\frac{1}{2}[\mathbf{x}-\mathbf{R}(\sigma_\mathrm{sto})]^2\right),
\]
the paper finds:
- ray tracing remains accurate up to \(\sigma_\mathrm{sto}\sim 10\),
- HMC degrades by \(\sigma_\mathrm{sto}\sim 1\).

The median-log-likelihood error obeys
\[
|\Delta \ln\mathcal{L}| = (\sigma_\mathrm{sto}/\sigma_c)^2,
\]
with empirical resilience
- HMC: \(\sigma_c^2 = 0.012\),
- ray tracing: \(\sigma_c^2 = 3.2\).

So ray tracing tolerated about \(16\times\) larger noise amplitude, or \(\sim 250\times\) larger variance, at comparable bias.

Scaling with step size:
- HMC robustness: \(\sigma_c\propto \Delta\phi^{-1/2}\),
- ray tracing robustness: \(\sigma_c\propto \Delta\phi^{-1}\).

This implies smaller minibatches can improve total efficiency for ray tracing, but not for HMC.

### 13.3 Neural-network applications
- **MLP, 1433 params:** both HMC and ray tracing work; similar posterior predictions, somewhat better autocorrelation for ray tracing.
- **ResNet-34, 22M params:** ray tracing feasible on one consumer GPU; HMC not attempted because minibatch stochasticity too high.
- **GPT-2, 1.5B params:** approximate posterior sampling on a single consumer GPU; stable validation loss around target; median autocorrelation time for sampled token probabilities around \(10^8\) tokens.

The GPT-2 experiment is presented as approximate rather than exact, but it supports the paper’s claim that the framework scales to very large neural networks under stochastic gradients.

---

## 14. Limitations and caveats

The paper is fairly candid about several limitations:

1. **\(D=1\)**: the basic formula
   \[
   n(x)=\mathcal{L}(x)^{1/(D-1)}
   \]
   is undefined; the ray-tracing formulation is meaningful only for \(D>1\).

2. **Need for refresh/scattering**: deterministic ray tracing alone is not ergodic.

3. **Disconnected support**: requires special blackbody-boundary treatment for islands.

4. **Approximate likelihoods for neural nets**: practical results depend on choosing \(D_\mathrm{eff}\) and loss scaling, often heuristically.

5. **Weight-space convergence may fail** even when function-space uncertainty is useful.

6. **Very large models**: reported GPT-2 sampling is approximate and affected by BF16 quantization spikes; the paper uses masking to skip bad samples.

7. **No universal speed advantage over exact-gradient HMC** in clean, standard targets; the strongest advantage is specifically for stochastic-gradient settings.

---

## 15. Why the generalized framework matters

The significance of the framework is threefold.

### (i) A new geometric route to correct sampling
Instead of preserving Hamiltonian energy, it preserves an optical invariant:
\[
R = n^{1-D}L.
\]
This gives a distinct acceptance rule and a natural fair-sampling construction.

### (ii) A principled separation of geometry from weighting
The generalized formulation
\[
n(x) =
\left(\frac{\mathcal{L}(x)v(x)}{W(x)}\right)^{\frac{1}{D-1}}
\]
separates:
- path geometry \(n\),
- traversal speed \(v\),
- sample weight \(W\).

That makes the approach a **family of samplers**, not just a single one.

### (iii) Unification of prior samplers
Under this lens:
- HMC is ray tracing with \(n\propto \sqrt{E+\ln \mathcal{L}}\),
- microcanonical HMC uses \(W=\mathcal{L}^{1/D}\),
- Gibbs uses \(n=1, W=\mathcal{L}\),
- Metropolis is a one-step straight-ray weighted update,
- Monte Carlo integration is masked Gibbs sampling.

So the framework provides a common language for comparing how different samplers trade off exploration of high-probability peaks versus low-probability tails.

---

## 16. Bottom-line summary

The paper proposes a sampling framework based on optical ray propagation in parameter space. The fair-sampling version chooses

\[
n(x) = \mathcal{L}(x)^{1/(D-1)},
\]

so that conservation of optical radiance implies ray density \(L(x)\propto \mathcal{L}(x)\). Ray paths evolve according to

\[
\frac{d}{ds}\left(n(x)\frac{dx}{ds}\right)=\nabla_x n(x),
\]
or equivalently
\[
\frac{d}{ds}\left(\frac{dx}{ds}\right)
=
\nabla_x \ln(n(x))
-
\left(\frac{dx}{ds}\cdot \nabla_x \ln(n(x))\right)\frac{dx}{ds},
\]
with constant path speed and reversible angle update
\[
\tan\left(\frac{\theta_f}{2}\right)
=
\tan\left(\frac{\theta_i}{2}\right)\exp(-\Delta s |\nabla_x\ln(n(x))|).
\]

Correctness is enforced through conservation of the “basic radiance”
\[
R=n^{1-D}L,
\]
with Metropolis correction
\[
P(x\rightarrow\mathbf{y})=
\min\left(1,\frac{\mathcal{L}(\mathbf{y})L(x)}{\mathcal{L}(x)L(\mathbf{y})}\right),
\]
or in generalized form
\[
P(x\rightarrow\mathbf{y})
=
\min\left(1,\frac{n(x)^{1-D}L(x)}{n(\mathbf{y})^{1-D}L(\mathbf{y})}\right).
\]

The generalized framework introduces weights and speeds:
\[
n(x)=\left(\frac{\mathcal{L}(x)v(x)}{W(x)}\right)^{1/(D-1)},
\]
which lets many standard methods appear as special cases.

Its main practical claim is that constant-speed rays are vastly more robust than HMC to stochastic-gradient heating, which the experiments support strongly. That robustness is what enables approximate posterior sampling for very large neural networks, including GPT-2-scale models, on modest hardware.

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