@@ -148,6 +148,28 @@ def test_periodic_attention_keeps_batched_graphs_independent():
148148 torch .testing .assert_close (together , separate )
149149
150150
151+ def test_periodic_attention_validates_inputs_before_building_sources ():
152+ layer = EquivariantTransformerLayer (
153+ "4x0e" , heads = 1 , require_tensor_coupling = False
154+ ).double ()
155+ features , positions , batch , cell , pbc = _periodic_inputs ()
156+
157+ with pytest .raises (TypeError , match = "batch must have dtype torch.long" ):
158+ layer .forward_periodic_attention (
159+ features , positions , batch .to (torch .int32 ), cell , pbc
160+ )
161+ with pytest .raises (
162+ ValueError , match = "features and positions must have the same dtype"
163+ ):
164+ layer .forward_periodic_attention (features , positions .float (), batch , cell , pbc )
165+ with pytest .raises (
166+ ValueError , match = "features, positions, and batch must share a device"
167+ ):
168+ layer .forward_periodic_attention (
169+ features , positions , batch .to ("meta" ), cell , pbc
170+ )
171+
172+
151173def test_periodic_configuration_validates_replication_convention ():
152174 config = {
153175 "global_attn_engine" : "EquivariantTransformer" ,
0 commit comments