ViuAI commited on
Commit
51eb3b0
·
verified ·
1 Parent(s): fc94952

Fix: disable progress bars and memory copy during base checkpoint download

Browse files
Files changed (1) hide show
  1. scripts/train.py +13 -4
scripts/train.py CHANGED
@@ -183,6 +183,13 @@ def run_live_eval_previews(model, tokenizer, device):
183
  # ------------------------------------------------------------------------------
184
  def ensure_dataset_and_base_ckpt(data_dir: str, base_ckpt_path: str, token: str = None):
185
  os.makedirs(data_dir, exist_ok=True)
 
 
 
 
 
 
 
186
  shards = [
187
  "train_tokens.npy", "train_labels.npy", "train_offsets.npy", "train_domains.npy",
188
  "val_tokens.npy", "val_labels.npy", "val_offsets.npy", "val_domains.npy",
@@ -196,14 +203,16 @@ def ensure_dataset_and_base_ckpt(data_dir: str, base_ckpt_path: str, token: str
196
  if not os.path.exists(target):
197
  print(f" • Fetching {s}...")
198
  dl = hf_hub_download(repo_id="ViuAI/ViuTranslate-Data", filename=s, repo_type="dataset", token=token)
199
- shutil.copy(dl, target)
 
200
  print(" ✅ All dataset shards downloaded.")
201
 
202
  if not os.path.exists(base_ckpt_path):
203
- print(f"\n🌐 Base checkpoint not found. Downloading base weights from ViuAI/ViuAI-500M...")
204
- os.makedirs(os.path.dirname(base_ckpt_path), exist_ok=True)
205
  dl_b = hf_hub_download(repo_id="ViuAI/ViuAI-500M", filename="checkpoints/ckpt_latest.pt", token=token)
206
- shutil.copy(dl_b, base_ckpt_path)
 
207
  print(" ✅ Base checkpoint ready.")
208
 
209
  # ------------------------------------------------------------------------------
 
183
  # ------------------------------------------------------------------------------
184
  def ensure_dataset_and_base_ckpt(data_dir: str, base_ckpt_path: str, token: str = None):
185
  os.makedirs(data_dir, exist_ok=True)
186
+ os.environ["HF_HUB_DISABLE_PROGRESS_BARS"] = "1"
187
+ try:
188
+ from huggingface_hub.utils import disable_progress_bars
189
+ disable_progress_bars()
190
+ except Exception:
191
+ pass
192
+
193
  shards = [
194
  "train_tokens.npy", "train_labels.npy", "train_offsets.npy", "train_domains.npy",
195
  "val_tokens.npy", "val_labels.npy", "val_offsets.npy", "val_domains.npy",
 
203
  if not os.path.exists(target):
204
  print(f" • Fetching {s}...")
205
  dl = hf_hub_download(repo_id="ViuAI/ViuTranslate-Data", filename=s, repo_type="dataset", token=token)
206
+ if dl != target and not os.path.exists(target):
207
+ shutil.copy(dl, target)
208
  print(" ✅ All dataset shards downloaded.")
209
 
210
  if not os.path.exists(base_ckpt_path):
211
+ print(f"\n🌐 Base checkpoint not found. Downloading base weights (~5.9GB) from ViuAI/ViuAI-500M...")
212
+ os.makedirs(os.path.dirname(base_ckpt_path) if os.path.dirname(base_ckpt_path) else ".", exist_ok=True)
213
  dl_b = hf_hub_download(repo_id="ViuAI/ViuAI-500M", filename="checkpoints/ckpt_latest.pt", token=token)
214
+ if dl_b != base_ckpt_path and not os.path.exists(base_ckpt_path):
215
+ shutil.copy(dl_b, base_ckpt_path)
216
  print(" ✅ Base checkpoint ready.")
217
 
218
  # ------------------------------------------------------------------------------