"""Shared constants and helpers (no MLX import here, so it works on any machine).""" import json import os from pathlib import Path DRAFT = "mlx-community/Qwen3.5-9B-MLX-4bit" TARGET_38 = "mlx-community/Qwen3.8-27B-4bit" TARGET_36 = "mlx-community/Qwen3.6-27B-4bit" MOE = "mlx-community/Qwen3.6-35B-A3B-4bit" ALL_MODELS = [DRAFT, TARGET_38, TARGET_36, MOE] MAX_TOKENS = 256 HERE = Path(__file__).parent OUT = Path(os.environ.get("SPEC_OUT", HERE / "out")) # run.sh sets this def hf_hub_dir(): if os.environ.get("HF_HUB_CACHE"): return Path(os.environ["HF_HUB_CACHE"]) home = os.environ.get("HF_HOME", str(Path.home() / ".cache" / "huggingface")) return Path(home) / "hub" def resolve(repo): """Local snapshot path and commit hash of a cached HF repo (offline, refs/main).""" d = hf_hub_dir() / ("models--" + repo.replace("/", "--")) commit = (d / "refs" / "main").read_text().strip() return d / "snapshots" / commit, commit def short(repo): return repo.split("/")[-1] def write_json(path, obj): path = Path(path) path.parent.mkdir(parents=True, exist_ok=True) tmp = path.with_suffix(path.suffix + ".tmp") tmp.write_text(json.dumps(obj, indent=2, default=str)) tmp.replace(path)