Skip to content

Commit

Permalink
Update custom_merge_method.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ljleb authored Jun 17, 2024
1 parent d2e7454 commit b57d146
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions examples/custom_merge_method.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sd_mecha
import torch
from sd_mecha.extensions.merge_method import convert_to_recipe, LiftFlag, MergeSpace
from sd_mecha import Hyper
sd_mecha.set_log_level()


Expand Down Expand Up @@ -28,8 +29,10 @@ def custom_sum(
b: torch.Tensor | LiftFlag[MergeSpace.BASE],
*,
# hyperparameters go here
alpha: float = 0.5, # default arguments are honored
beta: float,
# `Hyper` is an union type of `float`, `int` and `dict` (the dict case is for a different weight per block MBW), which is what the caller of the method excpects.
# in practice the method only ever receives numeric types (int or float), so no need to worry about the dict case
alpha: Hyper = 0.5, # default arguments are honored
beta: Hyper,
# `@convert_to_recipe` introduces additional kwargs: `device=` and `dtype=`
# We must put `**kwargs` to satisfy the type system:
**kwargs,
Expand Down

0 comments on commit b57d146

Please sign in to comment.