Optimization#
The Cartesian and kinematic minimization entry points,
tmol.run_cart_min() and tmol.run_kin_min(), are imported from the
top-level package and documented in Top-level API. tmol.optimization
exports the score-function network used for kinematic minimization.
Minimizers and scoring-function optimization adapters.
- class tmol.optimization.KinForestSfxnNetwork(score_function: ScoreFunction, pose_stack: PoseStack, kin_module: PoseStackKinematicsModule, dof_mask=None, kin_dtype=torch.float32, *, cuda_graph: bool | str = False, fold_forest: FoldForest | None = None, move_map: MoveMap | None = None)[source]#
Bases:
ModuleDifferentiable score network over selected kinematic degrees of freedom.
Set
cuda_graphto"forward_backward"(orTrue) to capture the complete DOF-to-score evaluation and its gradient as CUDA graphs,"forward"to capture gradient-free evaluation, or"both". Capture requires CUDA and a fixed topology;_reset()reuses the captured graphs for new coordinates. Passfold_forestandmove_mapto allow that reuse.- enable_cuda_graphs(mode: str = 'forward_backward') KinForestSfxnNetwork[source]#
Capture DOF-to-score evaluation for this fixed topology.
Captures forward kinematics, the coordinate scatter, and weighted scoring as one graph and, for gradients, their backward pass as a second graph sharing its memory pool.
modemay be"forward","forward_backward", or"both"; paths already captured are kept.
- forward() Tensor[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.