diffalign.models package¶
Subpackages¶
Submodules¶
diffalign.models.common module¶
- class diffalign.models.common.MultiLayerPerceptron(input_dim, hidden_dims, activation='relu', dropout=0)[source]¶
Bases:
ModuleMulti-layer Perceptron. Note there is no activation or dropout in the last layer. :param input_dim: input dimension :type input_dim: int :param hidden_dim: hidden dimensions :type hidden_dim: list of int :param activation: activation function :type activation: str or function, optional :param dropout: dropout rate :type dropout: float, optional
Module contents¶
Public model API for DiffAlign.
- class diffalign.models.CrossAttention(dim: int, heads: int = 4, dropout: float = 0.0, coord_update: bool = True)[source]¶
Bases:
ModuleQ <- R masked dense cross-attention with optional coordinate updates.
- forward(h_q, x_q, h_r, x_r, q2r_edge_index=None, k_train: int | None = None)[source]¶
Legacy-compatible interface (kept for callers in DiffAlign).
- forward_dense(h_q: Tensor, x_q: Tensor, h_r: Tensor, x_r: Tensor, mask_q: Tensor, mask_r: Tensor, *, pre_k: Tensor | None = None, pre_v: Tensor | None = None, pre_rh: Tensor | None = None, coord_chunk_M: int = 256) tuple[Tensor, Tensor][source]¶
h_q: [B,N,D], x_q: [B,N,3], mask_q: [B,N] (True=valid) h_r: [B,M,D], x_r: [B,M,3], mask_r: [B,M]
- class diffalign.models.CrossGraphAligner(dim: int, heads: int = 4, dropout: float = 0.0, coord_update: bool = True, num_layers: int = 6, recompute_each: int = 1, coord_chunk_M: int = 256)[source]¶
Bases:
ModuleMasked dense cross-attention aligner (drop-in).
- forward(h, x, batch, graph_idx)[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.
- class diffalign.models.DiffAlign(node_feature_dim: int = 64, time_embed_dim: int = 32, query_embed_dim: int = 32, edge_encoder_dim: int = 64, gnn_hidden_dim: int = 128, gnn_layers_intra: int = 12, gnn_layers_intra_2: int = 4, gnn_layers_inter: int = 8, max_atom_types: int = 100, num_timesteps: int = 32, beta_start: float = 0.0001, beta_end: float = 0.02, schedule_type: str = 'cosine', repulsion_weight: float = 0.01, repulsion_margin: float = 1.2, repulsion_exclude_hops: int = 3)[source]¶
Bases:
ModuleIsotropic Gaussian Diffusion (v-parameterization; T steps) - Backbone: EGNN + CrossGraphAligner (only query coordinates move) - Output: v_t in merged (Q,R) order - Loss: v MSE + x0 anchor + optional repulsion
- DDPM_Sampling_UFF(query_batch: Batch, reference_batch: Batch, *, clamp: float = 1e-10, cfg_scale: float = 1.0, query_mols=None, pocket_mols=None, uff_guidance_scale: float = 0.0, uff_inner_steps: int = 8, uff_clamp: float = 1.0, uff_start_ratio: float = 0.0, snr_gate_gamma: float = 1.0, noise_temperature: float = 0.3, uff_vdw_multiplier: float = 10.0, debug_log: bool = False)[source]¶
Standard DDPM (v-param) + UFFTorch-based UFF steering on x0. Note: _refresh_nonbond_candidates is called with ligand+pocket coords merged.
- class diffalign.models.EGNN(in_node_nf: int, in_edge_nf: int, hidden_nf: int, device: str = 'cpu', act_fn=SiLU(), n_layers: int = 4, attention: bool = False, norm_diff: bool = True, out_node_nf: int | None = None, tanh: bool = False, coords_range: float = 15.0, agg: str = 'sum', norm_constant: float = 0.0)[source]¶
Bases:
Module- forward(h: Tensor, x: Tensor, edges: Tensor, edge_attr: Tensor | None = None, node_mask: Tensor | None = None, edge_mask: Tensor | None = None, coord_mask: Tensor | None = None, node_attr: Tensor | None = None)[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.
- class diffalign.models.E_GCL(input_nf: int, output_nf: int, hidden_nf: int, edges_in_d: int = 0, nodes_att_dim: int = 0, act_fn=SiLU(), attention: bool = False, norm_diff: bool = True, tanh: bool = False, coords_range: float = 1.0, norm_constant: float = 0.0)[source]¶
Bases:
Module- forward(h: Tensor, edge_index: Tensor, coord: Tensor, edge_attr: Tensor | None = None, node_attr: Tensor | None = None, node_mask: Tensor | None = None, edge_mask: Tensor | None = None, coord_mask: Tensor | None = None)[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.
- class diffalign.models.MLPEdgeEncoder(hidden_dim=100, activation='relu')[source]¶
Bases:
Module- forward(edge_length, edge_type)[source]¶
- Input:
edge_length: The length of edges, shape=(E, 1). edge_type: The type pf edges, shape=(E,)
- Returns:
The representation of edges. (E, self.hidden_dim)
- Return type:
edge_attr
- property out_channels¶
- class diffalign.models.MultiLayerPerceptron(input_dim, hidden_dims, activation='relu', dropout=0)[source]¶
Bases:
ModuleMulti-layer Perceptron. Note there is no activation or dropout in the last layer. :param input_dim: input dimension :type input_dim: int :param hidden_dim: hidden dimensions :type hidden_dim: list of int :param activation: activation function :type activation: str or function, optional :param dropout: dropout rate :type dropout: float, optional