lgatr.layers.attention.self_attention.SelfAttention
- class lgatr.layers.attention.self_attention.SelfAttention(config, primitives)[source]
Bases:
ModuleL-GATr self-attention.
Constructs queries, keys, and values, computes geometric attention, and projects linearly to outputs.
- Parameters:
config (
SelfAttentionConfig) – Attention configuration.primitives (
PrimitivesConfig) – LGATr primitives configuration.
- forward(multivectors, scalars=None, additional_qk_features_mv=None, additional_qk_features_s=None, **attn_kwargs)[source]
Compute self-attention.
Queries, keys, and values are computed per head, geometric attention is applied over items, the heads are concatenated, and a final linear map produces the outputs.
- Parameters:
multivectors (
Tensor) – Input multivectors of shape(..., items, mv_channels, 16).scalars (
Tensor|None) – Optional input scalars of shape(..., items, s_channels). If None, the scalar stream is bypassed andoutputs_smay be None (or a tensor lifted byout_linearifout_s_channelsis configured).additional_qk_features_mv (
Tensor|None) – Additional multivector Q/K features of shape(..., items, add_qk_mv_channels, 16).additional_qk_features_s (
Tensor|None) – Additional scalar Q/K features of shape(..., items, add_qk_s_channels).**attn_kwargs – Optional keyword arguments forwarded to 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.