#!/bin/bash set -euo pipefail mkdir -p /root/models/king/current KING=$(python3 - <<'PY' import json, re, urllib.request req = urllib.request.Request( "https://huggingface.co/api/models?author=dendriteholdings&limit=100", headers={"User-Agent": "ingot-setup"}) ms = [m["id"] for m in json.load(urllib.request.urlopen(req)) if re.fullmatch(r"dendriteholdings/Ingot-[IVX]+-27B-Q2", m["id"])] def rom(s): v = {"I": 1, "V": 5, "X": 10, "L": 50} t, out = 0, 0 for c in re.search(r"Ingot-([IVX]+)-", s).group(1): t, out = (v[c], out + v[c]) if t <= v[c] else (v[c], out - v[c]) return out top = sorted(ms, key=rom)[-2:] open("/root/models/king/.names", "w").write("\n".join(x.split("/")[1] for x in top)) print(top[1].split("/")[1]) PY ) PREV=$(head -1 /root/models/king/.names) echo "current king: $KING, predecessor: $PREV" [ -s /root/models/king/cur.gguf ] || curl -sL -o /root/models/king/cur.gguf \ "https://huggingface.co/dendriteholdings/$KING/resolve/main/$KING-PQ2_0.gguf" cp /root/models/king/cur.gguf "/root/models/king/current/$KING-PQ2_0.gguf" [ -s /root/models/king/prev.gguf ] || curl -sL -o /root/models/king/prev.gguf \ "https://huggingface.co/dendriteholdings/$PREV/resolve/main/$PREV-PQ2_0.gguf" for f in LICENSE NOTICE.txt; do [ -s "/root/models/king/current/$f" ] || curl -sL -o "/root/models/king/current/$f" \ "https://huggingface.co/dendriteholdings/$KING/resolve/main/$f" done sed -i \ -e "s|sd\[name\] = ck.get(name)$|sd[name] = ck.get(name).to(torch.bfloat16)|" \ -e 's|device_map="cpu"|device_map={"": "cuda"}|' \ -e 's|torch.save(out, "/dev/shm/king_hf.pt")|torch.save(out, "/root/king_hf.pt")|' \ -e 's|print("saved /dev/shm/king_hf.pt")|print("saved /root/king_hf.pt")|' \ /root/build_king_hf.py [ -s /root/king_hf.pt ] || /root/ingot/.venv/bin/python /root/build_king_hf.py cd /root/ingot .venv/bin/python /root/fn_test.py .venv/bin/python /root/transform_check.py echo "SETUP COMPLETE — all smokes green"