The MSAModule implements Algorithm 8 for processing Multiple Sequence Alignments (MSA). It facilitates communication between single representations and pairwise representations through a series of layers. Each layer consists of:
- Outer Product Mean: Computes a pairwise representation from the MSA using an outer product of hidden features.
- MSA Pair Weighted Averaging: Updates the MSA representations using information from the pairwise representation.
- MSA Transition: A feedforward-style transition applied to the MSA.
- Pairwise Block: A block of triangle modules (multiplication and attention) and transitions applied to the pairwise representation.
To handle large MSAs, the module can cap the number of MSAs using max_num_msa by sampling without replacement.
Key Parameters
dim_single: Dimension of the single representation.dim_pairwise: Dimension of the pairwise representation.depth: Number of MSA layers.dim_msa: Dimension of the MSA features.dim_msa_input: Input dimension for MSA (defaults to NUM_MSA_ONE_HOT).dim_additional_msa_feats: Number of additional MSA features (defaults to 2).max_num_msa: Maximum number of MSAs to process (if exceeded, samples the top $k$ based on random noise).checkpoint: If True, uses gradient checkpointing for the layers to save memory.
API
forward method signature:
forward(
*,
single_repr: Float['b n ds'],
pairwise_repr: Float['b n n dp'],
msa: Float['b s n dm'],
mask: Bool['b n'] | None = None,
msa_mask: Bool['b s'] | None = None,
additional_msa_feats: Float['b s n {self.dmi}'] | None = None
) -> Float['b n n dp']
class MSAModule(
Module
):
def __init__(
self,
*,
dim_single = 384,
dim_pairwise = 128,
depth = 4,
dim_msa = 64,
dim_msa_input=NUM_MSA_ONE_HOT,
dim_additional_msa_feats=2,
outer_product_mean_dim_hidden = 32,
msa_pwa_dropout_row_prob = 0.15,
msa_pwa_heads = 8,
msa_pwa_dim_head = 32,
checkpoint = False,
pairwise_block_kwargs: dict = dict(),
max_num_msa: int | None = None,
layerscale_output: bool = True
):
# ... implementation ...
def forward(
self,
*,
single_repr: Float['b n ds'],
pairwise_repr: Float['b n n dp'],
msa: Float['b s n dm'],
mask: Bool['b n'] | None = None,
msa_mask: Bool['b s'] | None = None,
additional_msa_feats: Float['b s n {self.dmi}'] | None = None
) -> Float['b n n dp']:
# ... implementation ...