From lgatr v1 to v2
The lgatr v2 release renames parts of the interface, mostly to make names consistent
between the LGATr and LGATrSlim
architectures, and changes a handful of defaults. A v2 network constructed with the same
arguments as its v1 counterpart is therefore not numerically identical.
API changes
ConditionalLGATrandConditionalLGATrSlim__init__arguments:condition_mv_channels→mv_channels_condcondition_v_channels→v_channels_condcondition_s_channels→s_channels_cond
and
forwardarguments:multivectors_condition→multivectors_condvectors_condition→vectors_condscalars_condition→scalars_cond
-
activation→nonlinearityincrease_hidden_channels→mlp_rationum_hidden_layers→num_layers_mlp(num_layers_mlpcounts all layers instead of only the hidden ones, so explicit values have to be increased by one if the parameter is specified)
SelfAttentionConfigandCrossAttentionConfig:increase_hidden_channels→attn_ratio.
The global
gatr_configobject is replaced byPrimitivesConfig, which is passed to each network asprimitives. This way several networks with different settings can coexist. The flags are renamed:use_fully_connected_subgroup→subgroupuse_bivector→bivectoruse_geometric_product→geometric_product
The
compile_modeandcompile_dynamicarguments are replaced by a singlecompile_kwargsdict that is passed on totorch.compile().
Default changes
norm_elementwise_affine=Truein all normalization operations (EquiLayerNorm,SlimRMSNorm), allowing for an extra learned scalar multiplier. We find that this uniformly improves performance, and it is standard in LayerNorm and RMSNorm. Setnorm_elementwise_affine=Falseto recover v1 behavior.sparse_gp=TrueinPrimitivesConfig. With the new implementation this is faster on GPU and CPU. We keepsparse_linear=Falseas the default which is faster on GPU, but slower on CPU and costs significantly more FLOPs, see Efficient implementation. This only affects efficiency, not the network output.nonlinearity_v="sigmoid"inSlimGLU. We find that this improves stability in extreme cases, because the vector branch can not blow up. Setnonlinearity_v=Noneto fall back tononlinearityand recover the v1 behavior.compile=Trueno longer impliesdynamic=True. Setcompile_kwargs={"dynamic": True}to recover the old behavior.The vector gate in
SlimGLUis scaled by1/sqrt(4)to correct for variance increase from the Minkowski product, similar to the1/sqrt(d_k)factor in attention.The scalar bias in the qkv linear layers is turned off in all networks, because they cost parameters and extra kernel launches while having little effect.
The bias of the scalar linear layer in
SlimLinearis initialized to zero to improve numerical stability in extreme cases.