""" Lightning AI'dan HuggingFace'e V5 verisi + checkpoint yukle. 3 ayri repo kullanir (clean separation): - musabc/nanogpt-tr-v5-data (dataset, ~30GB binaries + tokenizer) - musabc/nanogpt-tr-v5-ckpts (model, latest_ckpt.pt + best_ckpt.pt) - musabc/nanogpt-tr-v5-code (model, scripts — Thunder'da clone edilir) Kullanim: huggingface-cli login # bir kere python hf_push_v5.py --all # her seyi yukle python hf_push_v5.py --data # sadece binaries + tokenizer python hf_push_v5.py --ckpt # sadece checkpoints python hf_push_v5.py --code # sadece scriptler python hf_push_v5.py --user musabc # user/org override NOT: ilk yuklemede 30+ GB upload, internet hizina gore 30-60 dk. huggingface_hub multipart upload otomatik kullanir. """ import argparse import os import sys from pathlib import Path try: from huggingface_hub import HfApi, create_repo, upload_file, upload_folder except ImportError: print("! huggingface_hub yok. Yukle: pip install -U huggingface_hub") sys.exit(1) REPO_BASE = "nanogpt-tr-v5" DEFAULT_USER = "musabc" ROOT = Path(__file__).parent DATA_DIR = ROOT / "data" RUN_DIR = ROOT / "runs" / "tr-200m-v5" # Veri repo'suna gidecekler (dataset) DATA_FILES = [ DATA_DIR / "v5_stage1.bin", DATA_DIR / "v5_stage2.bin", DATA_DIR / "v5_stage3.bin", DATA_DIR / "v5_val.bin", DATA_DIR / "v5_val_stage1.bin", # opsiyonel — yoksa atlanir DATA_DIR / "v5_val_stage2.bin", DATA_DIR / "v5_val_stage3.bin", DATA_DIR / "tokenizer-tr-v5.json", ] # Checkpoint repo'suna gidecekler (model) CKPT_FILES = [ RUN_DIR / "latest_ckpt.pt", RUN_DIR / "best_ckpt.pt", RUN_DIR / "train.log", ] # Kod repo'suna gidecekler (model — kod da model repo'sunda ok) CODE_FILES = [ "model_v5.py", "muon.py", "05_train_v5.py", "06_sample.py", "04_tokenize.py", "04b_make_val.py", "hf_push_v5.py", "hf_pull_v5.py", # asagida olusturulacak ] def fmt_size(b): for u in ["B", "KB", "MB", "GB"]: if b < 1024: return f"{b:.1f} {u}" b /= 1024 return f"{b:.1f} TB" def ensure_repo(api: HfApi, repo_id: str, repo_type: str, private: bool): try: api.repo_info(repo_id, repo_type=repo_type) print(f" ✓ repo var: {repo_id} ({repo_type})") except Exception: print(f" + repo olusturuluyor: {repo_id} ({repo_type}, private={private})") create_repo(repo_id, repo_type=repo_type, private=private, exist_ok=True) def push_files(api: HfApi, repo_id: str, repo_type: str, files: list, target_subdir: str = ""): total_size = 0 pushed = 0 skipped = 0 for f in files: f = Path(f) if not f.exists(): print(f" - atlandı (yok): {f.name}") skipped += 1 continue size = f.stat().st_size total_size += size target = f"{target_subdir}/{f.name}" if target_subdir else f.name print(f" → {f.name} ({fmt_size(size)}) upload...", flush=True) api.upload_file( path_or_fileobj=str(f), path_in_repo=target, repo_id=repo_id, repo_type=repo_type, commit_message=f"upload {f.name}", ) pushed += 1 print(f"\n ✓ {pushed} dosya yuklendi ({fmt_size(total_size)}), " f"{skipped} atlandi") def write_data_readme(): """Dataset repo icin README olustur.""" content = """--- language: tr license: cc-by-4.0 size_categories: - 10B