Skip to content

Commit 79d17a9

Browse files
committed
add comments
1 parent da2c3a6 commit 79d17a9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/liger_kernel/transformers/monkey_patch.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def _bind_method_to_module(module, method_name: str, new_method: Callable):
5252

5353

5454
def _patch_rms_norm_module(module, offset=0.0, eps=1e-6, casting_mode="llama", in_place=True):
55+
# Check if the module is a PEFT ModulesToSaveWrapper
56+
# If it is, we need to patch the modules_to_save.default and original_modules
5557
if PEFT_AVAILABLE and isinstance(module, peft.utils.other.ModulesToSaveWrapper):
5658
module.modules_to_save.default.offset = offset
5759
module.modules_to_save.default.casting_mode = casting_mode
@@ -78,6 +80,8 @@ def _patch_rms_norm_module(module, offset=0.0, eps=1e-6, casting_mode="llama", i
7880

7981

8082
def _patch_layer_norm_module(module, eps=1e-6):
83+
# Check if the module is a PEFT ModulesToSaveWrapper
84+
# If it is, we need to patch the modules_to_save.default and original_modules
8185
if PEFT_AVAILABLE and isinstance(module, peft.utils.other.ModulesToSaveWrapper):
8286
module.hidden_size = module.normalized_shape
8387
_bind_method_to_module(module, "forward", LigerLayerNorm.forward)

0 commit comments

Comments
 (0)