Upload code/train_sft.py with huggingface_hub
Browse files280 unmodified lines2812822832842852862872882892902912922932942952962972982993003013025 unmodified lines308309310311312313314315316317318319320321280 unmodified linesif not base_ckpt_path:print(f"📥 Base checkpoint not found locally, downloading pretrained model from Hugging Face: ViuAI/ViuAI-500M...")target_path = os.path.abspath("base_ckpt/ckpt_latest.pt")os.makedirs(os.path.dirname(target_path), exist_ok=True)# 1. Try direct HTTP streaming download (Bypasses buggy HF xet/lock I/O errors on cloud NFS mounts)try:import requestsfrom huggingface_hub import hf_hub_urlfrom tqdm import tqdmurl = hf_hub_url(repo_id="ViuAI/ViuAI-500M", filename="checkpoints/ckpt_latest.pt", repo_type="model")headers = {"Authorization": f"Bearer {args.hf_token}"} if args.hf_token else {}print(f"📥 Direct HTTP Stream Download: checkpoints/ckpt_latest.pt -> {target_path}...")with requests.get(url, headers=headers, stream=True, timeout=60) as r:r.raise_for_status()total_size = int(r.headers.get("content-length", 0))with open(target_path, "wb") as f, tqdm(total=total_size, unit="B", unit_scale=True, desc="ckpt_latest.pt", ncols=80) as pbar:for chunk in r.iter_content(chunk_size=16 * 1024 * 1024): # 16 MB chunks for blazing speedif chunk:5 unmodified linestry:base_ckpt_path = hf_hub_download(repo_id="ViuAI/ViuAI-500M",filename="checkpoints/ckpt_latest.pt",local_dir=os.path.abspath("base_ckpt"),token=args.hf_token)except Exception:base_ckpt_path = hf_hub_download(repo_id="ViuAI/ViuAI-500M",filename="checkpoints/ckpt_best.pt",local_dir=os.path.abspath("base_ckpt"),token=args.hf_token)280 unmodified lines2812822832842852862872882892902912922932942952962972982993003013025 unmodified lines308309310311312313314315316317318319320321280 unmodified linesif not base_ckpt_path:print(f"📥 Base checkpoint not found locally, downloading pretrained model from Hugging Face: ViuAI/ViuAI-500M...")target_path = os.path.abspath("base_ckpt/ckpt_best.pt")os.makedirs(os.path.dirname(target_path), exist_ok=True)# 1. Try direct HTTP streaming download of ckpt_best.pt (1.84 GB lightweight base weights)try:import requestsfrom huggingface_hub import hf_hub_urlfrom tqdm import tqdmurl = hf_hub_url(repo_id="ViuAI/ViuAI-500M", filename="checkpoints/ckpt_best.pt", repo_type="model")headers = {"Authorization": f"Bearer {args.hf_token}"} if args.hf_token else {}print(f"📥 Direct HTTP Stream Download: checkpoints/ckpt_best.pt (1.84 GB) -> {target_path}...")with requests.get(url, headers=headers, stream=True, timeout=60) as r:r.raise_for_status()total_size = int(r.headers.get("content-length", 0))with open(target_path, "wb") as f, tqdm(total=total_size, unit="B", unit_scale=True, desc="ckpt_best.pt", ncols=80) as pbar:for chunk in r.iter_content(chunk_size=16 * 1024 * 1024): # 16 MB chunks for blazing speedif chunk:5 unmodified linestry:base_ckpt_path = hf_hub_download(repo_id="ViuAI/ViuAI-500M",filename="checkpoints/ckpt_best.pt",local_dir=os.path.abspath("base_ckpt"),token=args.hf_token)except Exception:base_ckpt_path = hf_hub_download(repo_id="ViuAI/ViuAI-500M",filename="checkpoints/ckpt_latest.pt",local_dir=os.path.abspath("base_ckpt"),token=args.hf_token)
code/train_sft.py+7-7