MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / LAMB

Class LAMB

bitsandbytes/optim/lamb.py:8–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7
8class LAMB(Optimizer2State):
9 def __init__(
10 self,
11 params,
12 lr=1e-3,
13 bias_correction=True,
14 betas=(0.9, 0.999),
15 eps=1e-8,
16 weight_decay=0,
17 amsgrad=False,
18 adam_w_mode=True,
19 optim_bits=32,
20 args=None,
21 min_8bit_size=4096,
22 max_unorm=1.0,
23 ):
24 """
25 Base LAMB optimizer.
26
27 Arguments:
28 params (`torch.tensor`):
29 The input parameters to optimize.
30 lr (`float`, defaults to 1e-3):
31 The learning rate.
32 bias_correction (`bool`, defaults to `True`):
33 Whether to apply bias correction to the first and second-order moments.
34 betas (`tuple(float, float)`, defaults to (0.9, 0.999)):
35 The beta values are the decay rates of the first and second-order moment of the optimizer.
36 eps (`float`, defaults to 1e-8):
37 The epsilon value prevents division by zero in the optimizer.
38 weight_decay (`float`, defaults to 1e-2):
39 The weight decay value for the optimizer.
40 amsgrad (`bool`, defaults to `False`):
41 Whether to use the [AMSGrad](https://hf.co/papers/1904.09237) variant of Adam that uses the maximum of past squared gradients instead.
42 adam_w_mode (`bool`, defaults to `True`):
43 Whether to use the AdamW variant.
44 optim_bits (`int`, defaults to 32):
45 The number of bits of the optimizer state.
46 args (`object`, defaults to `None`):
47 An object with additional arguments.
48 min_8bit_size (`int`, defaults to 4096):
49 The minimum number of elements of the parameter tensors for 8-bit optimization.
50 max_unorm (`float`, defaults to 1.0):
51 The maximum gradient norm.
52 """
53 super().__init__(
54 "lamb",
55 params,
56 lr,
57 betas,
58 eps,
59 weight_decay,
60 optim_bits,
61 args,
62 min_8bit_size,
63 max_unorm=max_unorm,
64 )
65

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected