lgatr.nets.conditional_lgatr.ConditionalLGATr
- class lgatr.nets.conditional_lgatr.ConditionalLGATr(num_blocks, in_mv_channels, mv_channels_cond, out_mv_channels, hidden_mv_channels, in_s_channels, s_channels_cond, out_s_channels, hidden_s_channels, attention, crossattention, mlp, primitives=None, dropout_prob=None, norm_elementwise_affine=True, checkpoint_blocks=False, naive_amp=False)[source]
Bases:
ModuleConditional L-GATr network.
Combines
num_blocksConditionalLGATrBlockmodules (geometric self-attention, cross-attention, geometric MLP, residual connections, normalization) with initial and final equivariant linear layers. The condition is expected to be already preprocessed (e.g. by a non-conditionalLGATrnetwork).- Parameters:
num_blocks (
int) – Number of transformer blocks.in_mv_channels (
int) – Number of input multivector channels.mv_channels_cond (
int) – Number of condition multivector channels.out_mv_channels (
int) – Number of output multivector channels.hidden_mv_channels (
int) – Number of hidden multivector channels.in_s_channels (
int) – Number of scalar input channels. Use 0 for no scalar inputs.s_channels_cond (
int) – Number of scalar condition channels. Use 0 for no scalar condition stream.out_s_channels (
int) – Number of scalar output channels. Use 0 for no scalar outputs.hidden_s_channels (
int) – Number of scalar hidden channels.attention (
SelfAttentionConfig|Mapping) – Self-attention configuration.crossattention (
CrossAttentionConfig|Mapping) – Cross-attention configuration.mlp (
MLPConfig|Mapping) – MLP configuration.primitives (
PrimitivesConfig|Mapping|None) – LGATr primitives configuration. Accepts aPrimitivesConfiginstance, a dict, orNone(uses defaults).dropout_prob (
float|None) – Dropout probability.norm_elementwise_affine (
bool) – Whether the blockEquiLayerNorminstances learn an affine gain.checkpoint_blocks (
bool) – Whether to use gradient checkpointing for the transformer blocks.naive_amp (
bool) – Whether to bypass the fp32 precision islands so the whole forward runs in the surrounding autocast dtype (e.g. bf16). WhenFalse(default), under autocast the multivector stream and metric contractions stay fp32 while the scalar GEMMs run in bf16.
- forward(multivectors, multivectors_cond, scalars=None, scalars_cond=None, attn_kwargs=None, crossattn_kwargs=None)[source]
Forward pass.
- Parameters:
multivectors (
Tensor) – Input multivectors of shape(..., items, in_mv_channels, 16).multivectors_cond (
Tensor) – Condition multivectors of shape(..., items_cond, mv_channels_cond, 16).scalars (
Tensor|None) – Optional input scalars of shape(..., items, in_s_channels).scalars_cond (
Tensor|None) – Optional condition scalars of shape(..., items_cond, s_channels_cond).attn_kwargs (
dict|None) – Optional keyword arguments forwarded to self-attention.crossattn_kwargs (
dict|None) – Optional keyword arguments forwarded to cross-attention.
- Return type:
tuple[Tensor,Tensor|None]- Returns:
outputs_mv – Output multivectors of shape
(..., items, out_mv_channels, 16).outputs_s – Output scalars of shape
(..., items, out_s_channels), or None ifout_s_channels == 0.