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

Function optimizer_update_32bit

bitsandbytes/functional.py:1080–1166  ·  view source on GitHub ↗

Performs an inplace optimizer update with one or two optimizer states. Universal optimizer update for 32-bit state and 32/16-bit gradients/weights. Parameters ---------- optimizer_name : str The name of the optimizer: {adam}. g : torch.Tensor Gradient tenso

(
    optimizer_name: str,
    g: Tensor,
    p: Tensor,
    state1: Tensor,
    beta1: float,
    eps: float,
    step: int,
    lr: float,
    state2: Optional[torch.Tensor] = None,
    beta2: float = 0.0,
    beta3: float = 0.0,
    alpha: float = 0.0,
    weight_decay: float = 0.0,
    gnorm_scale: float = 1.0,
    unorm_vec: Optional[torch.Tensor] = None,
    max_unorm: float = 0.0,
    skip_zeros=False,
)

Source from the content-addressed store, hash-verified

1078
1079
1080def optimizer_update_32bit(
1081 optimizer_name: str,
1082 g: Tensor,
1083 p: Tensor,
1084 state1: Tensor,
1085 beta1: float,
1086 eps: float,
1087 step: int,
1088 lr: float,
1089 state2: Optional[torch.Tensor] = None,
1090 beta2: float = 0.0,
1091 beta3: float = 0.0,
1092 alpha: float = 0.0,
1093 weight_decay: float = 0.0,
1094 gnorm_scale: float = 1.0,
1095 unorm_vec: Optional[torch.Tensor] = None,
1096 max_unorm: float = 0.0,
1097 skip_zeros=False,
1098) -> None:
1099 """
1100 Performs an inplace optimizer update with one or two optimizer states.
1101
1102 Universal optimizer update for 32-bit state and 32/16-bit gradients/weights.
1103
1104 Parameters
1105 ----------
1106 optimizer_name : str
1107 The name of the optimizer: {adam}.
1108 g : torch.Tensor
1109 Gradient tensor.
1110 p : torch.Tensor
1111 Parameter tensor.
1112 state1 : torch.Tensor
1113 Optimizer state 1.
1114 beta1 : float
1115 Optimizer beta1.
1116 eps : float
1117 Optimizer epsilon.
1118 weight_decay : float
1119 Weight decay.
1120 step : int
1121 Current optimizer step.
1122 lr : float
1123 The learning rate.
1124 state2 : torch.Tensor
1125 Optimizer state 2.
1126 beta2 : float
1127 Optimizer beta2.
1128 beta3 : float
1129 Optimizer beta3.
1130 alpha : float
1131 Optimizer alpha.
1132 gnorm_scale : float
1133 The factor to rescale the gradient to the max clip value.
1134 unorm_vec : torch.Tensor
1135 The tensor for the update norm.
1136 max_unorm : float
1137 The maximum update norm relative to the weight norm.

Callers

nothing calls this directly

Calls 1

is_on_gpuFunction · 0.85

Tested by

no test coverage detected