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: Module

Differentiable score network over selected kinematic degrees of freedom.

Set cuda_graph to "forward_backward" (or True) 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. Pass fold_forest and move_map to 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. mode may be "forward", "forward_backward", or "both"; paths already captured are kept.

property full_dofs: Tensor#

All kinematic DOFs at the current movable-DOF values.

property full_coords: Tensor#

Pose-stack coordinates at the current movable-DOF values.

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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Was this page helpful?

Was this page helpful?