Sarthak commited on
Commit
c9e9334
·
1 Parent(s): 729d700

refactor(patch-utils): improve patch application check for tokenlearn

Browse files
Files changed (1) hide show
  1. src/distiller/patch_utils.py +12 -0
src/distiller/patch_utils.py CHANGED
@@ -176,6 +176,18 @@ def is_patch_already_applied(patch_file: Path, target_dir: Path) -> bool:
176
  return True
177
  break
178
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  return False
180
 
181
  except Exception as e:
 
176
  return True
177
  break
178
 
179
+ # For tokenlearn.patch, check if the indexing fix is already present
180
+ if "tokenlearn.patch" in patch_file.name:
181
+ pretrain_file = target_dir / "tokenlearn" / "pretrain.py"
182
+ if pretrain_file.exists():
183
+ pretrain_content = pretrain_file.read_text()
184
+ # Check for the specific fix we're adding
185
+ if (
186
+ "Fix for index out of bounds issue" in pretrain_content
187
+ and "torch.clamp(input_ids, 0, self.w.shape[0] - 1)" in pretrain_content
188
+ ):
189
+ return True
190
+
191
  return False
192
 
193
  except Exception as e: