MolecularDiffusion.modules.models.equifm.paths¶
Probability paths for EquiFM (Song, Gong et al., NeurIPS 2023, arXiv:2312.07168).
Two independent conditional paths (paper Prop. 4.2 licenses treating them separately):
coordinates x – conditional OT path, Eq. 8:
x_t = (sigma_min + (1 - sigma_min) t) * pi*(R* eps_x) + (1 - t) x_0features h – variance-preserving path, Eq. 5:
h_t = alpha_t h_0 + sqrt(1 - alpha_t^2) eps_h,alpha_t = e^{-T(t)/2}.
Note t = 1 is noise and t = 0 is data (MolFM’s convention – their
sampler integrates t: 1 -> 0), the reverse of the usual flow-matching
convention. Both u_x and u_h returned here are the true forward-time
velocities d/dt of the respective paths, so an ODE solver stepping
t: 1 -> 0 with dt < 0 reproduces data.
Paper defects patched here (see INTEGRATION_PLAN.md, “Paper-Reconstruction Assessment”):
sigma_minis never given a numerical value in the paper; we use the flow-matching convention of Lipman et al.,1e-4.Algorithm 1 line 8 writes
h_t = alpha_t h_0 + (1 - alpha_t^2) eps_h, dropping a square root. Section 3.1 defines the VP path asN(h | alpha_t h_0, (1 - alpha_t^2) I), so the square root is required. Unambiguous typo; corrected.beta_min/beta_maxforT(t)are not in the paper. They are in the released code (others/MolFM/sampling/cnf_models.py:8-19): 0.1 and 20, the standard VP-linear values.Algorithm 1 line 9 gives the
hregression target asalpha'_t / (1 - alpha_t^2) * (alpha_t h_t - h_0). Expandingh_t = alpha_t h_0 + sqrt(1 - alpha_t^2) eps_hshows that expression equals-dh_t/dt, i.e. it carries the opposite sign to thextarget on the same line (which is+dx_t/dt). Since the released sampler integratest: 1 -> 0treating the network output asdz/dtfor both channel groups, the sign on line 9’shterm is a typo.vp_interpolatereturns+dh_t/dt.
Attributes¶
Functions¶
|
Integrated VP noise schedule |
|
|
|
|
|
Hybrid-transport reweighting factor |
|
Paper Eq. 8 / Algorithm 1 lines 7 and 9 (x term). |
|
Paper Eq. 5 / Algorithm 1 line 8, with the square root restored. |
Module Contents¶
- MolecularDiffusion.modules.models.equifm.paths.T(t: torch.Tensor, beta_min: float, beta_max: float) torch.Tensor¶
Integrated VP noise schedule
T(t) = (b_max - b_min) t^2 / 2 + b_min t.
- MolecularDiffusion.modules.models.equifm.paths.T_hat(t: torch.Tensor, beta_min: float, beta_max: float) torch.Tensor¶
T'(t) = (b_max - b_min) t + b_min.
- MolecularDiffusion.modules.models.equifm.paths.alpha(t: torch.Tensor, beta_min: float, beta_max: float) torch.Tensor¶
alpha_t = exp(-T(t) / 2)(paper Eq. 5).
- MolecularDiffusion.modules.models.equifm.paths.m_para(t: torch.Tensor, beta_min: float, beta_max: float) torch.Tensor¶
Hybrid-transport reweighting factor
-T'(t) / (2 (1 - e^{-T(t)})).Exactly MolFM’s
M_para(cnf_models.py:262-270) – the factor the released sampler multiplies the network’shoutput by at integration time. Always strictly negative, so dividing by it is safe.
- MolecularDiffusion.modules.models.equifm.paths.ot_interpolate(x_0: torch.Tensor, eps_x: torch.Tensor, t: torch.Tensor, sigma_min: float)¶
Paper Eq. 8 / Algorithm 1 lines 7 and 9 (x term).
eps_xmust already be the EOT-aligned noisepi*(R* eps_x). Returns(x_t, u_x)withu_x = dx_t/dt.
- MolecularDiffusion.modules.models.equifm.paths.vp_interpolate(h_0: torch.Tensor, eps_h: torch.Tensor, t: torch.Tensor, beta_min: float, beta_max: float)¶
Paper Eq. 5 / Algorithm 1 line 8, with the square root restored.
Returns
(h_t, u_h)withu_h = dh_t/dtwritten in the expanded formdh_t/dt = -T’(t)/2 * alpha_t * (h_0 - alpha_t eps_h / sqrt(1 - alpha_t^2))
which is algebraically identical to differentiating
h_tbut avoids the catastrophic cancellation of formingalpha_t h_t - h_0and dividing by a vanishing1 - alpha_t^2. See defect (4) in the module docstring for the sign.
- MolecularDiffusion.modules.models.equifm.paths.EPS = 1e-05¶