daavidhauser's picture
Publish Swift HyperQwen collection with performance and quality comparisons
2bc6021 verified
Raw History Blame Contribute Delete
2.22 kB
"""Download pinned public inputs and install the isolated official verifier."""
import hashlib
import io
import subprocess
import sys
import urllib.request
import zipfile
from pathlib import Path
from huggingface_hub import snapshot_download
from common import ROOT, RUN, SOURCE, write_json, stamp
REPO = "ukisai/Swift-1.5-Qwen3.8-27b-W4A16-AWQ"
REVISION = "9dba8a05877150d587215a519ce6befec3c9978a"
IFBENCH = "1c40f0c10d9b5c5c2f10a175a28007ebb64f7f4d"
def main():
RUN.mkdir(parents=True, exist_ok=True)
snapshot_download(REPO, revision=REVISION, local_dir=SOURCE,
allow_patterns=["*.json", "*.safetensors", "*.jinja", "*.txt", "LICENSE*", "NOTICE", "recipe.yaml", "README.md"])
if not (RUN / "source.json").exists():
write_json(RUN / "source.json", {"repo": REPO, "revision": REVISION, "downloaded_at": stamp()})
env = RUN / "eval-venv"
if not (env / "bin/python").exists():
subprocess.run([sys.executable, "-m", "venv", str(env)], check=True)
subprocess.run([str(env / "bin/pip"), "install", "https://github.com/allenai/IFBench/archive/" + IFBENCH + ".zip"], check=True)
url = "https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/tokenizers/punkt_tab.zip"
payload = urllib.request.urlopen(url).read()
with zipfile.ZipFile(io.BytesIO(payload)) as archive:
assert all(not n.startswith("/") and ".." not in n.split("/") for n in archive.namelist())
archive.extractall(RUN / "nltk_data/tokenizers")
subprocess.run(["docker", "image", "inspect", "python:3.12-slim"], check=True, stdout=subprocess.DEVNULL)
image = subprocess.check_output(["docker", "image", "inspect", "python:3.12-slim", "--format", "{{.Id}}"], text=True).strip()
write_json(RUN / "evaluation/runtime.json", {"code_image": image, "ifbench_revision": IFBENCH,
"punkt_tab_sha256": hashlib.sha256(payload).hexdigest()})
subprocess.run([sys.executable, "swift15/corpus.py"], cwd=ROOT, check=True)
subprocess.run([sys.executable, "swift15/eval_data.py"], cwd=ROOT, check=True)
print("Setup complete. Existing patched HyperQwen venv and Python Docker image are required.")
if __name__ == "__main__":
main()