qwenjev / scripts /xet_experiment3.py
tchbcb's picture
v0.4.8: safetensors-loss fix + HEAD verification + v0.4.7 OOM-gate sync
e16119c verified
Raw History Blame Contribute Delete
1.94 kB
# Round 3: forensics — did commits land? does extension matter?
# env var set BEFORE hf import (subprocess-level effect via fresh process).
import os
os.environ["HF_HUB_DISABLE_XET"] = "1" # BEFORE any huggingface_hub import
import time, json, urllib.request
tok = open("/content/qwenjev_work_v3/.hf_token").read().strip()
from huggingface_hub import HfApi
import huggingface_hub
print("hf_hub:", huggingface_hub.__version__, flush=True)
try:
import hf_xet
print("hf_xet present:", getattr(hf_xet, "__version__", "?"), flush=True)
except ImportError:
print("hf_xet: NOT installed", flush=True)
api = HfApi(token=tok)
# ---- 1) recent commits: did test commits actually land? ----------------
commits = list(api.list_repo_commits("tchbcb/qwenjev", repo_type="model"))[:12]
for c in commits:
print("commit:", c.commit_id[:8], c.title[:70], flush=True)
# ---- 2) same 30MB payload, two extensions, no-xet env set pre-import ----
big = os.urandom(30 * 1024 * 1024)
open("/tmp/big.pt", "wb").write(big)
open("/tmp/big.bin", "wb").write(big)
res = {}
for ext in ["pt", "bin"]:
p = "t4_assets_v3/_xet_test/big_noxet." + ext
t0 = time.time()
try:
api.upload_file(path_or_fileobj="/tmp/big." + ext, path_in_repo=p,
repo_id="tchbcb/qwenjev", repo_type="model",
commit_message="xet test E noxet-" + ext)
res[ext] = "up " + str(round(time.time() - t0, 1)) + "s"
except Exception as e:
res[ext] = "ERR " + str(e)[:80]
time.sleep(2)
url = "https://huggingface.co/tchbcb/qwenjev/resolve/main/" + p
try:
r = urllib.request.urlopen(urllib.request.Request(url, method="HEAD"), timeout=30)
res[ext] += " | HEAD OK len=" + str(r.headers.get("Content-Length"))
except Exception as e:
res[ext] += " | HEAD FAIL " + str(e)[:40]
print(ext, "->", res[ext], flush=True)
print("EXPERIMENT3_DONE", flush=True)