88from tests .utils import Example , simple_parameter
99
1010
11+ @pytest .mark .cfg
1112@pytest .mark .parametrize ('optimizer_name' , VALID_OPTIMIZER_NAMES )
1213def test_learning_rate (optimizer_name ):
1314 if optimizer_name in ('alig' ,):
@@ -23,6 +24,7 @@ def test_learning_rate(optimizer_name):
2324 optimizer (None , ** config )
2425
2526
27+ @pytest .mark .cfg
2628@pytest .mark .parametrize ('optimizer_name' , VALID_OPTIMIZER_NAMES )
2729def test_epsilon (optimizer_name ):
2830 if optimizer_name in ('nero' , 'shampoo' , 'scalableshampoo' , 'dadaptsgd' , 'adafactor' , 'lion' ):
@@ -40,6 +42,7 @@ def test_epsilon(optimizer_name):
4042 assert str (error_info .value ) == '[-] epsilon -1e-06 must be non-negative'
4143
4244
45+ @pytest .mark .cfg
4346def test_shampoo_epsilon ():
4447 shampoo = load_optimizer ('Shampoo' )
4548 scalable_shampoo = load_optimizer ('ScalableShampoo' )
@@ -54,6 +57,7 @@ def test_shampoo_epsilon():
5457 shampoo (None , matrix_eps = - 1e-6 )
5558
5659
60+ @pytest .mark .cfg
5761def test_adafactor_epsilon ():
5862 adafactor = load_optimizer ('adafactor' )
5963
@@ -64,6 +68,7 @@ def test_adafactor_epsilon():
6468 adafactor (None , eps2 = - 1e-6 )
6569
6670
71+ @pytest .mark .cfg
6772@pytest .mark .parametrize ('optimizer_name' , VALID_OPTIMIZER_NAMES )
6873def test_weight_decay (optimizer_name ):
6974 if optimizer_name in ('nero' , 'alig' ):
@@ -81,6 +86,7 @@ def test_weight_decay(optimizer_name):
8186 assert str (error_info .value ) == '[-] weight_decay -0.001 must be non-negative'
8287
8388
89+ @pytest .mark .cfg
8490@pytest .mark .parametrize ('optimizer_name' , ['apollo' ])
8591def test_weight_decay_type (optimizer_name ):
8692 optimizer = load_optimizer (optimizer_name )
@@ -89,6 +95,7 @@ def test_weight_decay_type(optimizer_name):
8995 optimizer (None , weight_decay_type = 'dummy' )
9096
9197
98+ @pytest .mark .cfg
9299@pytest .mark .parametrize ('optimizer_name' , ['apollo' ])
93100def test_rebound (optimizer_name ):
94101 optimizer = load_optimizer (optimizer_name )
@@ -97,48 +104,55 @@ def test_rebound(optimizer_name):
97104 optimizer (None , rebound = 'dummy' )
98105
99106
107+ @pytest .mark .cfg
100108@pytest .mark .parametrize ('optimizer_name' , ['adamp' , 'sgdp' ])
101109def test_wd_ratio (optimizer_name ):
102110 optimizer = load_optimizer (optimizer_name )
103111 with pytest .raises (ValueError ):
104112 optimizer (None , wd_ratio = - 1e-3 )
105113
106114
115+ @pytest .mark .cfg
107116@pytest .mark .parametrize ('optimizer_name' , ['lars' ])
108117def test_trust_coefficient (optimizer_name ):
109118 optimizer = load_optimizer (optimizer_name )
110119 with pytest .raises (ValueError ):
111120 optimizer (None , trust_coefficient = - 1e-3 )
112121
113122
123+ @pytest .mark .cfg
114124@pytest .mark .parametrize ('optimizer_name' , ['madgrad' , 'lars' ])
115125def test_momentum (optimizer_name ):
116126 optimizer = load_optimizer (optimizer_name )
117127 with pytest .raises (ValueError ):
118128 optimizer (None , momentum = - 1e-3 )
119129
120130
131+ @pytest .mark .cfg
121132@pytest .mark .parametrize ('optimizer_name' , ['ranger' ])
122133def test_lookahead_k (optimizer_name ):
123134 optimizer = load_optimizer (optimizer_name )
124135 with pytest .raises (ValueError ):
125136 optimizer (None , k = - 1 )
126137
127138
139+ @pytest .mark .cfg
128140@pytest .mark .parametrize ('optimizer_name' , ['ranger21' ])
129141def test_beta0 (optimizer_name ):
130142 optimizer = load_optimizer (optimizer_name )
131143 with pytest .raises (ValueError ):
132144 optimizer (None , num_iterations = 200 , beta0 = - 0.1 )
133145
134146
147+ @pytest .mark .cfg
135148@pytest .mark .parametrize ('optimizer_name' , ['nero' , 'apollo' ])
136149def test_beta (optimizer_name ):
137150 optimizer = load_optimizer (optimizer_name )
138151 with pytest .raises (ValueError ):
139152 optimizer (None , beta = - 0.1 )
140153
141154
155+ @pytest .mark .cfg
142156@pytest .mark .parametrize ('optimizer_name' , BETA_OPTIMIZER_NAMES )
143157def test_betas (optimizer_name ):
144158 optimizer = load_optimizer (optimizer_name )
@@ -160,6 +174,7 @@ def test_betas(optimizer_name):
160174 optimizer (None , betas = (0.1 , 0.1 , - 0.1 ))
161175
162176
177+ @pytest .mark .cfg
163178def test_reduction ():
164179 parameters = Example ().parameters ()
165180 optimizer = load_optimizer ('adamp' )(parameters )
@@ -168,6 +183,7 @@ def test_reduction():
168183 PCGrad (optimizer , reduction = 'wrong' )
169184
170185
186+ @pytest .mark .cfg
171187@pytest .mark .parametrize ('optimizer_name' , ['scalableshampoo' , 'shampoo' ])
172188def test_update_frequency (optimizer_name ):
173189 optimizer = load_optimizer (optimizer_name )
@@ -183,18 +199,21 @@ def test_update_frequency(optimizer_name):
183199 optimizer (None , preconditioning_compute_steps = - 1 )
184200
185201
202+ @pytest .mark .cfg
186203@pytest .mark .parametrize ('optimizer_name' , ['adan' , 'lamb' ])
187204def test_norm (optimizer_name ):
188205 optimizer = load_optimizer (optimizer_name )
189206 with pytest .raises (ValueError ):
190207 optimizer (None , max_grad_norm = - 0.1 )
191208
192209
210+ @pytest .mark .cfg
193211def test_sam_parameters ():
194212 with pytest .raises (ValueError , match = '' ):
195213 SAM (None , load_optimizer ('adamp' ), rho = - 0.1 )
196214
197215
216+ @pytest .mark .cfg
198217def test_lookahead_parameters ():
199218 param = simple_parameter ()
200219 optimizer = load_optimizer ('adamp' )([param ])
@@ -216,6 +235,7 @@ def test_lookahead_parameters():
216235 Lookahead (optimizer , pullback_momentum = 'invalid' )
217236
218237
238+ @pytest .mark .cfg
219239def test_sam_methods ():
220240 param = simple_parameter ()
221241
@@ -224,6 +244,7 @@ def test_sam_methods():
224244 optimizer .load_state_dict (optimizer .state_dict ())
225245
226246
247+ @pytest .mark .cfg
227248def test_safe_fp16_methods ():
228249 param = simple_parameter ()
229250
@@ -244,12 +265,14 @@ def test_safe_fp16_methods():
244265 assert optimizer .loss_scale == 2.0 ** (15 - 1 )
245266
246267
268+ @pytest .mark .cfg
247269def test_ranger21_warm_methods ():
248270 assert Ranger21 .build_warm_up_iterations (1000 , 0.999 ) == 220
249271 assert Ranger21 .build_warm_up_iterations (4500 , 0.999 ) == 2000
250272 assert Ranger21 .build_warm_down_iterations (1000 ) == 280
251273
252274
275+ @pytest .mark .cfg
253276@pytest .mark .parametrize ('optimizer' , ['ranger21' , 'adai' ])
254277def test_size_of_parameter (optimizer ):
255278 param = simple_parameter (require_grad = False )
@@ -259,6 +282,7 @@ def test_size_of_parameter(optimizer):
259282 load_optimizer (optimizer )([param ], 1 ).step ()
260283
261284
285+ @pytest .mark .cfg
262286def test_ranger21_closure ():
263287 model : nn .Module = Example ()
264288 optimizer = load_optimizer ('ranger21' )(model .parameters (), num_iterations = 100 , betas = (0.9 , 1e-9 ))
@@ -273,6 +297,7 @@ def closure():
273297 optimizer .step (closure )
274298
275299
300+ @pytest .mark .cfg
276301def test_adafactor_reset ():
277302 param = torch .zeros (1 ).requires_grad_ (True )
278303 param .grad = torch .zeros (1 )
@@ -281,6 +306,7 @@ def test_adafactor_reset():
281306 optimizer .reset ()
282307
283308
309+ @pytest .mark .cfg
284310def test_adafactor_get_lr ():
285311 model : nn .Module = Example ()
286312
0 commit comments