lgatr.nets.slim.LGATrSlim

class lgatr.nets.slim.LGATrSlim(num_blocks, in_v_channels, out_v_channels, hidden_v_channels, in_s_channels, out_s_channels, hidden_s_channels, num_heads, nonlinearity='gelu', nonlinearity_v='sigmoid', mlp_ratio=2, attn_ratio=1, num_layers_mlp=2, dropout_prob=None, norm_elementwise_affine=True, checkpoint_blocks=False, naive_amp=False)[source]

Bases: Module

L-GATr-slim network.

A slimmer L-GATr variant that operates on Lorentz vectors and scalars (no full multivector representation). Stacks num_blocks SlimBlock modules between initial and final SlimLinear layers.

Parameters:
  • num_blocks (int) – Number of Lorentz-transformer blocks.

  • in_v_channels (int) – Number of input vector channels.

  • out_v_channels (int) – Number of output vector channels.

  • hidden_v_channels (int) – Number of hidden vector channels.

  • in_s_channels (int) – Number of input scalar channels.

  • out_s_channels (int) – Number of output scalar channels.

  • hidden_s_channels (int) – Number of hidden scalar channels.

  • num_heads (int) – Number of attention heads.

  • nonlinearity (str) – Nonlinearity for the MLP layers.

  • nonlinearity_v (str | None) – Optional override for the vector-path gate nonlinearity in every GLU. None falls back to nonlinearity.

  • mlp_ratio (int) – Expansion ratio for MLP hidden channels.

  • attn_ratio (int) – Expansion ratio for attention hidden channels.

  • num_layers_mlp (int) – Number of layers in each MLP (must be >= 2).

  • dropout_prob (float | None) – Dropout probability.

  • norm_elementwise_affine (bool) – Whether the block SlimRMSNorm instances learn a per-channel gain.

  • checkpoint_blocks (bool) – Whether to use gradient checkpointing for the blocks.

  • naive_amp (bool) – Whether to bypass the fp32 precision islands so the whole forward runs in the surrounding autocast dtype (e.g. bf16). When False (default), under autocast the vector stream and metric contractions stay fp32 while the scalar GEMMs run in bf16.

forward(vectors, scalars, **attn_kwargs)[source]

Forward pass.

Parameters:
  • vectors (Tensor) – Lorentz vectors of shape (..., items, in_v_channels, 4).

  • scalars (Tensor) – Scalar features of shape (..., items, in_s_channels).

  • **attn_kwargs – Optional keyword arguments forwarded to attention.

Return type:

tuple[Tensor, Tensor]

Returns:

  • outputs_v – Lorentz vectors of shape (..., items, out_v_channels, 4).

  • outputs_s – Scalar features of shape (..., items, out_s_channels).