From 108cf9fc1f8c6bc0360a49ce790699928883b3d3 Mon Sep 17 00:00:00 2001 From: Tim Dettmers Date: Mon, 29 Nov 2021 08:21:05 -0800 Subject: Fixed unsafe use of eval. #8 --- tests/test_optim.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/test_optim.py b/tests/test_optim.py index d306511..5464043 100644 --- a/tests/test_optim.py +++ b/tests/test_optim.py @@ -392,3 +392,18 @@ def test_benchmark_blockwise(dim1, dim2, gtype, optim_name): #assert s < 3.9 + +def test_str_betas(): + betas = (0.80, 0.95) + strbetas = '(0.80, 0.95)' + + layer = torch.nn.Linear(10, 10) + + base = bnb.optim.Adam(layer.parameters(), betas=betas) + strbase = bnb.optim.Adam(layer.parameters(), betas=strbetas) + assert base.defaults['betas'][0] == 0.8 + assert base.defaults['betas'][1] == 0.95 + assert strbase.defaults['betas'][0] == 0.8 + assert strbase.defaults['betas'][1] == 0.95 + + -- cgit v1.2.3