Skip to content

Commit

Permalink
fix #95 issue
Browse files Browse the repository at this point in the history
 * check validity of keys
  • Loading branch information
wkpark committed Dec 28, 2023
1 parent 2d8f5d5 commit f9f39fb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/rebasin/weight_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,15 @@ def scipylap(cost):
return lapfunc


def _valid_key(key):
if "cond_stage_model.transformer.text_model." in key:
return True
return "model_" not in key


def apply_permutation(ps: PermutationSpec, perm, params):
"""Apply a `perm` to `params`."""
return {k: get_permuted_param(ps, perm, k, params) for k in params.keys() if "model_" not in k}
return {k: get_permuted_param(ps, perm, k, params) for k in params.keys() if _valid_key(k)}

def weight_matching(ps: PermutationSpec, params_a, params_b, special_layers=None, device="cpu", max_iter=3, init_perm=None, usefp16=False, usetqdm=True, full=False, lap="lap"):
"""Find a permutation of `params_b` to make them match `params_a`."""
Expand Down

0 comments on commit f9f39fb

Please sign in to comment.