torchref.base.targets.xray_ml module

Maximum-likelihood X-ray loss math.

Mirrors lines 47-84 of torchref/refinement/targets/xray/maximum_likelihood.py verbatim. The caller is responsible for everything XrayTarget.get_data does: unpacking ReflectionData, running the Scaler forward to produce |F_calc| from a complex f_calc, and building the work/free mask.

torchref.base.targets.xray_ml.ml_xray_loss_math(F_obs, F_calc, sigma, centric_flags, mask)[source]

Maximum-likelihood X-ray loss on already-scaled amplitudes.

Matches MaximumLikelihoodXrayTarget.forward lines 37-84.

Dispatches to torchref.base.targets.triton.xray_ml.ml_xray_loss_math_triton() on CUDA float32; falls back to the eager implementation otherwise.

Parameters:
  • F_obs (torch.Tensor) – (N,) observed amplitudes (zeros outside mask).

  • F_calc (torch.Tensor) – (N,) scaled calculated amplitudes (already real-valued, zeros outside mask).

  • sigma (torch.Tensor) – (N,) per-reflection sigma (ones outside mask).

  • centric_flags (torch.Tensor or None) – (N,) bool, True for centric reflections. None is treated as all-acentric.

  • mask (torch.Tensor) – (N,) bool work-set mask applied to the final sum.